3 ef@sdZddlmZddlmZddlmZddlm Z ddlZddlZddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlmZddlmZdd lmZdd lmZdd lmZdd lmZmZmZmZm Z m!Z!m"Z"m#Z#ddl$j%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}|jtjj}tjtj}d|f}xt|D]\}}|t|dk}|dkrv|rd|d7}q4|d||f7}q4d}t|} x:|| kr||} | dkr||d7}n| d kr||7}n| d kr|d} | | kr|| d kr| d} | | kr|| d kr| d} x&| | kr6|| d kr6| d} qW| | krR|tj| 7}nR||d| } d} | dd krd } | dd} | tj| 7} |d| f7}| }n|tj| 7}|d7}qW|s4||7}q4W|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.*z (?:%s+%s)*r*?[!]^Nz[%s]z\Z)flags) splitospathsepreescape enumeratelencompile MULTILINEDOTALL)rpatchunksr"Z valid_charcchunk last_chunkiZ chunk_lencharZinner_iinner char_classr3A/tmp/pip-build-vlmub77e/setuptools/setuptools/command/egg_info.pytranslate_pattern#sV         r5c@s@eZdZdZdZeddZddZddZdd Z ee Z dS) InfoCommonNcCst|jjS)N)r distributionget_name)selfr3r3r4namezszInfoCommon.namecCst|j|jjS)N)r _maybe_tagr7 get_version)r9r3r3r4tagged_version~szInfoCommon.tagged_versioncCs |jr|j|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. )vtagsendswith)r9versionr3r3r4r;szInfoCommon._maybe_tagcCs,d}|jr||j7}|jr(|tjd7}|S)Nrz-%Y%m%d) tag_buildtag_datetimestrftime)r9r@r3r3r4tagss  zInfoCommon.tags) __name__ __module__ __qualname__rArBpropertyr:r=r;rEr>r3r3r3r4r6vs  r6c@seZdZdZd%d&d'd(gZdgZd diZddZeddZ e j ddZ ddZ ddZ d)ddZ ddZddZddZd d!Zd"d#Zd$S)*egg_infoz+create a distribution's .egg-info directory egg-base=eLdirectory containing .egg-info directories (default: top of the source tree)tag-dated0Add date stamp (e.g. 20050528) to version number tag-build=b-Specify explicit tag to add to version numberno-dateD"Don't include date stamp [default]cCs"d|_d|_d|_d|_d|_dS)NF)egg_baseegg_namerJ egg_versionbroken_egg_info)r9r3r3r4initialize_optionss zegg_info.initialize_optionscCsdS)Nr3)r9r3r3r4tag_svn_revisionszegg_info.tag_svn_revisioncCsdS)Nr3)r9valuer3r3r4r\scCs0tj}|j|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. rArrB)rJN) collections OrderedDictrEr dict)r9filenamerJr3r3r4save_version_infos zegg_info.save_version_infocCsT|j|_|j|_t|j}y6t|tjj}|r4dnd}t t ||j|jfWn<t k r}z t j jd|j|jf|WYdd}~XnX|jdkr|jj}|pijdtj|_|jdt|jd|_|jtjkrtjj|j|j|_d|jkr|j|j|jj_|jj}|dk rP|j|jjkrP|j|_t|j|_ d|j_dS)Nz%s==%sz%s===%sz2Invalid distribution name or version syntax: %s-%srrWz .egg-info-)!r:rXr=rYr isinstancerr@Versionlistr ValueError distutilserrorsDistutilsOptionErrorrWr7 package_dirgetr curdirensure_dirnamerrJr!joincheck_broken_egg_infometadataZ _patched_distkeylower_version_parsed_version)r9parsed_versionZ is_versionspecrLdirspdr3r3r4finalize_optionss8         zegg_info.finalize_optionsFcCsN|r|j|||n6tjj|rJ|dkr@| r@tjd||dS|j|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)r9whatradataforcer3r3r4write_or_delete_files   zegg_info.write_or_delete_filecCs>tjd|||jd}|js:t|d}|j||jdS)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 %szutf-8wbN)rinfoencodedry_runopenwriteclose)r9rrarfr3r3r4r{ s    zegg_info.write_filecCs tjd||jstj|dS)z8Delete `filename` (if not a dry run) after announcing itz deleting %sN)rrrr unlink)r9rar3r3r4r~s zegg_info.delete_filecCs|j|jtj|jd|jj}x@tdD]4}|j|d|j}|||j tj j |j|j q,Wtj j |jd}tj j |r|j ||jdS)Nzegg_info.writers) installerznative_libs.txt)mkpathrJr utimer7Zfetch_build_eggrrequireresolver:r!ror|r~ find_sources)r9repwriternlr3r3r4runs     z egg_info.runcCs4tjj|jd}t|j}||_|j|j|_dS)z"Generate SOURCES.txt manifest filez SOURCES.txtN) r r!rorJmanifest_makerr7manifestrfilelist)r9Zmanifest_filenamemmr3r3r4r-s  zegg_info.find_sourcescCsd|jd}|jtjkr&tjj|j|}tjj|r`tjddddd||j |j |_ ||_ dS)Nz .egg-inforcNz 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. ) rXrWr rmr!ror|rr}rJrZ)r9Zbeir3r3r4rp5s    zegg_info.check_broken_egg_infoN)rKrLrM)rNrOrP)rQrRrS)rTrUrV)F)rFrGrH description user_optionsboolean_options negative_optr[rIr\setterrbrzrr{r~rrrpr3r3r3r4rJs$  1  rJc@s|eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZdS)rc Cs|j|\}}}}|j|j|j|jtj|j|tj|j||j |j d}dddddddd d}y ||}Wn$t k rt d j |d YnX|jd } |dkr|g}| r|fnf} ||} |jdj|g| r|gng|x&|D]} || stj| | f| qWdS)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-rr >rr)Z_parse_template_linerrglobal_includeglobal_exclude functoolspartialrecursive_includerecursive_excluderrKeyErrorrformat startswith debug_printrorr}) r9linerpatternsdirZ dir_patternZ action_mapZlog_mapZprocess_actionZaction_is_recursiveZextra_log_argsZlog_tmplpatternr3r3r4process_template_lineHsJ     zFileList.process_template_linecCsVd}xLtt|jdddD]2}||j|r|jd|j||j|=d}qW|S)z Remove all files from the file list that match the predicate. Return True if any matching files were removed Frz removing Tr)ranger&filesr)r9 predicatefoundr/r3r3r4 _remove_filesszFileList._remove_filescCs$ddt|D}|j|t|S)z#Include files that match 'pattern'.cSsg|]}tjj|s|qSr3)r r!isdir).0rr3r3r4 sz$FileList.include..)rextendbool)r9rrr3r3r4rs zFileList.includecCst|}|j|jS)z#Exclude files that match 'pattern'.)r5rmatch)r9rrr3r3r4rszFileList.excludecCs8tjj|d|}ddt|ddD}|j|t|S)zN Include all files anywhere in 'dir/' that match the pattern. z**cSsg|]}tjj|s|qSr3)r r!r)rrr3r3r4rsz.FileList.recursive_include..T) recursive)r r!rorrr)r9rrZ full_patternrr3r3r4rs zFileList.recursive_includecCs ttjj|d|}|j|jS)zM Exclude any file anywhere in 'dir/' that match the pattern. z**)r5r r!rorr)r9rrrr3r3r4rszFileList.recursive_excludecCs$ddt|D}|j|t|S)zInclude all files from 'dir/'.cSs"g|]}tjj|D]}|qqSr3)rhrfindall)rZ match_diritemr3r3r4rsz"FileList.graft..)rrr)r9rrr3r3r4rs  zFileList.graftcCsttjj|d}|j|jS)zFilter out files from 'dir/'.z**)r5r r!rorr)r9rrr3r3r4rszFileList.prunecsJ|jdkr|jttjjd|fdd|jD}|j|t|S)z Include all files anywhere in the current directory that match the pattern. This is very inefficient on large file trees. Nz**csg|]}j|r|qSr3)r)rr)rr3r4rsz+FileList.global_include..)allfilesrr5r r!rorr)r9rrr3)rr4rs   zFileList.global_includecCsttjjd|}|j|jS)zD Exclude all files anywhere that match the pattern. z**)r5r r!rorr)r9rrr3r3r4rszFileList.global_excludecCs8|jdr|dd}t|}|j|r4|jj|dS)N rr)r?r _safe_pathrappend)r9rr!r3r3r4rs    zFileList.appendcCs|jjt|j|dS)N)rrfilterr)r9pathsr3r3r4rszFileList.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)rfrrr)r9r3r3r4_repairszFileList._repairc Csd}tj|}|dkr(tjd|dStj|d}|dkrNtj||ddSy tjj|shtjj|rldSWn&tk rtj||t j YnXdS)Nz!'%s' not %s encodable -- skippingz''%s' in unexpected encoding -- skippingFzutf-8T) unicode_utilsfilesys_decoderr}Z try_encoder r!r|UnicodeEncodeErrorsysgetfilesystemencoding)r9r!Zenc_warnZu_pathZ utf8_pathr3r3r4rs  zFileList._safe_pathN)rFrGrHrrrrrrrrrrrrrrr3r3r3r4rEsM     rc@sleZdZdZddZddZddZdd Zd d Zd d Z e ddZ ddZ ddZ ddZddZdS)rz MANIFEST.incCsd|_d|_d|_d|_dS)Nr)Z use_defaultsrZ manifest_onlyZforce_manifest)r9r3r3r4r[sz!manifest_maker.initialize_optionscCsdS)Nr3)r9r3r3r4rzszmanifest_maker.finalize_optionscCslt|_tjj|js|j|jtjj|jr<|j |j |j |jj |jj |jdS)N)rrr r!r|rwrite_manifest add_defaultstemplateZ read_templateadd_license_filesprune_file_listsortZremove_duplicates)r9r3r3r4rs  zmanifest_maker.runcCstj|}|jtjdS)N/)rrreplacer r")r9r!r3r3r4_manifest_normalize&s z"manifest_maker._manifest_normalizecsBjjfddjjD}dj}jtj|f|dS)zo Write the file list in 'self.filelist' to the manifest file named by 'self.manifest'. csg|]}j|qSr3)r)rr)r9r3r4r2sz1manifest_maker.write_manifest..zwriting manifest file '%s'N)rrrrexecuter{)r9rmsgr3)r9r4r*s  zmanifest_maker.write_manifestcCs|j|stj||dS)N)_should_suppress_warningrr})r9rr3r3r4r}6s zmanifest_maker.warncCs tjd|S)z; suppress missing-file warnings from sdist zstandard file .*not found)r#r)rr3r3r4r:sz'manifest_maker._should_suppress_warningcCstj||jj|j|jj|jtt}|rB|jj|nt j j |jrX|j t j j drp|jjd|j d}|jj|jdS)Nzsetup.pyrJ)rrrrrrrfrrr r!r|Z read_manifestget_finalized_commandrrJ)r9ZrcfilesZei_cmdr3r3r4rAs     zmanifest_maker.add_defaultscCs8|jjjp g}x|D]}tjd|qW|jj|dS)Nzadding license file '%s')r7rq license_filesrrrr)r9rlfr3r3r4rSs   z manifest_maker.add_license_filescCsZ|jd}|jj}|jj|j|jj|tjtj }|jj d|d|dddS)Nbuildz(^|z)(RCS|CVS|\.svn)r)Zis_regex) rr7 get_fullnamerr build_baser#r$r r"Zexclude_pattern)r9rbase_dirr"r3r3r4rZs    zmanifest_maker.prune_file_listcCs&t|dr|jStjdt|jS)a0 The parent class implementation of this method (``sdist``) will try to include data files, which might cause recursion problems when ``include_package_data=True``. Therefore, avoid triggering any attempt of analyzing/building the manifest again. get_data_files_without_manifestzCustom 'build_py' does not implement 'get_data_files_without_manifest'. Please extend command classes from setuptools instead of distutils.)hasattrrwarningsr}rZget_data_files)r9build_pyr3r3r4_safe_data_filescs zmanifest_maker._safe_data_filesN)rFrGrHrr[rzrrrr} staticmethodrrrrrr3r3r3r4r s    rc Cs8dj|}|jd}t|d}|j|WdQRXdS)z{Create a file with the specified name and write 'contents' (a sequence of strings without line terminators) to it.  zutf-8rN)rorrr)racontentsrr3r3r4r{ys   r{c Cs|tjd||jsx|jj}|j|j|_}|j|j|_}z|j |j Wd|||_|_Xt |jdd}t j |j |dS)Nz writing %sZzip_safe)rrrr7rqrYr@rXr:write_pkg_inforJgetattrr Zwrite_safety_flag)cmdbasenamerarqZoldverZoldnamesafer3r3r4rs rcCstjj|rtjddS)NzsWARNING: 'depends.txt' is not used by setuptools 0.6! Use the install_requires/extras_require setup() args instead.)r r!r|rr})rrrar3r3r4warn_depends_obsoletes rcCs,t|pf}dd}t||}|j|dS)NcSs|dS)Nrr3)rr3r3r4 append_crsz&_write_requirements..append_cr)rmap writelines)streamreqslinesrr3r3r4_write_requirementss  rcCsn|j}tj}t||j|jp"i}x2t|D]&}|jdjft t|||q.W|j d||j dS)Nz [{extra}] requirements) r7ioStringIOrZinstall_requiresextras_requiresortedrrvarsrgetvalue)rrradistrrextrar3r3r4write_requirementss  rcCs,tj}t||jj|jd||jdS)Nzsetup-requirements)rrrr7Zsetup_requiresrr)rrrarr3r3r4write_setup_requirementssrcCs:tjdd|jjD}|jd|djt|ddS)NcSsg|]}|jdddqS).rr)r)rkr3r3r4rsz(write_toplevel_names..ztop-level namesr)r`fromkeysr7Ziter_distribution_namesr{ror)rrrapkgsr3r3r4write_toplevel_namessrcCst|||ddS)NT) write_arg)rrrar3r3r4 overwrite_argsr FcCsHtjj|d}t|j|d}|dk r4dj|d}|j||||dS)Nrr)r r!splitextrr7ror)rrrarZargnamer]r3r3r4rs rcCs|jj}t|ts|dkr |}np|dk rg}xXt|jD]H\}}t|tsptj||}djtt t|j }|j d||fq:Wdj|}|j d||ddS)Nrz [%s] %s rz entry pointsT) r7 entry_pointsrdstrritemsr parse_grouprorvaluesrr)rrrarrsectionrr3r3r4 write_entriess   rc Cs^tjdttjjdrZtjd2}x*|D]"}tj d|}|r*t |j dSq*WWdQRXdS)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*$rNr) rr}EggInfoDeprecationWarningr r!r|rrr#rintgroup)rrrr3r3r4get_pkg_info_revisions    rc@seZdZdZdS)rz?Deprecated behavior warning for EggInfo, bypassing suppression.N)rFrGrH__doc__r3r3r3r4rsr)F);rdistutils.filelistrZ _FileListZdistutils.errorsrdistutils.utilrrhrrr r#rrrrCr^ setuptoolsrZsetuptools.command.sdistrrZsetuptools.command.setoptr Zsetuptools.commandr pkg_resourcesr r r rrrrrZsetuptools.unicode_utilsrZsetuptools.globrZsetuptools.externrrr5r6rJrr{rrrrrrr rrrrr3r3r3r4sV         (    S1Il