U +a@@s"dZddlmZmZddlmZddlmZddlZddl Z ddl Z ddl Z ddl Z ddl mZmZmZddlmZddlmZdd lmZmZd d Zd d ZddZddZGdddeZedZ ddZ!ddZ"ddZ#dddZ$ddZ%d d!Z&d"d#Z'd$d%d&d'gZ(d,d*d+Z)dS)-z6setuptools.command.bdist_egg Build .egg distributions) remove_treemkpath)log)CodeTypeN)get_build_platform Distributionensure_directory)Library)Command)get_pathget_python_versioncCstdS)Npurelib)r rrD/tmp/pip-install-1bd_1mtk/setuptools/setuptools/command/bdist_egg.py _get_purelibsrcCs2d|krtj|d}|dr.|dd}|S)N.rmodulei)ospathsplitextendswith)filenamerrr strip_modules   rccs6t|D]&\}}}|||||fVq dS)zbDo os.walk in a reproducible way, independent of indeterministic filesystem readdir order N)rwalksort)dirbasedirsfilesrrr sorted_walk!src Cs6td}t|d}|||W5QRXdS)Na def __bootstrap__(): global __bootstrap__, __loader__, __file__ import sys, pkg_resources, importlib.util __file__ = pkg_resources.resource_filename(__name__, %r) __loader__ = None; del __bootstrap__, __loader__ spec = importlib.util.spec_from_file_location(__name__,__file__) mod = importlib.util.module_from_spec(spec) spec.loader.exec_module(mod) __bootstrap__() w)textwrapdedentlstripopenwrite)resourcepyfileZ_stub_templatefrrr write_stub+s r)c@seZdZdZddddefdddd gZd d d gZd dZddZddZ ddZ ddZ ddZ ddZ ddZddZdd Zd!d"Zd#S)$ bdist_eggzcreate an "egg" distribution)z bdist-dir=bz1temporary directory for creating the distributionz plat-name=pz;platform name to embed in generated filenames (default: %s))exclude-source-filesNz+remove all .py files from the generated egg) keep-tempkzPkeep the pseudo-installation tree around after creating the distribution archive)z dist-dir=dz-directory to put final built distributions in) skip-buildNz2skip rebuilding everything (for testing/debugging)r.r1r-cCs.d|_d|_d|_d|_d|_d|_d|_dS)Nr) bdist_dir plat_name keep_tempdist_dir skip_build egg_outputexclude_source_filesselfrrrinitialize_optionsRszbdist_egg.initialize_optionscCs|d}|_|j|_|jdkr>|dj}tj|d|_|jdkrPt |_| dd|j dkrt dd|j |jt|jo|j }tj|j|d|_ dS)Negg_infobdistZegg)r5r5z.egg)get_finalized_commandei_cmdr<r2 bdist_baserrjoinr3rset_undefined_optionsr7regg_nameZ egg_versionr distributionhas_ext_modulesr5)r:r?r@basenamerrrfinalize_options[s$     zbdist_egg.finalize_optionscCs|j|d_tjtjt}|jj g}|j_ |D]}t |t rt |dkrtj |drtj|d}tj|}||ks||tjr|t |dd|df}|jj |q:z"td|j|jddddW5||j_ XdS)Ninstallrzinstalling package data to %s install_data)forceroot)r2r> install_librrnormcaserealpathrrD data_files isinstancetuplelenisabs startswithsepappendrinfo call_command)r: site_packagesolditemrP normalizedrrrdo_install_datass"  zbdist_egg.do_install_datacCs|jgS)N)r7r9rrr get_outputsszbdist_egg.get_outputscKsPtD]}|||jq|d|j|d|j|j|f|}|||S)z8Invoke reinitialized command `cmdname` with keyword argsr6dry_run)INSTALL_DIRECTORY_ATTRS setdefaultr2r6rareinitialize_command run_command)r:ZcmdnamekwdirnamecmdrrrrZs zbdist_egg.call_commandcCs|dtd|j|d}|j}d|_|jrH|jsH|d|j ddd}||_| \}}g|_ g}t |D]|\}}t j|\} } t j|jt| d} |j | td ||jstt j|| || |t jd ||<qz|r|||jjr||j} t j| d } || |jjrlt j| d }td ||j d|dd|| t j| d}|rtd||jst|t|d}| d|| d|!n,t j"|rtd||jst #|t$t j| d |%t j&t j|j'drrMrDhas_c_librariesr6rZget_ext_outputsstubs enumeraterrrrArrXrar)rFreplacerW byte_compilerQr_rrncopy_metadata_torr$r%closeisfileunlinkwrite_safety_flagzip_safeexistsr<warnr8 zap_pyfiles make_zipfiler7rs gen_headerr4rgetattrr )r:ZinstcmdZold_rootrh all_outputs ext_outputsZ to_compiler,Zext_namerextr'Z archive_rootr<Z script_dirZ native_libsZ libs_filerrrruns                      z bdist_egg.runc Cstdt|jD]\}}}|D]}tj||}|drTtd|t ||dr"|}d}t ||}tj|tj | dd} td|| fzt| Wntk rYnXt|| q"qdS) Nz+Removing .py files from temporary directoryrkz Deleting %s __pycache__z#(?P.+)\.(?P[^.]+)\.pycname.pyczRenaming file from [%s] to [%s])rrYwalk_eggr2rrrArdebugrrematchpardirgroupremoveOSErrorrename) r:rrrrrZpath_oldpatternmZpath_newrrrrs4       zbdist_egg.zap_pyfilescCs2t|jdd}|dk r|Stdt|j|jS)Nrz4zip_safe flag not set; analyzing archive contents...)rrDrr analyze_eggr2ry)r:saferrrrs  zbdist_egg.zip_safecCsdS)Nr rr9rrrr szbdist_egg.gen_headercCshtj|j}tj|d}|jjjD]<}||r&tj||t |d}t || ||q&dS)z*Copy metadata (egg info) to the target_dirN) rrnormpathr<rAr?filelistrrVrTr copy_file)r: target_dirZ norm_egg_infoprefixrtargetrrrr}s zbdist_egg.copy_metadata_toc Csg}g}|jdi}t|jD]f\}}}|D].}tj|dtkr*||||q*|D]"}|||d|tj||<q^q|j r| d}|j D]Z} t | trq|| j} || }tj|dstjtj|j|r||q||fS)zAGet a list of relative paths to C extensions in the output distrorrJrl build_extzdl-)r2rrrrlowerNATIVE_EXTENSIONSrXrArDrEr> extensionsrRr Zget_ext_fullnamerZget_ext_filenamerFrVr) r:rrpathsrrrrZ build_cmdrfullnamerrrrxs0        zbdist_egg.get_ext_outputsN)__name__ __module__ __qualname__ descriptionr user_optionsboolean_optionsr;rGr_r`rZrrrrr}rxrrrrr*;s2  Q r*z.dll .so .dylib .pydccsHt|}t|\}}}d|kr(|d|||fV|D] }|Vq8dS)z@Walk an unpacked egg's contents, skipping the metadata directoryrmN)rnextr)egg_dirwalkerrrrZbdfrrrr:s  rc CstD](\}}tjtj|d|r|Sqtst||krzt|q|dk rt||krt|d}| d| qdS)Nrqrr) rrrrrArboolrr$r%r~)rrrrr(rrrrWs    rzzip-safez not-zip-safe)TFc Cstj||}|dd|kr"dS|t|ddtjd}||rJdpLdtj|d}tjdkrpd }nd }t |d }| |t |} | d} tt| } d D]} | | krtd || d} qd| krdD]} | | krtd|| d} q| S)z;Check whether module possibly uses unsafe-for-zipfile stuffNTrJrrr) rb)__file____path__z%s: module references %sFinspect) getsource getabsfile getsourcefileZgetfilegetsourcelines findsource getcomments getframeinfogetinnerframesgetouterframesstacktracez"%s: module MAY be using inspect.%s)rrrArTr{rWrsys version_infor$readmarshalloadr~dictfromkeys iter_symbolsrr) rrrryrpkgrskipr(codersymbolsbadrrrrjs0     rccsR|jD] }|Vq|jD]4}t|tr.|Vqt|trt|D] }|Vq@qdS)zBYield names and strings used by `code` and its nested code objectsN)co_names co_constsrRstrrr)rrconstrrrrs     rcCs2tjdstjdkrdStdtddS)NjavacliTz1Unable to analyze compiled code on this platform.zfPlease ask the author to include a 'zip_safe' setting (either True or False) in the package's setup.py)rplatformrVrrrrrrrs rrNrprK install_baseTr c sddl}ttj|dtd|fdd}|rB|jn|j}s|j |||d} t D]\} } } || | | qd| n t D]\} } } |d| | q|S)aqCreate a zip file from all the files under 'base_dir'. The output zip file will be named 'base_dir' + ".zip". Uses either the "zipfile" Python module (if available) or the InfoZIP "zip" utility (if installed and found on the default search path). If neither tool is available, raises DistutilsExecError. Returns the name of the output zip file. rNruz#creating '%s' and adding '%s' to itcs`|D]V}tjtj||}tj|r|tdd}sN|||td|qdS)NrJz adding '%s') rrrrArrTr%rr)zrgnamesrrr,base_dirrarrvisits  zmake_zipfile..visit) compression) zipfilerrrrgrrY ZIP_DEFLATED ZIP_STOREDZipFilerr~) zip_filenamerrsracompressrtrrrrrgrrrrrrs  r)rrTr )*__doc__distutils.dir_utilrr distutilsrtypesrrrrr!r pkg_resourcesrrrZsetuptools.extensionr setuptoolsr sysconfigr r rrrr)r*rrsplitrrrrrrrrrbrrrrrsH     } "