MReI@sdZddlZddlZddlZddlmZddlmZmZy&ddl m Z m Z ddZ Wn4e k rddlmZm Z d dZ YnXdd lmZdd lmZdd lmZmZmZdd lmZddlmZddlmZmZddlmZddZ ddZ!dZ"GdddeZ#e$j%dj&Z'ddZ(ddZ)ddZ*idd 6d!d"6Z+d#d$Z,d%d&Z-d'd(Z.d)d*d+d,gZ/dddd-d.d/Z0dS)0z6setuptools.command.bdist_egg Build .egg distributionsN)Command) remove_treemkpath)get_pathget_python_versioncCs tdS)Npurelib)rrr7/tmp/pip-l4uy7dan-build/setuptools/command/bdist_egg.py _get_purelib sr )get_python_librcCs tdS)NF)r rrrr r s)log)DistutilsSetupError)get_build_platform Distributionensure_directory) EntryPoint)CodeType) basestringnext)LibrarycCsKd|kr%tjj|d}n|jdrG|dd}n|S)N.rmodulei)ospathsplitextendswith)filenamerrr strip_modules  rc CsOt|d}|jdjdddd|ddd d g|jdS) Nw zdef __bootstrap__():z- global __bootstrap__, __loader__, __file__z! import sys, pkg_resources, impz: __file__ = pkg_resources.resource_filename(__name__,%r)z3 __loader__ = None; del __bootstrap__, __loader__z& imp.load_dynamic(__name__,__file__)z__bootstrap__())openwritejoinclose)resourcepyfilefrrr write_stub"s  r)z7__import__("pkg_resources").declare_namespace(__name__)c@seZdZdZd,dddefd-d d d dfd.d/gZd ddgZddZddZddZ ddZ ddZ ddZ d d!Z d"d#Zd$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 eggz 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)cCsCd|_d|_d|_d|_d|_d|_d|_dS)Nr) bdist_dir plat_name keep_tempdist_dir skip_build egg_outputexclude_source_files)selfrrr initialize_options]s      zbdist_egg.initialize_optionscCs|jd}|_|j|_|jdkr^|jdj}tjj|d|_n|jdkr|t |_n|j dd|j dkrt dd|j |jt|jjo|jj }tjj|j|d|_ ndS)Negg_infobdisteggr:z.egg)dist_dirrC)get_finalized_commandei_cmdr@r7 bdist_baserrr$r8rset_undefined_optionsr<regg_nameZ egg_versionr distributionhas_ext_modulesr:)r>rErFbasenamerrr finalize_optionsgs !zbdist_egg.finalize_optionsc Csf|j|jd_tjjtjjt}|jj g}|j_ x|D]}t |t r t |dkr tjj |dr tjj|d}tjj|}||ks|j|tjr|t |dd|df}qq n|jj j|qVWz1tjd|j|jdddddWd||j_ XdS) Ninstallrzinstalling package data to %s install_dataforceroot)r7rD install_librrnormcaserealpathr rI data_files isinstancetuplelenisabs startswithsepappendr info call_command)r> site_packagesolditemrU normalizedrrr do_install_datas ! !-zbdist_egg.do_install_datacCs |jgS)N)r<)r>rrr get_outputsszbdist_egg.get_outputscKsmx!tD]}|j||jqW|jd|j|jd|j|j||}|j||S)z8Invoke reinitialized command `cmdname` with keyword argsr;dry_run)INSTALL_DIRECTORY_ATTRS setdefaultr7r;rfreinitialize_command run_command)r>Zcmdnamekwdirnamecmdrrr r_s  zbdist_egg.call_commandc Cs|jdtjd|j|jd}|j}d|_|jjrk|j rk|jdn|j ddd}||_|j \}}g|_ g}xt |D]\}}t jj|\} } t jj|jt| d} |j j| tjd ||jsCtt jj|| n|j| |jt jd ||ZinstcmdZold_rootrm all_outputs ext_outputsZ to_compiler.Zext_namerextr'Z archive_rootr@Z script_dirZ native_libsZ libs_filerrr runsx    "            $    z bdist_egg.runcCstjdxut|jD]d\}}}xR|D]J}|jdr3tjj||}tjd|tj |q3q3WqWdS)Nz+Removing .py files from temporary directoryz.pyz Deleting %s) r r^walk_eggr7rrrr$debugr)r>basedirsfilesnamerrrr rs  zbdist_egg.zap_pyfilescCsEt|jdd}|dk r%|Stjdt|j|jS)Nrz4zip_safe flag not set; analyzing archive contents...)rrIr r analyze_eggr7rz)r>saferrr r s   zbdist_egg.zip_safec Cs*g}xt|jD] \}}}||jkr:qnx|D]}|jdrAd|kr |t|jddjtjd}|jj|r t j d|tj j |d}|j st|d}|jt|jn|j|q nPqAqAWg|ddZ init_filesrrrrpkgrr(rrr r~s&  ,   zbdist_egg.make_init_filesc Cs'tj|jjpd}|jdijd}|dkrFdS|j sY|jrotd|fntj dd}|j }dj |j}|jd}t j j|j}d t}|js#tt j j|jd |jt|jd} | j|| jnd S) Nr!zsetuptools.installationZ eggsecutablerzGeggsecutable 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 rfa)r parse_maprIZ entry_pointsgetattrsextrasr sysversion module_namer$rrrKr<localsrfrrlr"r#r%) r>ZepmeppyverrfullrrKheaderr(rrr r*s*     "  zbdist_egg.gen_headercCstjj|j}tjj|d}xh|jjjD]W}|j|r:tjj||t |d}t ||j ||q:q:WdS)z*Copy metadata (egg info) to the target_dirr!N) rrnormpathr@r$rEfilelistrr[rYr copy_file)r> target_dirZ norm_egg_infoprefixrtargetrrr rSs% zbdist_egg.copy_metadata_toc Csg}g}id|j6}xtj|jD]\}}}xH|D]@}tjj|djtkrE|j|||qEqEWx3|D]+}|||d|tjj||rrpathsrrrrZ build_cmdrfullnamerrr ry_s(" " -$zbdist_egg.get_ext_outputs)r+r,r-)r/Nr0)r2r3r4)r5Nr6)__name__ __module__ __qualname__ descriptionr user_optionsboolean_optionsr?rLrdrer_rrrr~rrryrrrr r*4s8       R   ) r*z.dll .so .dylib .pydccshtj|}t|\}}}d|kr@|jdn|||fVx|D] }|VqUWdS)z@Walk an unpacked egg's contents, skipping the metadata directoryzEGG-INFON)rrrremove)egg_dirwalkerrrrZbdfrrr rs  rc CsxBtjD]4\}}tjjtjj|d|r |Sq WtsRdSd}xt|D]\}}}xn|D]f}|jds{|jdrq{q{|jds|jdr{t ||||o|}q{q{WqeW|S)NzEGG-INFOFTz.pyz.pywz.pycz.pyo) safety_flagsitemsrrrr$can_scanrr scan_module) rrzflagfnrrrrrrrr rs$  &rcCsxtjD]\}}tjj||}tjj|rq|dks^t||krtj|qq |dk r t||kr t|d}|j d|j q q WdS)Nrtr ) rrrrr$rboolrr"r#r%)rrrrr(rrr rs rzzip-safeTz not-zip-safeFc Cstjj||}|dd |kr/dS|t|ddjtjd}||rgdpjdtjj|d}tjd!krd}nd }t |d }|j |t j |} |j d} tjt| } x<d d gD].} | | krtjd || d} qqWd| krxZdddddddddddg D].} | | krctjd|| d} qcqcWnd| krd| krd|krtjdddkrtjd|d} qn| S)"z;Check whether module possibly uses unsafe-for-zipfile stuffNrOTrr!rr rb__file____path__z%s: module references %sFinspectZ getsourceZ getabsfileZ getsourcefileZgetfilegetsourcelinesZ findsourceZ getcommentsZ getframeinfoZgetinnerframesZgetouterframesstacktracez"%s: module MAY be using inspect.%sr__main__z2.4z.%s: top-level module may be 'python -m' script)rr)rrr$rYr|r\rr version_infor"readmarshalloadr%dictfromkeys iter_symbolsr rr) rrrrzrrrskipr(coderZsymbolsbadrrr rs>)*         $ rccsvx|jD] }|Vq WxV|jD]K}t|tr@|Vq#t|tr#xt|D] }|Vq\Wq#q#WdS)zBYield names and strings used by `code` and its nested code objectsN)co_names co_constsrWrrr)rrconstrrr rs rcCsDtjjd r&tjdkr&dStjdtjddS)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)rplatformr[r rrrrr rs" rrSrsrP install_baserc sddl}ttjj|dtjd|fdd}|dkrntjdk}n|j |j gt |}s|j ||d|} x0tj D]\} } } || | | qW| jn3x0tj D]\} } } |d| | qW|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. rNrfz#creating '%s' and adding '%s' to itcsx|D]}tjjtjj||}tjj|r|tdd}ss|j||ntjd|qqWdS)NrOz adding '%s') rrrr$rrYr#r r)zrlnamesrrr.)base_dirrfrr visits !zmake_zipfile..visitz2.4 compression)zipfilerrrrlr r^rr ZIP_STORED ZIP_DEFLATEDrZipFilerr%) zip_filenamerrurfcompressrvrrrrrlrrr)rrfr rs   r)1__doc__rrr setuptoolsrdistutils.dir_utilrr sysconfigrrr ImportErrordistutils.sysconfigr distutilsr distutils.errorsr pkg_resourcesrrrrtypesrZsetuptools.compatrrZsetuptools.extensionrrr)rr*rrsplitrrrrrrrrrgrrrrr sD$   H    # -