Yf;@sdZddlZddlZddlmZddlmZddlmZm 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@seZdZdZd4dddefdd d d fd dd dfd5d6d7d8d9d:d;d<d=g ZddddgZd&d'Zd(d)Zd*d+Z d,d-Z dd.d/Z d0d1Z d2d3Z dS)> 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)z keep-tempkz/keep the pseudo-installation tree around after z!creating the distribution archiveztarget-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=Tbasename of installation script to be run afterinstallation 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 UACcCsyd|_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)selfr3D/opt/alt/python35/lib64/python3.5/distutils/command/bdist_wininst.pyinitialize_options:s            z bdist_wininst.initialize_optionscCsG|jdd |jdkry|jrO|jrO|jjd}|j|_|jdj}tj j |d|_|j sd|_ |j r|jj rt }|j r|j |krtd|f||_ |jdd d |jrCxC|jjD]"}|jtj j|kr Pq Wtd|jdS) Nbdistr.ZwininstzMtarget version can only be %s, or the '--skip-build' option must be specifiedr+r&z(install_script '%s' not found in scripts)r.r.)r+r+)r&r&)Zset_undefined_optionsr%r.r& distributionZget_command_objget_finalized_command bdist_baseospathjoinr*has_ext_modulesrZDistutilsOptionErrorr/scriptsbasename)r2r6r:Z short_versionscriptr3r3r4finalize_optionsJs4        zbdist_wininst.finalize_optionsc Cstjdkr9|jjs-|jjr9td|jsO|jd|jddd}|j |_ |j|_d|_ |j |_ |jd}d|_ d|_|jjr9|j}|s|jstd tjdd }d |j |f}|jd}tjj|jd ||_xDdD]<}|j}|dkrh|d}t|d||q@Wtjd|j |jtjjdtjj|j d|jtjd=ddlm }|} |jj!} |j"| dd|j } |j#| | |j$|jjrJt%} nd} |jj&j'd| |j(| ftj)d| tj*| |j+st,|j d|j-dS)Nwin32z^distribution contains extensions and/or C libraries; must be compiled on a Windows 32 platformbuildinstallZreinit_subcommandsr install_libz Should have already checked thisz.%s-%slibpurelibplatlibheadersr?dataz/Include/$dist_nameZinstall_zinstalling to %sZPURELIB)mktempzipZroot_diranyr zremoving temporary file '%s'dry_run)rJrKrLr?rM).sysplatformr8r>Zhas_c_librariesZDistutilsPlatformErrorr.Z run_commandZreinitialize_commandr%rootZwarn_dirr&compileoptimizer*AssertionErrorversionr9r;r<r=Z build_baseZ build_libuppersetattrrinfoZensure_finalizedinsertrunZtempfilerN get_fullnameZ make_archive create_exer,rZ dist_filesappendget_installer_filenamedebugremover'rrQ) r2rErGr*Zplat_specifierrDkeyvaluerNZarchive_basenamefullnamearcnameZ pyversionr3r3r4r]psf                %       zbdist_wininst.runc Csg}|jj}|jd|jp+dd}dd}x{dddd d d d d gD][}t||d}|r]|d|j||f}|jd|||fq]W|jd|jr|jd|j|jd|||jd|j |jd|j |j rD|jd|j |j ra|jd|j |j pv|jj }|jd||ddl }ddl} d|j|j | jf} |jd| dj|S)Nz [metadata]r7 cSs|jddS)Nrhz\n)replace)sr3r3r4escapesz)bdist_wininst.get_inidata..escapeZauthorZ author_email descriptionZ maintainerZmaintainer_emailnameZurlrXz %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)r8metadatar`Zlong_descriptiongetattr capitalizer/r(r)r*r1r-r^time distutilsZctime __version__r=) r2linesrnr[rkrmrMr-rqrrZ build_infor3r3r4 get_inidatas<   !      zbdist_wininst.get_inidatac Csddl}|j|j|j}|j|}|jd||rrt|dj}t|}nd}t|d} | j |j |r| j |t |t r|j d}|d}|jr&t|jddd } | jj d } WdQRX|| d }n |d}| j ||jd d t||} | j | | j t|djdS) Nrz creating %srbwbmbcssrencodingzlatin-1s zs