3 K] G @sxdZddlmZddlmZmZddlmZddlm Z ddl Z ddl Z ddl Z ddl Z ddlZddlmZddlmZmZmZdd lmZdd lmZdd lmZydd lmZmZd dZWn,ek rddlm Z mZddZYnXddZ!ddZ"ddZ#GdddeZ$e%j&dj'Z(ddZ)ddZ*ddZ+d d!d"Z,d#d$Z-d%d&Z.d'd(Z/d)d*d+d,gZ0d1d/d0Z1dS)2z6setuptools.command.bdist_egg Build .egg distributions)DistutilsSetupError) remove_treemkpath)log)CodeTypeN)six)get_build_platform Distributionensure_directory) EntryPoint)Library)Command)get_pathget_python_versioncCstdS)Npurelib)rrr/usr/lib/python3.6/bdist_egg.py _get_purelibsr)get_python_librcCstdS)NF)rrrrrrscCs2d|krtjj|d}|jdr.|dd}|S)N.rmodulei)ospathsplitextendswith)filenamerrr strip_module#s   rccs:x4tj|D]&\}}}|j|j|||fVq WdS)zbDo os.walk in a reproducible way, independent of indeterministic filesystem readdir order N)rwalksort)dirbasedirsfilesrrr sorted_walk+sr$c Cs6tjdj}t|d}|j||WdQRXdS)NaR def __bootstrap__(): global __bootstrap__, __loader__, __file__ import sys, pkg_resources, imp __file__ = pkg_resources.resource_filename(__name__, %r) __loader__ = None; del __bootstrap__, __loader__ imp.load_dynamic(__name__,__file__) __bootstrap__() w)textwrapdedentlstripopenwrite)ZresourcepyfileZ_stub_templatefrrr write_stub5s  r-c@seZdZdZd*dddefd+d-d.d/gZd ddgZddZddZddZ ddZ ddZ ddZ d d!Z d"d#Zd$d%Zd&d'Zd(d)Zd S)0 bdist_eggzcreate an "egg" distribution bdist-dir=b1temporary directory for creating the distributionz plat-name=pz;platform name to embed in generated filenames (default: %s)exclude-source-filesN+remove all .py files from the generated egg keep-tempkz/keep the pseudo-installation tree around after z!creating the distribution archive dist-dir=d-directory to put final built distributions in skip-build2skip rebuilding everything (for testing/debugging)cCs.d|_d|_d|_d|_d|_d|_d|_dS)Nr) bdist_dir plat_name keep_tempdist_dir skip_build egg_outputexclude_source_files)selfrrrinitialize_optionsZszbdist_egg.initialize_optionscCs|jd}|_|j|_|jdkr>|jdj}tjj|d|_|jdkrPt |_|j dd|j dkrt dd|j |jt|jjo|jj }tjj|j|d|_ dS)Negg_infoZbdistZeggr?z.egg)r?r?)get_finalized_commandei_cmdrEr< bdist_baserrjoinr=rZset_undefined_optionsrAr Zegg_nameZ egg_versionr distributionhas_ext_modulesr?)rCrGrHbasenamerrrfinalize_optionscs      zbdist_egg.finalize_optionsc Cs|j|jd_tjjtjjt}|jj g}|j_ x|D]}t |t rt |dkrtjj |drtjj|d}tjj|}||ks|j|tjr|t |dd|df}|jj j|qrgetattrr)rCZinstcmdZold_rootrk all_outputs ext_outputsZ to_compiler2Zext_namerextr+Z archive_rootrEZ script_dirZ native_libsZ libs_filerrrrunsz                    z bdist_egg.runc Cstjdxt|jD]\}}}x|D]}tjj||}|jdrXtjd|tj ||jdr&|}d}t j ||}tjj|tj |j dd} tjd|| fytj| Wntk rYnXtj|| q&WqWdS) Nz+Removing .py files from temporary directoryz.pyz Deleting %s __pycache__z#(?P.+)\.(?P[^.]+)\.pycnamez.pyczRenaming file from [%s] to [%s])rr_walk_eggr<rrrIrdebugrzrematchpardirgroupremoveOSErrorrename) rCr!r"r#rrZpath_oldpatternmZpath_newrrrrs*        zbdist_egg.zap_pyfilescCs2t|jdd}|dk r|Stjdt|j|jS)Nr|z4zip_safe flag not set; analyzing archive contents...)rrJrr~ analyze_eggr<rt)rCsaferrrr| s  zbdist_egg.zip_safec Cstj|jjpd}|jdijd}|dkr0dS|j s>|jrLtd|ftj dd}|j }dj |j}|jd}t j j|j}d t}|jstt j j|j|jd t|jd} | j|| jd S) Nzsetuptools.installationZ eggsecutabler%zGeggsecutable entry point (%r) cannot have 'extras' or refer to a modulerraH#!/bin/sh if [ `basename $0` = "%(basename)s" ] then exec python%(pyver)s -c "import sys, os; sys.path.insert(0, os.path.abspath('$0')); from %(pkg)s import %(base)s; sys.exit(%(full)s())" "$@" else echo $0 is not the correct name for this egg file. echo Please rename it back to %(basename)s and try again. exec false fi )rea)r Z parse_maprJZ entry_pointsgetZattrsZextrasrsysversionZ module_namerIrrrLrAlocalsrerrjr)r*rx) rCZepmZepZpyverpkgZfullr!rLheaderr,rrrrs*      zbdist_egg.gen_headercCsltjj|j}tjj|d}xJ|jjjD]<}|j|r(tjj||t |d}t ||j ||q(WdS)z*Copy metadata (egg info) to the target_dirrN) rrnormpathrErIrGZfilelistr#r\rZr Z copy_file)rCZ target_dirZ norm_egg_infoprefixrtargetrrrrw:s zbdist_egg.copy_metadata_toc Csg}g}|jdi}x|t|jD]n\}}}x6|D].}tjj|djtkr.|j|||q.Wx*|D]"}|||d|tjj||<qfWqW|j j r |j d}xd|j D]Z} t | trq|j| j} |j| }tjj|jdstjjtjj|j|r|j|qW||fS)zAGet a list of relative paths to C extensions in the output distrorrPrlZ build_extzdl-)r<r$rrrlowerNATIVE_EXTENSIONSr^rIrJrKrF extensionsrXr Zget_ext_fullnamerZget_ext_filenamerLr\r}) rCrrpathsr!r"r#rZ build_cmdrfullnamerrrrsFs(   &      zbdist_egg.get_ext_outputs)r/r0r1)r3Nr4Pkeep the pseudo-installation tree around after creating the distribution archive)r5r6r)r7r8r9)r:Nr;)__name__ __module__ __qualname__ descriptionrZ user_optionsZboolean_optionsrDrMrcrdr`rrr|rrwrsrrrrr.Cs4   Q' r.z.dll .so .dylib .pydccsLt|}t|\}}}d|kr(|jd|||fVx|D] }|Vq:WdS)z@Walk an unpacked egg's contents, skipping the metadata directoryzEGG-INFON)r$nextr)egg_dirZwalkerr!r"r#Zbdfrrrrfs   rc Csx0tjD]$\}}tjjtjj|d|r |Sq Wts.visit) compression) zipfilerrrrjrr_Z ZIP_DEFLATEDZ ZIP_STOREDZZipFiler$rx) Z zip_filenamerrqrecompressrrrrrrrjr"r#r)rrerrs  r)rrTr%)2__doc__Zdistutils.errorsrZdistutils.dir_utilrrZ distutilsrtypesrrrrr&rZsetuptools.externrZ pkg_resourcesrr r r Zsetuptools.extensionr Z setuptoolsr sysconfigrrr ImportErrorZdistutils.sysconfigrrr$r-r.rrsplitrrrr{rrrrrfrrrrrsL         " $