3 �L�j�<�@spdZddlZddlZddlmZddlmZddlmZm Z ddl Tddl m Z ddl mZGd d �d e�ZdS) 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�eZdZdZd5ddde�fd7d9d:d;dd?d@dAdBg ZddddgZejd&kZ d'd(�Z d)d*�Z d+d,�Z d-d.�Z dCd/d0�Zd1d2�Zd3d4�ZdS)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�win32cCsRd|_d|_d|_d|_d|_d|_d|_d|_d|_d|_ d|_ d|_ d|_ dS)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=sz bdist_wininst.initialize_optionscCs�|jdd �|jdkrR|jr6|jr6|jjd�}|j|_|jd�j}tj j |d�|_|j s^d|_ |j r�|jj �r�t �}|j r�|j |kr�td|f��||_ |jdd d �|jr�x2|jjD]}|jtj j|�kr�Pq�Wtd|j��dS) N�bdistr1Zwininst�zMtarget version can only be %s, or the '--skip-build' option must be specifiedr.r)z(install_script '%s' not found in scripts)r1r1)r.r.)r)r))Zset_undefined_optionsr(r1r)� distributionZget_command_obj�get_finalized_command� bdist_base�os�path�joinr-�has_ext_modulesrZDistutilsOptionErrorr2�scripts�basename)r5r9r=Z short_version�scriptr6r6r7�finalize_optionsMs4      zbdist_wininst.finalize_optionsc Cs�tjdkr&|jj�s|jj�r&td��|js6|jd�|jddd�}|j |_ |j|_d|_ |j |_ |jd�}d|_ d|_|jj�r�|j}|s�|js�td ��d tjdd �}d |j |f}|jd�}tjj|jd |�|_x6dD].}|j�}|dk�r�|d}t|d||�q�Wtjd|j �|j�tjjdtjj|j d��|j�tjd=ddlm }|�} |jj!�} |j"| d|j d�} |j#| | |j$�|jj��r�t%�} nd} |jj&j'd| |j(| �f�tj)d| �tj*| �|j+�s�t,|j |j-d�dS)Nr'z^distribution contains extensions and/or C libraries; must be compiled on a Windows 32 platform�build�install�)Zreinit_subcommandsr� install_libz Should have already checked thisz%d.%d�z.%s-%s�lib�purelib�platlib�headersrB�dataz/Include/$dist_nameZinstall_zinstalling to %sZPURELIB)�mktemp�zip)Zroot_dir�anyr zremoving temporary file '%s')�dry_run)rLrMrNrBrO).�sys�platformr;rAZhas_c_librariesZDistutilsPlatformErrorr1Z run_commandZreinitialize_commandr(�rootZwarn_dirr)�compile�optimizer-�AssertionError� version_infor<r>r?r@Z build_baseZ build_lib�upper�setattrr�infoZensure_finalized�insert�runZtempfilerP� get_fullnameZ make_archive� create_exer/rZ dist_files�append�get_installer_filename�debug�remover*rrS) r5rGrIr-Zplat_specifierrF�key�valuerPZarchive_basename�fullname�arcnameZ pyversionr6r6r7r_ssf                   zbdist_wininst.runc Cs`g}|jj}|jd�|jpdd}dd�}xJdD]B}t||d�}|r2|d|j�||�f}|jd|||�f�q2W|jd�|jr�|jd|j�|jd||��|jd|j �|jd|j �|j r�|jd|j �|j �r�|jd|j �|j �p |jj �}|jd||��ddl }ddl} d|j|j ��| jf} |jd| �dj|�S)Nz [metadata]r:� cSs |jdd�S)Nrjz\n)�replace)�sr6r6r7�escape�sz)bdist_wininst.get_inidata..escape�author� author_email� description� maintainer�maintainer_email�name�url�versionz %s: %sz%s=%sz [Setup]zinstall_script=%szinfo=%sztarget_compile=%dztarget_optimize=%dztarget_version=%szuser_access_control=%sztitle=%srzBuilt %s with distutils-%sz build_info=%s)rnrorprqrrrsrtru)r;�metadatarbZlong_description�getattr� capitalizer2r+r,r-r4r0r`�time� distutilsZctime� __version__r@) r5�linesrvr]rmrsrOr0ryrzZ build_infor6r6r7� get_inidata�s<   zbdist_wininst.get_inidatac Csddl}|j|j�|j�}|j|�}|jd|�|rPt|d�j�}t|�}nd}t|d�} | j |j ��|rz| j |�t |t �r�|j d�}|d}|jr�t|jddd ��} | j�j d�} WdQRX|| d }n|d}| j |�|jd d t|�|�} | j | �| j t|d�j��dS) Nrz creating %s�rb�wb�mbcs��rzlatin-1)�encodings zr?r@r.r))r5rhr�r6r6r7rc's  z$bdist_wininst.get_installer_filenamec Cs t�}|jrl|j|krl|jdkr&d}q�|jdkr6d}q�|jdkrFd}q�|jdkrVd}q�|jdkrfd }q�d }n@yd d lm}Wntk r�d }YnX|jd �d }|d}tjjt �}|j dkr�|j dd�dkr�|j dd�}nd}tjj |d||f�}t |d�}z|j �S|j�XdS)Nz2.4z6.0z7.1z2.5z8.0z3.2z9.0z3.4z10.0z14.0r)�CRT_ASSEMBLY_VERSION�.z.0r'��winr:zwininst-%s%s.exer~)rr-Zmsvcrtr�� ImportError� partitionr>r?�dirname�__file__r)r@r�r��close) r5Z cur_versionZbvr��majorZ directoryZsfix�filename�fr6r6r7r�4s8         zbdist_wininst.get_exe_bytes)r Nr �Pkeep the pseudo-installation tree around after creating the distribution archive)r rr��6require a specific python version on the target system)rNr�)rrr)rrr)rrr)rrr)rrr)rNr )r!Nr")r#Nr$)r%Nr&)N)�__name__� __module__� __qualname__rprZ user_optionsZboolean_optionsrTrUZ _unsupportedr8rEr_r}rarcr�r6r6r6r7r sP &Q. 5 r )�__doc__rTr>Zdistutils.corerZdistutils.utilrZdistutils.dir_utilrrZdistutils.errorsZdistutils.sysconfigrrzrr r6r6r6r7�s