509318396
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3
ct„jÈ<  ã               @   sp   d Z ddlZddlZddlmZ ddlmZ ddlmZm	Z	 ddl
T ddlmZ ddlmZ G d	d
„ d
eƒZdS )zzdistutils.command.bdist_wininst

Implements the Distutils 'bdist_wininst' command: create a windows installer
exe-program.é    N)ÚCommand)Úget_platform)Úcreate_treeÚremove_tree)Ú*)Úget_python_version)Úlogc               @   sŠ   e Zd ZdZd5dddeƒ  fd7d9d:d;d<d=d>d?d@dAdBgZddddgZejd&kZ	d'd(„ Z
d)d*„ Zd+d,„ Zd-d.„ ZdCd/d0„Zd1d2„ Zd3d4„ ZdS )DÚbdist_wininstz-create an executable installer for MS Windowsú
bdist-dir=Nú1temporary directory for creating the distributionz
plat-name=Úpz;platform name to embed in generated filenames (default: %s)ú	keep-tempÚkz/keep the pseudo-installation tree around after z!creating the distribution archiveútarget-version=z!require a specific python versionz on the target systemúno-target-compileÚcú/do not compile .py to .pyc on the target systemúno-target-optimizeÚoú;do not compile .py to .pyo (optimized) on the target systemú	dist-dir=Údú-directory to put final built distributions inúbitmap=Úbú>bitmap to use for the installer instead of python-powered logoútitle=Útú?title to display on the installer background instead of defaultú
skip-buildú2skip rebuilding everything (for testing/debugging)úinstall-script=úUbasename of installation script to be run after installation or before deinstallationúpre-install-script=ú{Fully qualified filename of a script to be run before any files are installed.  This script need not be in the distributionúuser-access-control=úŠspecify Vista's UAC handling - 'none'/default=no handling, 'auto'=use UAC if target Python installed for all users, 'force'=always use UACÚwin32c             C   sR   d | _ d | _d| _d| _d| _d | _d | _d | _d | _d | _	d | _
d | _d | _d S )Nr   )Ú	bdist_dirÚ	plat_nameÚ	keep_tempÚno_target_compileÚno_target_optimizeÚtarget_versionÚdist_dirÚbitmapÚtitleÚ
skip_buildÚinstall_scriptÚpre_install_scriptÚuser_access_control)Úself© r6   ú7/usr/lib64/python3.6/distutils/command/bdist_wininst.pyÚinitialize_options=   s    z bdist_wininst.initialize_optionsc             C   sæ   | j dd	ƒ | jd krR| jr6| jr6| jjdƒ}| j|_| jdƒj}tj	j
|dƒ| _| js^d| _| j rš| jjƒ rštƒ }| jr”| j|kr”td|f ƒ‚|| _| j dd
dƒ | jrâx2| jjD ]}| jtj	j|ƒkr¸P q¸W td| j ƒ‚d S )NÚbdistr1   ZwininstÚ zMtarget version can only be %s, or the '--skip-build' option must be specifiedr.   r)   z(install_script '%s' not found in scripts)r1   r1   )r.   r.   )r)   r)   )Zset_undefined_optionsr(   r1   r)   ÚdistributionZget_command_objÚget_finalized_commandÚ
bdist_baseÚosÚpathÚjoinr-   Úhas_ext_modulesr   ZDistutilsOptionErrorr2   ÚscriptsÚbasename)r5   r9   r=   Zshort_versionÚscriptr6   r6   r7   Úfinalize_optionsM   s4    

zbdist_wininst.finalize_optionsc             C   sä  t jdkr&| jjƒ s| jjƒ r&tdƒ‚| js6| jdƒ | jddd�}| j	|_
| j|_d|_| j|_| jdƒ}d|_d|_| jjƒ rÌ| j}|sžd	t jd d
…  }d| j|f }| jdƒ}tjj|jd| ƒ|_x4dD ],}|jƒ }|dkrî|d }t|d| |ƒ qÒW tjd| j	ƒ |jƒ  t jjdtjj| j	dƒƒ |jƒ  t jd= ddlm} |ƒ }	| jj ƒ }
| j!|	d| j	d�}| j"||
| j#ƒ | jjƒ �r”t$ƒ }nd}| jj%j&d|| j'|
ƒfƒ tj(d|ƒ tj)|ƒ | j*�sàt+| j	| j,d� d S )Nr'   z^distribution contains extensions and/or C libraries; must be compiled on a Windows 32 platformÚbuildÚinstallé   )Zreinit_subcommandsr   Úinstall_libz%d.%dé   z.%s-%sÚlibÚpurelibÚplatlibÚheadersrB   Údataz/Include/$dist_nameZinstall_zinstalling to %sZPURELIB)ÚmktempÚzip)Zroot_dirÚanyr	   zremoving temporary file '%s')Údry_run)rL   rM   rN   rB   rO   )-ÚsysÚplatformr;   rA   Zhas_c_librariesZDistutilsPlatformErrorr1   Zrun_commandZreinitialize_commandr(   ÚrootZwarn_dirr)   ÚcompileÚoptimizer-   Úversion_infor<   r>   r?   r@   Z
build_baseZ	build_libÚupperÚsetattrr   ÚinfoZensure_finalizedÚinsertÚrunZtempfilerP   Úget_fullnameZmake_archiveÚ
create_exer/   r   Z
dist_filesÚappendÚget_installer_filenameÚdebugÚremover*   r   rS   )r5   rG   rI   r-   Zplat_specifierrF   ÚkeyÚvaluerP   Zarchive_basenameÚfullnameÚarcnameZ	pyversionr6   r6   r7   r^   s   sd    












zbdist_wininst.runc             C   s`  g }| j j}|jdƒ |jpdd }dd„ }xJdD ]B}t||dƒ}|r2|d|jƒ ||ƒf  }|jd|||ƒf ƒ q2W |jdƒ | jr˜|jd| j ƒ |jd||ƒ ƒ |jd| j  ƒ |jd| j  ƒ | j	rä|jd| j	 ƒ | j
� rü|jd| j
 ƒ | j�p| j jƒ }|jd||ƒ ƒ dd l}dd l}	d|j|jƒ ƒ|	jf }
|jd|
 ƒ dj|ƒS )Nz
[metadata]r:   Ú
c             S   s   | j ddƒS )Nri   z\n)Úreplace)Úsr6   r6   r7   ÚescapeÑ   s    z)bdist_wininst.get_inidata.<locals>.escapeÚauthorÚauthor_emailÚdescriptionÚ
maintainerÚmaintainer_emailÚnameÚurlÚversionz
    %s: %sz%s=%sz
[Setup]zinstall_script=%szinfo=%sztarget_compile=%dztarget_optimize=%dztarget_version=%szuser_access_control=%sztitle=%sr   zBuilt %s with distutils-%szbuild_info=%s)rm   rn   ro   rp   rq   rr   rs   rt   )r;   Úmetadatara   Zlong_descriptionÚgetattrÚ
capitalizer2   r+   r,   r-   r4   r0   r_   ÚtimeÚ	distutilsZctimeÚ__version__r@   )r5   Úlinesru   r\   rl   rr   rO   r0   rx   ry   Z
build_infor6   r6   r7   Úget_inidataÄ   s<    

zbdist_wininst.get_inidatac             C   s  dd l }| j| jƒ | jƒ }| j|ƒ}| jd| ƒ |rPt|dƒjƒ }t|ƒ}nd}t|dƒ}	|	j	| j
ƒ ƒ |rz|	j	|ƒ t|tƒrŽ|jdƒ}|d }| jrÔt| jddd	��}
|
jƒ jdƒ}W d Q R X || d
 }n|d }|	j	|ƒ |jddt|ƒ|ƒ}|	j	|ƒ |	j	t|dƒjƒ ƒ d S )Nr   zcreating %sÚrbÚwbÚmbcsó    Úrzlatin-1)Úencodings   
 z<iiii{V4)ÚstructZmkpathr.   r|   rb   ZannounceÚopenÚreadÚlenÚwriteÚget_exe_bytesÚ
isinstanceÚstrÚencoder3   Zpack)r5   rh   rg   r/   rƒ   ZcfgdataÚinstaller_nameZ
bitmapdataZ	bitmaplenÚfilerD   Zscript_dataÚheaderr6   r6   r7   r`   ò   s:    








zbdist_wininst.create_exec             C   sD   | j r&tjj| jd|| j| j f ƒ}ntjj| jd|| jf ƒ}|S )Nz%s.%s-py%s.exez	%s.%s.exe)r-   r>   r?   r@   r.   r)   )r5   rg   rŒ   r6   r6   r7   rb   '  s    

z$bdist_wininst.get_installer_filenamec       	      C   s   t ƒ }| jrl| j|k rl| jdk r&d}q¬| jdkr6d}q¬| jdkrFd}q¬| jdkrVd}q¬| jdkrfd	}q¬d
}n@yddlm} W n tk
r”   d
}Y nX |jdƒd }|d }tjjt	ƒ}| j
dkrä| j
d d… dkrä| j
dd … }nd}tjj|d||f ƒ}t|dƒ}z|jƒ S |jƒ  X d S )Nz2.4z6.0z7.1z2.5z8.0z3.2z9.0z3.4z10.0z14.0r   )ÚCRT_ASSEMBLY_VERSIONÚ.z.0r'   é   Úwinr:   zwininst-%s%s.exer}   )r   r-   Zmsvcrtr�   ÚImportErrorÚ	partitionr>   r?   ÚdirnameÚ__file__r)   r@   r„   r…   Úclose)	r5   Zcur_versionZbvr�   ÚmajorZ	directoryZsfixÚfilenameÚfr6   r6   r7   rˆ   4  s8    	






zbdist_wininst.get_exe_bytes)r
   Nr   úPkeep the pseudo-installation tree around after creating the distribution archive)r   r   r›   ú6require a specific python version on the target system)r   Nrœ   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   Nr    )r!   Nr"   )r#   Nr$   )r%   Nr&   )N)Ú__name__Ú
__module__Ú__qualname__ro   r   Zuser_optionsZboolean_optionsrT   rU   Z_unsupportedr8   rE   r^   r|   r`   rb   rˆ   r6   r6   r6   r7   r	      sP                 
&Q.
5r	   )Ú__doc__rT   r>   Zdistutils.corer   Zdistutils.utilr   Zdistutils.dir_utilr   r   Zdistutils.errorsZdistutils.sysconfigr   ry   r   r	   r6   r6   r6   r7   Ú<module>   s   