3 Qg<@slddlZddlZddlmZddlmZddlmZmZddl Tddl m Z ddl m Z Gdd d eZdS) N)Command) get_platform) create_tree remove_tree)*)get_python_version)logc@seZdZdZd5dddefd7d9d:d;dd?d@dAdBg ZddddgZejd&kZ d'd(Z d)d*Z d+d,Z d-d.Z dCd/d0Zd1d2Zd3d4ZdS)D bdist_wininstz-create an executable installer for MS Windows bdist-dir=N1temporary directory for creating the distributionz plat-name=pz;platform name to embed in generated filenames (default: %s) keep-tempkz/keep the pseudo-installation tree around after z!creating the distribution archivetarget-version=z!require a specific python versionz on the target systemno-target-compilec/do not compile .py to .pyc on the target systemno-target-optimizeo;do not compile .py to .pyo (optimized) on the target system dist-dir=d-directory to put final built distributions inbitmap=b>bitmap to use for the installer instead of python-powered logotitle=t?title to display on the installer background instead of default skip-build2skip rebuilding everything (for testing/debugging)install-script=Ubasename of installation script to be run after installation or before deinstallationpre-install-script={Fully qualified filename of a script to be run before any files are installed. This script need not be in the distributionuser-access-control=specify Vista's UAC handling - 'none'/default=no handling, 'auto'=use UAC if target Python installed for all users, 'force'=always use UACwin32cCsRd|_d|_d|_d|_d|_d|_d|_d|_d|_d|_ d|_ d|_ d|_ dS)Nr) bdist_dir plat_name keep_tempno_target_compileno_target_optimizetarget_versiondist_dirbitmaptitle skip_buildinstall_scriptpre_install_scriptuser_access_control)selfr67/usr/lib64/python3.6/distutils/command/bdist_wininst.pyinitialize_options=sz bdist_wininst.initialize_optionscCs|jdd |jdkrR|jr6|jr6|jjd}|j|_|jdj}tj j |d|_|j s^d|_ |j r|jj rt }|j r|j |krtd|f||_ |jdd d |jrx2|jjD]}|jtj j|krPqWtd|jdS) Nbdistr1ZwininstzMtarget 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_objget_finalized_command bdist_baseospathjoinr-has_ext_modulesrZDistutilsOptionErrorr2scriptsbasename)r5r9r=Z short_versionscriptr6r6r7finalize_optionsMs4      zbdist_wininst.finalize_optionsc Cstjdkr&|jjs|jjr&td|js6|jd|jddd}|j |_ |j|_d|_ |j |_ |jd}d|_ d|_|jjr|j}|sd tjdd }d |j |f}|jd}tjj|jd ||_x4dD],}|j}|dkr|d}t|d||qWtjd|j |jtjjdtjj|j d|jtjd=ddlm}|} |jj } |j!| d|j d} |j"| | |j#|jjrt$} nd} |jj%j&d| |j'| ftj(d| tj)| |j*st+|j |j,ddS)Nr'z^distribution contains extensions and/or C libraries; must be compiled on a Windows 32 platformbuildinstall)Zreinit_subcommandsr install_libz%d.%dz.%s-%slibpurelibplatlibheadersrBdataz/Include/$dist_nameZinstall_zinstalling to %sZPURELIB)mktempzip)Zroot_diranyr zremoving temporary file '%s')dry_run)rLrMrNrBrO)-sysplatformr;rAZhas_c_librariesZDistutilsPlatformErrorr1Z run_commandZreinitialize_commandr(rootZwarn_dirr)compileoptimizer- version_infor<r>r?r@Z build_baseZ build_libuppersetattrrinfoZensure_finalizedinsertrunZtempfilerP get_fullnameZ make_archive create_exer/rZ dist_filesappendget_installer_filenamedebugremover*rrS) r5rGrIr-Zplat_specifierrFkeyvaluerPZarchive_basenamefullnamearcnameZ pyversionr6r6r7r^ssd                  zbdist_wininst.runc Cs`g}|jj}|jd|jpdd}dd}xJdD]B}t||d}|r2|d|j||f}|jd|||fq2W|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 |jddS)Nriz\n)replace)sr6r6r7escapesz)bdist_wininst.get_inidata..escapeauthor author_email description maintainermaintainer_emailnameurlversionz %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)rmrnrorprqrrrsrt)r;metadataraZlong_descriptiongetattr capitalizer2r+r,r-r4r0r_time distutilsZctime __version__r@) r5linesrur\rlrrrOr0rxryZ build_infor6r6r7 get_inidatas<   zbdist_wininst.get_inidatac Csddl}|j|j|j}|j|}|jd||rPt|dj}t|}nd}t|d} | j |j |rz| j |t |t r|j d}|d}|jrt|jddd } | jj d} WdQRX|| d }n|d}| j ||jd d t||} | j | | j t|djdS) Nrz creating %srbwbmbcsrzlatin-1)encodings zr?r@r.r))r5rgrr6r6r7rb's  z$bdist_wininst.get_installer_filenamec Cs t}|jrl|j|krl|jdkr&d}q|jdkr6d}q|jdkrFd}q|jdkrVd}q|jdkrfd }qd }n@yd d lm}Wntk rd }YnX|jd d }|d}tjjt }|j dkr|j dddkr|j dd}nd}tjj |d||f}t |d}z|j S|jXdS)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@rrclose) r5Z cur_versionZbvrmajorZ directoryZsfixfilenamefr6r6r7r4s8         zbdist_wininst.get_exe_bytes)r Nr Pkeep the pseudo-installation tree around after creating the distribution archive)r rr6require 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__rorZ user_optionsZboolean_optionsrTrUZ _unsupportedr8rEr^r|r`rbrr6r6r6r7r sP &Q. 5 r )rTr>Zdistutils.corerZdistutils.utilrZdistutils.dir_utilrrZdistutils.errorsZdistutils.sysconfigrryrr r6r6r6r7s