3 e@@s"dZddlmZmZddlmZddlmZddlZddl Z ddl Z ddl Z ddl Z ddl mZmZmZddlmZddlmZdd lmZmZd d Zd d ZddZddZGdddeZejdjZ 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 rrB/tmp/pip-build-vlmub77e/setuptools/setuptools/command/bdist_egg.py _get_purelibsrcCs2d|krtjj|d}|jdr.|dd}|S)N.rmodulei)ospathsplitextendswith)filenamerrr strip_modules   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)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@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_optionsRszbdist_egg.initialize_optionscCs|jd}|_|j|_|jdkr>|jdj}tjj|d|_|jdkrPt |_|j dd|j dkrt dd|j |jt|jjo|jj }tjj|j|d|_ dS)Negg_infobdistZeggr<z.egg)r<r<)get_finalized_commandei_cmdrBr9 bdist_baserrjoinr:rset_undefined_optionsr>regg_nameZ egg_versionr distributionhas_ext_modulesr<)r@rErFbasenamerrrfinalize_options[s      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|q)r@rrr get_outputsszbdist_egg.get_outputscKsTxtD]}|j||jqW|jd|j|jd|j|j|f|}|j||S)z8Invoke reinitialized command `cmdname` with keyword argsr=dry_run)INSTALL_DIRECTORY_ATTRS setdefaultr9r=rgreinitialize_command run_command)r@Zcmdnamekwdirnamecmdrrrr`s  zbdist_egg.call_commandcCs|jdtjd|j|jd}|j}d|_|jjrJ|j rJ|jd|j ddd}||_|j \}}g|_ g}xt |D]|\}}t jj|\} } t jj|jt| d} |j j| tjd ||jstt jj|| |j| |jt jd ||<q~W|r|j||jjr |j|j} t jj| d } |j| |jjrrt jj| d }tjd ||j d|dd|j| t jj| d}|rtjd||jst|t|d}|j dj||j d|j!n,t jj"|rtjd||jst j#|t$t jj| d |j%t jj&t jj|j'drBtj(d|j)rR|j*t+|j,| |j-|j|j.d|j/st0|j|jdt1|jdgjdt2|j,fdS)NrBzinstalling library code to %srN build_clibrTr)warn_dirz.pyzcreating stub loader for %s/zEGG-INFOscriptszinstalling scripts to %sinstall_scriptsrP) install_dirZno_epznative_libs.txtz writing %swt z removing %sz depends.txtzxWARNING: 'depends.txt' will not be used by setuptools 0.6! Use the install_requires/extras_require setup() args instead.)verbosergmode)rg dist_filesr+)3rkrr_r9rDrSrJhas_c_librariesr=r`get_ext_outputsstubs enumeraterrrrGrr^rgr*rLreplacer] byte_compilerWrerrrcopy_metadata_torr%r&closeisfileunlinkwrite_safety_flagzip_safeexistsrBwarnr? zap_pyfiles make_zipfiler>rw gen_headerr;rgetattrr )r@ZinstcmdZold_rootrn all_outputs ext_outputsZ to_compiler/Zext_namerextr(Z archive_rootrBZ 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_eggr9rrrGrdebugrrematchpardirgroupremoveOSErrorrename) r@rrrrrZpath_oldpatternmZpath_newrrrrs*        zbdist_egg.zap_pyfilescCs2t|jdd}|dk r|Stjdt|j|jS)Nrz4zip_safe flag not set; analyzing archive contents...)rrJrr analyze_eggr9r|)r@saferrrrs  zbdist_egg.zip_safecCsdS)Nr!r)r@rrrr szbdist_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_dirN) rrnormpathrBrGrEfilelistrr\rZr copy_file)r@ target_dirZ norm_egg_infoprefixrtargetrrrrs 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 distrorrPrq build_extzdl-)r9r rrrlowerNATIVE_EXTENSIONSr^rGrJrKrD extensionsrXr Zget_ext_fullnamerZget_ext_filenamerLr\r) r@rrpathsrrrrZ build_cmdrfullnamerrrr{s(   &      zbdist_egg.get_ext_outputs)r,r-r.)r0Nr1Pkeep the pseudo-installation tree around after creating the distribution archive)r2r3r)r4r5r6)r7Nr8)__name__ __module__ __qualname__ descriptionr user_optionsboolean_optionsrArMrerfr`rrrrrr{rrrrr+;s4   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_dirwalkerrrrZbdfrrrr:s   rc Csx0tjD]$\}}tjjtjj|d|r |Sq Wts.visit) compression) zipfilerrrrmrr_ ZIP_DEFLATED ZIP_STOREDZipFiler r) zip_filenamerrwrgcompressrxrrrrrmrrr)rrgrrs  r)rrTr!)*__doc__distutils.dir_utilrr distutilsrtypesrrrrr"r pkg_resourcesrrrZsetuptools.extensionr setuptoolsr sysconfigr r rrr r*r+rrsplitrrrrrrrrrhrrrrrs<     } "