U e@@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 rrJ/opt/hc_python/lib/python3.8/site-packages/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_infobdistegg)r5r5z.egg)get_finalized_commandei_cmdr<r2 bdist_baserrjoinr3rset_undefined_optionsr7regg_nameZ egg_versionr distributionhas_ext_modulesr5)r:r@rAbasenamerrrfinalize_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_librrnormcaserealpathrrE data_files isinstancetuplelenisabs startswithsepappendrinfo call_command)r: site_packagesolditemrQ 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 setdefaultr2r6rbreinitialize_command run_command)r:Zcmdnamekwdirnamecmdrrrr[s 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'dr.+)\.(?P[^.]+)\.pycname.pyczRenaming file from [%s] to [%s])rrZwalk_eggr2rrrBrdebugrrematchpardirgroupremoveOSErrorrename) r:rrrrrZpath_oldpatternmZpath_newrrrrs4       zbdist_egg.zap_pyfilescCs2t|jdd}|dk r|Stdt|j|jS)Nrz4zip_safe flag not set; analyzing archive contents...)rrErr analyze_eggr2rz)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<rBr@filelistrrWrUr 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 distrorrKrm build_extzdl-)r2rrrrlowerNATIVE_EXTENSIONSrYrBrErFr? extensionsrSr Zget_ext_fullnamerZget_ext_filenamerGrWr) r:rrpathsrrrrZ build_cmdrfullnamerrrrys0        zbdist_egg.get_ext_outputsN)__name__ __module__ __qualname__ descriptionr user_optionsboolean_optionsr;rHr`rar[rrrrr~ryrrrrr*;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 directoryrnN)rnextr)egg_dirZwalkerrrrZbdfrrrr:s  rc CstD](\}}tjtj|d|r|Sqtst||krzt|q|dk rt||krt|d}| d| qdS)Nrrrs) rrrrrBrboolrr$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 stuffNTrKrrr) rb)__file____path__z%s: module references %sFinspect) getsource getabsfile getsourcefileZgetfilegetsourcelines findsource getcomments getframeinfogetinnerframesgetouterframesstacktracez"%s: module MAY be using inspect.%s)rrrBrUr|rXrsys version_infor$readmarshalloadrdictfromkeys iter_symbolsrr) rrrrzrpkgrskipr(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_constsrSstrrr)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)rplatformrWrrrrrrrs rrOrqrL 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. rNrvz#creating '%s' and adding '%s' to itcs`|D]V}tjtj||}tj|r|tdd}sN|||td|qdS)NrKz adding '%s') rrrrBrrUr%rr)zrhnamesrrr,base_dirrbrrvisits  zmake_zipfile..visit) compression) zipfilerrrrhrrZ ZIP_DEFLATED ZIP_STOREDZipFilerr) zip_filenamerrtrbcompressrurrrrrhrrrrrrs  r)rrTr )*__doc__distutils.dir_utilrr distutilsrtypesrrrrr!r pkg_resourcesrrrZsetuptools.extensionr setuptoolsr sysconfigr r rrrr)r*rrsplitrrrrrrrrrcrrrrrsH     } "