U +ab@sdZddlmZddlmZddlmZddlm Z ddlZddlZddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlmZddlmZdd lmZdd lmZdd lmZdd lmZmZmZmZm Z m!Z!m"Z"m#Z#ddl$m%Z%dd l&m'Z'ddl(m)Z)ddlm*Z*ddZ+GdddZ,Gddde,eZ-GdddeZGdddeZ.ddZ/ddZ0ddZ1d d!Z2d"d#Z3d$d%Z4d&d'Z5d(d)Z6d3d+d,Z7d-d.Z8d/d0Z9Gd1d2d2e*Z:dS)4zUsetuptools.command.egg_info Create a distribution's .egg-info directory and contents)FileList)DistutilsInternalError) convert_path)logN)Command)sdist) walk_revctrl) edit_config) bdist_egg)parse_requirements safe_name parse_version safe_version yield_lines EntryPointiter_entry_points to_filename)glob) packaging)SetuptoolsDeprecationWarningcCsd}|tjj}ttj}d|f}t|D]\}}|t|dk}|dkrr|r`|d7}q0|d||f7}q0d}t|} || kr||} | dkr||d7}n| d kr||7}n| d kr|d} | | kr|| d kr| d} | | kr|| d kr| d} | | kr,|| d kr,| d} q| | krF|t| 7}nR||d| } d} | dd krxd } | dd} | t| 7} |d| f7}| }n|t| 7}|d7}q~|s0||7}q0|d7}tj|tj tj BdS)z Translate a file path glob like '*.txt' in to a regular expression. This differs from fnmatch.translate which allows wildcards to match directory separators. It also knows about '**/' which matches any number of directories. z[^%s]**z.*z (?:%s+%s)*r*?[!]^Nz[%s]z\Z)flags) splitospathsepreescape enumeratelencompile MULTILINEDOTALL)rpatchunksr#Z valid_charcchunk last_chunkiZ chunk_lencharZinner_iinner char_classr4C/tmp/pip-install-1bd_1mtk/setuptools/setuptools/command/egg_info.pytranslate_pattern#sV           r6c@s@eZdZdZdZeddZddZddZdd Z ee Z dS) InfoCommonNcCst|jSN)r distributionget_nameselfr4r4r5namezszInfoCommon.namecCst||jSr8)r _maybe_tagr9 get_versionr;r4r4r5tagged_version~szInfoCommon.tagged_versioncCs |jr||jr|S||jS)z egg_info may be called more than once for a distribution, in which case the version string already contains all tags. )vtagsendswithr<versionr4r4r5r>szInfoCommon._maybe_tagcCs,d}|jr||j7}|jr(|td7}|S)Nrz-%Y%m%d) tag_buildtag_datetimestrftimerCr4r4r5tagss  zInfoCommon.tags) __name__ __module__ __qualname__rErFpropertyr=r@r>rIrAr4r4r4r5r7vs  r7c@seZdZdZddddgZdgZddiZdd Zed d Z e j d d Z d dZ ddZ dddZ ddZddZddZddZddZdS) egg_infoz+create a distribution's .egg-info directory)z egg-base=ezLdirectory containing .egg-info directories (default: top of the source tree))tag-datedz0Add date stamp (e.g. 20050528) to version number)z tag-build=bz-Specify explicit tag to add to version number)no-dateDz"Don't include date stamp [default]rPrScCs"d|_d|_d|_d|_d|_dS)NF)egg_baseegg_namerN egg_versionbroken_egg_infor;r4r4r5initialize_optionss zegg_info.initialize_optionscCsdSr8r4r;r4r4r5tag_svn_revisionszegg_info.tag_svn_revisioncCsdSr8r4)r<valuer4r4r5rZscCs0t}||d<d|d<t|t|ddS)z Materialize the value of date into the build tag. Install build keys in a deterministic order to avoid arbitrary reordering on subsequent builds. rErrF)rNN) collections OrderedDictrIr dict)r<filenamerNr4r4r5save_version_infos zegg_info.save_version_infoc CsT|j|_||_t|j}z6t|tjj}|r4dnd}t t ||j|jfWn<t k r}zt j d|j|jf|W5d}~XYnX|jdkr|jj}|pidtj|_|dt|jd|_|jtjkrtj|j|j|_d|jkr||j|jj_|jj}|dk rP|j|jkrP|j|_t|j|_ d|j_dS)Nz%s==%sz%s===%sz2Invalid distribution name or version syntax: %s-%srrU .egg-info-)!r=rVr@rWr isinstancerrDVersionlistr ValueError distutilserrorsDistutilsOptionErrorrUr9 package_dirgetr!curdirensure_dirnamerrNr"joincheck_broken_egg_infometadataZ _patched_distkeylower_version_parsed_version)r<parsed_versionZ is_versionspecrOdirspdr4r4r5finalize_optionssB          zegg_info.finalize_optionsFcCsL|r||||n4tj|rH|dkr>|s>td||dS||dS)aWrite `data` to `filename` or delete if empty If `data` is non-empty, this routine is the same as ``write_file()``. If `data` is empty but not ``None``, this is the same as calling ``delete_file(filename)`. If `data` is ``None``, then this is a no-op unless `filename` exists, in which case a warning is issued about the orphaned file (if `force` is false), or deleted (if `force` is true). Nz$%s not set in setup(), but %s exists) write_filer!r"existsrwarn delete_file)r<whatr_dataforcer4r4r5write_or_delete_files   zegg_info.write_or_delete_filecCs>td|||d}|js:t|d}|||dS)zWrite `data` to `filename` (if not a dry run) after announcing it `what` is used in a log message to identify what is being written to the file. zwriting %s to %sutf-8wbN)rinfoencodedry_runopenwriteclose)r<r~r_rfr4r4r5rz s    zegg_info.write_filecCs td||jst|dS)z8Delete `filename` (if not a dry run) after announcing itz deleting %sN)rrrr!unlink)r<r_r4r4r5r}s zegg_info.delete_filecCs||jt|jd|jj}tdD]4}|j|d|}|||j tj |j|j q*tj |jd}tj |r| ||dS)Nzegg_info.writers) installerznative_libs.txt)mkpathrNr!utimer9Zfetch_build_eggrrequireresolver=r"rnr{r} find_sources)r<repwriternlr4r4r5runs     z egg_info.runcCs4tj|jd}t|j}||_||j|_dS)z"Generate SOURCES.txt manifest filez SOURCES.txtN) r!r"rnrNmanifest_makerr9manifestrfilelist)r<Zmanifest_filenamemmr4r4r5r-s  zegg_info.find_sourcescCsT|jd}|jtjkr&tj|j|}tj|rPtd||j |j |_ ||_ dS)NraaB------------------------------------------------------------------------------ Note: Your current .egg-info directory has a '-' in its name; this will not work correctly with "setup.py develop". Please rename %s to %s to correct this problem. ------------------------------------------------------------------------------) rVrUr!rlr"rnr{rr|rNrX)r<Zbeir4r4r5ro5s   zegg_info.check_broken_egg_infoN)F)rJrKrL description user_optionsboolean_options negative_optrYrMrZsetterr`ryrrzr}rrror4r4r4r5rNs.    1  rNc@s|eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZdS)rc Cs ||\}}}}|j|j|j|jt|j|t|j||j |j d}dddddddd d}z ||}Wn$t k rt d j |d YnX|d } |d kr|g}| r|fnd} ||} |d|g| r|gng||D]} || stj| | f| qdS)N)includeexcludezglobal-includezglobal-excludezrecursive-includezrecursive-excludegraftprunez%warning: no files found matching '%s'z9warning: no previously-included files found matching '%s'z>warning: no files found matching '%s' anywhere in distributionzRwarning: no previously-included files matching '%s' found anywhere in distributionz:warning: no files found matching '%s' under directory '%s'zNwarning: no previously-included files matching '%s' found under directory '%s'z+warning: no directories found matching '%s'z6no previously-included directories found matching '%s'z/this cannot happen: invalid action '{action!s}')actionz recursive->rrr4 )Z_parse_template_linerrglobal_includeglobal_exclude functoolspartialrecursive_includerecursive_excluderrKeyErrorrformat startswith debug_printrnrr|) r<linerpatternsdirZ dir_patternZ action_mapZlog_mapZprocess_actionZaction_is_recursiveZextra_log_argsZlog_tmplpatternr4r4r5process_template_lineHsd   zFileList.process_template_linecCsRd}tt|jdddD]2}||j|r|d|j||j|=d}q|S)z Remove all files from the file list that match the predicate. Return True if any matching files were removed Frz removing T)ranger'filesr)r< predicatefoundr0r4r4r5 _remove_filesszFileList._remove_filescCs$ddt|D}||t|S)z#Include files that match 'pattern'.cSsg|]}tj|s|qSr4r!r"isdir.0rr4r4r5 s z$FileList.include..rextendboolr<rrr4r4r5rs zFileList.includecCst|}||jS)z#Exclude files that match 'pattern'.)r6rmatchr<rrr4r4r5rszFileList.excludecCs8tj|d|}ddt|ddD}||t|S)zN Include all files anywhere in 'dir/' that match the pattern. rcSsg|]}tj|s|qSr4rrr4r4r5rs z.FileList.recursive_include..T) recursive)r!r"rnrrr)r<rrZ full_patternrr4r4r5rs zFileList.recursive_includecCs ttj|d|}||jS)zM Exclude any file anywhere in 'dir/' that match the pattern. rr6r!r"rnrr)r<rrrr4r4r5rszFileList.recursive_excludecCs$ddt|D}||t|S)zInclude all files from 'dir/'.cSs"g|]}tj|D]}|qqSr4)rgrfindall)rZ match_diritemr4r4r5rsz"FileList.graft..r)r<rrr4r4r5rs  zFileList.graftcCsttj|d}||jS)zFilter out files from 'dir/'.rr)r<rrr4r4r5rszFileList.prunecsJ|jdkr|ttjd|fdd|jD}||t|S)z Include all files anywhere in the current directory that match the pattern. This is very inefficient on large file trees. Nrcsg|]}|r|qSr4rrrr4r5rs z+FileList.global_include..)allfilesrr6r!r"rnrrrr4rr5rs   zFileList.global_includecCsttjd|}||jS)zD Exclude all files anywhere that match the pattern. rrrr4r4r5rszFileList.global_excludecCs8|dr|dd}t|}||r4|j|dS)N r)rBr _safe_pathrappend)r<rr"r4r4r5rs    zFileList.appendcCs|jt|j|dSr8)rrfilterr)r<pathsr4r4r5rszFileList.extendcCstt|j|j|_dS)z Replace self.files with only safe paths Because some owners of FileList manipulate the underlying ``files`` attribute directly, this method must be called to repair those paths. N)rerrrr;r4r4r5_repairszFileList._repairc Csd}t|}|dkr(td|dSt|d}|dkrNt||ddSz"tj|shtj|rnWdSWn&tk rt||t YnXdS)Nz!'%s' not %s encodable -- skippingz''%s' in unexpected encoding -- skippingFrT) unicode_utilsfilesys_decoderr|Z try_encoder!r"r{UnicodeEncodeErrorsysgetfilesystemencoding)r<r"Zenc_warnZu_pathZ utf8_pathr4r4r5rs   zFileList._safe_pathN)rJrKrLrrrrrrrrrrrrrrr4r4r4r5rEsM     rc@sdeZdZdZddZddZddZdd Zd d Zd d Z e ddZ ddZ ddZ ddZdS)rz MANIFEST.incCsd|_d|_d|_d|_dS)Nr)Z use_defaultsrZ manifest_onlyZforce_manifestr;r4r4r5rYsz!manifest_maker.initialize_optionscCsdSr8r4r;r4r4r5ryszmanifest_maker.finalize_optionscCslt|_tj|js||tj|jr<| | | |j |j |dSr8)rrr!r"r{rwrite_manifest add_defaultstemplateZ read_templateadd_license_filesprune_file_listsortZremove_duplicatesr;r4r4r5rs  zmanifest_maker.runcCst|}|tjdS)N/)rrreplacer!r#)r<r"r4r4r5_manifest_normalize&s z"manifest_maker._manifest_normalizecsBjfddjjD}dj}tj|f|dS)zo Write the file list in 'self.filelist' to the manifest file named by 'self.manifest'. csg|]}|qSr4)rrr;r4r5r2sz1manifest_maker.write_manifest..zwriting manifest file '%s'N)rrrrexecuterz)r<rmsgr4r;r5r*s  zmanifest_maker.write_manifestcCs||st||dSr8)_should_suppress_warningrr|)r<rr4r4r5r|6s zmanifest_maker.warncCs td|S)z; suppress missing-file warnings from sdist zstandard file .*not found)r$r)rr4r4r5r:sz'manifest_maker._should_suppress_warningcCst||j|j|j|jtt}|rB|j|nt j |jrX| t j drp|jd| d}|j|jdS)Nzsetup.pyrN)rrrrrrrerrr!r"r{Z read_manifestget_finalized_commandrrN)r<ZrcfilesZei_cmdr4r4r5rAs     zmanifest_maker.add_defaultscCs4|jjjp g}|D]}td|q|j|dS)Nzadding license file '%s')r9rp license_filesrrrr)r<rlfr4r4r5rSs  z manifest_maker.add_license_filescCsZ|d}|j}|j|j|j|ttj }|jj d|d|dddS)Nbuildz(^|z)(RCS|CVS|\.svn)r)Zis_regex) rr9 get_fullnamerr build_baser$r%r!r#Zexclude_pattern)r<rbase_dirr#r4r4r5rZs    zmanifest_maker.prune_file_listN)rJrKrLrrYryrrrr| staticmethodrrrrr4r4r4r5r s   rc Cs8d|}|d}t|d}||W5QRXdS)z{Create a file with the specified name and write 'contents' (a sequence of strings without line terminators) to it.  rrN)rnrrr)r_contentsrr4r4r5rzds   rzc Cs|td||jsx|jj}|j|j|_}|j|j|_}z| |j W5|||_|_Xt |jdd}t |j |dS)Nz writing %sZzip_safe)rrrr9rprWrDrVr=write_pkg_inforNgetattrr Zwrite_safety_flag)cmdbasenamer_rpZoldverZoldnamesafer4r4r5rqs rcCstj|rtddS)NzsWARNING: 'depends.txt' is not used by setuptools 0.6! Use the install_requires/extras_require setup() args instead.)r!r"r{rr|rrr_r4r4r5warn_depends_obsoletes rcCs,t|pd}dd}t||}||dS)Nr4cSs|dS)Nrr4)rr4r4r5 append_crsz&_write_requirements..append_cr)rmap writelines)streamreqslinesrr4r4r5_write_requirementss  rcCsj|j}t}t||j|jp"i}t|D]&}|djft t|||q,| d|| dS)Nz [{extra}] requirements) r9ioStringIOrZinstall_requiresextras_requiresortedrrvarsrgetvalue)rrr_distrrextrar4r4r5write_requirementss   rcCs,t}t||jj|d||dS)Nzsetup-requirements)rrrr9Zsetup_requiresrr)rrr_rr4r4r5write_setup_requirementssrcCs:tdd|jD}|d|dt|ddS)NcSsg|]}|dddqS).rr)r )rkr4r4r5rsz(write_toplevel_names..ztop-level namesr)r^fromkeysr9Ziter_distribution_namesrzrnr)rrr_pkgsr4r4r5write_toplevel_namess r cCst|||ddS)NT) write_argrr4r4r5 overwrite_argsr FcCsHtj|d}t|j|d}|dk r4d|d}|||||dS)Nrr)r!r"splitextrr9rnr)rrr_rargnamer[r4r4r5r s r cCs|jj}t|ts|dkr |}nl|dk rg}t|D]H\}}t|tsnt||}dtt t| }| d||fq8d|}| d||ddS)Nrz [%s] %s rz entry pointsT) r9 entry_pointsrcstrritemsr parse_grouprnrvaluesrr)rrr_rrsectionrr4r4r5 write_entriess   rc Csjtdttjdrftd>}|D]2}t d|}|r(t | dW5QRSq(W5QRXdS)zd Get a -r### off of PKG-INFO Version in case this is an sdist of a subversion revision. z$get_pkg_info_revision is deprecated.zPKG-INFOzVersion:.*-r(\d+)\s*$rr) warningsr|EggInfoDeprecationWarningr!r"r{rrr$rintgroup)rrrr4r4r5get_pkg_info_revisions   *rc@seZdZdZdS)rz?Deprecated behavior warning for EggInfo, bypassing suppression.N)rJrKrL__doc__r4r4r4r5rsr)F);rdistutils.filelistrZ _FileListdistutils.errorsrdistutils.utilrrgrrr!r$rrrrGr\ setuptoolsrZsetuptools.command.sdistrrZsetuptools.command.setoptr Zsetuptools.commandr pkg_resourcesr r r rrrrrZsetuptools.unicode_utilsrZsetuptools.globrZsetuptools.externrrr6r7rNrrzrrrrrr r r rrrr4r4r4r5sV         (    S1IW