3  fJ<@spdZddlZddlZddlmZddlmZddlmZm Z ddl Tddl m Z ddl mZGd d d eZdS) 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@seZdZdZd4dddefd6d8d9d:d;dd?d@dAg ZddddgZd&d'Zd(d)Zd*d+Z d,d-Z dBd.d/Z d0d1Z d2d3Z dS)C 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 UACcCsRd|_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)selfr5D/opt/alt/python36/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) Nbdistr0ZwininstzMtarget version can only be %s, or the '--skip-build' option must be specifiedr-r(z(install_script '%s' not found in scripts)r0r0)r-r-)r(r()Zset_undefined_optionsr'r0r( distributionZget_command_objget_finalized_command bdist_baseospathjoinr,has_ext_modulesrZDistutilsOptionErrorr1scriptsbasename)r4r8r<Z short_versionscriptr5r5r6finalize_optionsJs4      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)Nwin32z^distribution contains extensions and/or C libraries; must be compiled on a Windows 32 platformbuildinstall)Zreinit_subcommandsr install_libz%d.%dz.%s-%slibpurelibplatlibheadersrAdataz/Include/$dist_nameZinstall_zinstalling to %sZPURELIB)mktempzip)Zroot_diranyr zremoving temporary file '%s')dry_run)rLrMrNrArO)-sysplatformr:r@Zhas_c_librariesZDistutilsPlatformErrorr0Z 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) r4rGrIr,Zplat_specifierrFkeyvaluerPZarchive_basenamefullnamearcnameZ pyversionr5r5r6r^psd                  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]r9 cSs |jddS)Nriz\n)replace)sr5r5r6escapesz)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 capitalizer1r*r+r,r3r/r_time distutilsZctime __version__r?) r4linesrur\rlrrrOr/rxryZ build_infor5r5r6 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()r4rgrr5r5r6rb$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.0rEwinr9zwininst-%s%s.exer})rr,Zmsvcrtr ImportError partitionr=r>dirname__file__r(r?rrclose) r4Z cur_versionZbvrmajorZ directoryZsfixfilenamefr5r5r6r1s8         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_optionsr7rDr^r|r`rbrr5r5r5r6r sN&Q. 5 r )__doc__rTr=Zdistutils.corerZdistutils.utilrZdistutils.dir_utilrrZdistutils.errorsZdistutils.sysconfigrryrr r5r5r5r6s