3 ]`@sdZddlmZddlmZddlmZddlm Z ddlZddlZddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&ddl'j(Z(ddl)m*Z*ddlm+Z+ddZ,GdddeZ-GdddeZGdddeZ.ddZ/ddZ0ddZ1dd Z2d!d"Z3d#d$Z4d%d&Z5d'd(Z6d0d*d+Z7d,d-Z8d.d/Z9dS)1zUsetuptools.command.egg_info Create a distribution's .egg-info directory and contents)FileList)DistutilsInternalError) convert_path)logN)six)map)Command)sdist) walk_revctrl) edit_config) bdist_egg)parse_requirements safe_name parse_version safe_version yield_lines EntryPointiter_entry_points to_filename)glob) packagingcCsd}|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_classr4A/tmp/pip-build-8jg9gmni/setuptools/setuptools/command/egg_info.pytranslate_pattern$sV         r6c@seZdZdZd)d*d+d,gZdgZd diZddZeddZ e j ddZ ddZ ddZ d-ddZ ddZddZddZd d!Zd"d#Zd$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]cCs4d|_d|_d|_d|_d|_d|_d|_d|_dS)NrF)egg_name egg_versionegg_baser7 tag_buildtag_datebroken_egg_infovtags)selfr4r4r5initialize_optionsszegg_info.initialize_optionscCsdS)Nr4)rKr4r4r5tag_svn_revisionszegg_info.tag_svn_revisioncCsdS)Nr4)rKvaluer4r4r5rMscCs0tj}|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. rGrrH)r7N) collections OrderedDicttagsr dict)rKfilenamer7r4r4r5save_version_infos zegg_info.save_version_infoc CsVt|jj|_|j|_|j|_t|j}y6t |t j j }|rFdnd}t t||j|jfWn,tk rtjjd|j|jfYnX|jdkr|jj}|pijdtj|_|jdt|jd|_|jtjkrtjj|j|j|_d|jkr|j|j|jj_ |jj}|dk rR|j |jj!krR|j|_"t|j|_#d|j_dS)Nz%s==%sz%s===%sz2Invalid distribution name or version syntax: %s-%srrFz .egg-info-)$r distributionget_namerDrQrJtagged_versionrEr isinstancerversionVersionlistr ValueError distutilserrorsDistutilsOptionErrorrF package_dirgetr!curdirensure_dirnamerr7r"joincheck_broken_egg_infometadataZ _patched_distkeylower_version_parsed_version)rKparsed_versionZ is_versionspecdirspdr4r4r5finalize_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)rKwhatrSdataforcer4r4r5write_or_delete_files   zegg_info.write_or_delete_filecCsDtjd||tjr|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) rinforPY3encodedry_runopenwriteclose)rKrurSrvfr4r4r5rqs   zegg_info.write_filecCs tjd||jstj|dS)z8Delete `filename` (if not a dry run) after announcing itz deleting %sN)rrzr}r!unlink)rKrSr4r4r5rts zegg_info.delete_filecCs2|jj}|jr$|j|jr$t|St||jS)N)rV get_versionrJendswithr)rKrZr4r4r5rXs zegg_info.tagged_versioncCs|j|j|jj}x@tdD]4}|j|d|j}|||jtj j |j|jqWtj j |jd}tj j |r||j ||j dS)Nzegg_info.writers) installerznative_libs.txt)mkpathr7rVZfetch_build_eggrrequireresolvenamer!r"rerrrt find_sources)rKrepwriternlr4r4r5run s     z egg_info.runcCs,d}|jr||j7}|jr(|tjd7}|S)Nrz-%Y%m%d)rGrHtimestrftime)rKrZr4r4r5rQs  z egg_info.tagscCs4tjj|jd}t|j}||_|j|j|_dS)z"Generate SOURCES.txt manifest filez SOURCES.txtN) r!r"rer7manifest_makerrVmanifestrfilelist)rKZmanifest_filenamemmr4r4r5r s  zegg_info.find_sourcescCsd|jd}|jtjkr&tjj|j|}tjj|r`tjddddd||j |j |_ ||_ dS)Nz .egg-inforUNz 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. ) rDrFr!rcr"rerrrrsr7rI)rKZbeir4r4r5rf(s    zegg_info.check_broken_egg_infoN)r8r9r:)r;r<r=)r>r?r@)rArBrC)F)__name__ __module__ __qualname__ description user_optionsboolean_options negative_optrLpropertyrMsetterrTrprxrqrtrXrrQrrfr4r4r4r5r7ws(  / r7c@s|eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZdS)rcCs<|j|\}}}}|dkrV|jddj|x"|D]}|j|s4tjd|q4Wn|dkr|jddj|x"|D]}|j|sxtjd|qxWn|dkr|jd dj|x"|D]}|j|stjd |qWnZ|d kr(|jd dj|x&|D]}|j|stjd |qWn|dkrx|jd|dj|fx|D]"}|j ||sPtjd||qPWn|dkr|jd|dj|fx|D]"}|j ||stjd||qWnp|dkr|jd||j |s8tjd|n>|dkr,|jd||j |s8tjd|n t d|dS)Nincludezinclude  z%warning: no files found matching '%s'excludezexclude z9warning: no previously-included files found matching '%s'zglobal-includezglobal-include z>warning: no files found matching '%s' anywhere in distributionzglobal-excludezglobal-exclude zRwarning: no previously-included files matching '%s' found anywhere in distributionzrecursive-includezrecursive-include %s %sz:warning: no files found matching '%s' under directory '%s'zrecursive-excludezrecursive-exclude %s %szNwarning: no previously-included files matching '%s' found under directory '%s'graftzgraft z+warning: no directories found matching '%s'prunezprune z6no previously-included directories found matching '%s'z'this cannot happen: invalid action '%s')Z_parse_template_line debug_printrerrrsrglobal_includeglobal_excluderecursive_includerecursive_excluderrr)rKlineactionpatternsdirZ dir_patternpatternr4r4r5process_template_line;sd                 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)rK predicatefoundr0r4r4r5 _remove_filesszFileList._remove_filescCs$ddt|D}|j|t|S)z#Include files that match 'pattern'.cSsg|]}tjj|s|qSr4)r!r"isdir).0rr4r4r5 sz$FileList.include..)rextendbool)rKrrr4r4r5rs zFileList.includecCst|}|j|jS)z#Exclude files that match 'pattern'.)r6rmatch)rKrrr4r4r5rszFileList.excludecCs8tjj|d|}ddt|ddD}|j|t|S)zN Include all files anywhere in 'dir/' that match the pattern. z**cSsg|]}tjj|s|qSr4)r!r"r)rrr4r4r5rsz.FileList.recursive_include..T) recursive)r!r"rerrr)rKrrZ full_patternrr4r4r5rs zFileList.recursive_includecCs ttjj|d|}|j|jS)zM Exclude any file anywhere in 'dir/' that match the pattern. z**)r6r!r"rerr)rKrrrr4r4r5rszFileList.recursive_excludecCs$ddt|D}|j|t|S)zInclude all files from 'dir/'.cSs"g|]}tjj|D]}|qqSr4)r^rfindall)rZ match_diritemr4r4r5rsz"FileList.graft..)rrr)rKrrr4r4r5rs  zFileList.graftcCsttjj|d}|j|jS)zFilter out files from 'dir/'.z**)r6r!r"rerr)rKrrr4r4r5rszFileList.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|qSr4)r)rr)rr4r5rsz+FileList.global_include..)allfilesrr6r!r"rerr)rKrrr4)rr5rs   zFileList.global_includecCsttjjd|}|j|jS)zD Exclude all files anywhere that match the pattern. z**)r6r!r"rerr)rKrrr4r4r5rszFileList.global_excludecCs8|jdr|dd}t|}|j|r4|jj|dS)N rr)rr _safe_pathrappend)rKrr"r4r4r5rs    zFileList.appendcCs|jjt|j|dS)N)rrfilterr)rKpathsr4r4r5rszFileList.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)r\rrr)rKr4r4r5_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_decoderrsZ try_encoder!r"rrUnicodeEncodeErrorsysgetfilesystemencoding)rKr"Zenc_warnZu_pathZ utf8_pathr4r4r5rs  zFileList._safe_pathN)rrrrrrrrrrrrrrrrrr4r4r4r5r8sI     rc@s\eZdZdZddZddZddZdd Zd d Zd d Z e ddZ ddZ ddZ dS)rz MANIFEST.incCsd|_d|_d|_d|_dS)Nr)Z use_defaultsrZ manifest_onlyZforce_manifest)rKr4r4r5rLsz!manifest_maker.initialize_optionscCsdS)Nr4)rKr4r4r5rpszmanifest_maker.finalize_optionscCsdt|_tjj|js|j|jtjj|jr<|j |j |jj |jj |jdS)N) rrr!r"rrrwrite_manifest add_defaultstemplateZ read_templateprune_file_listsortZremove_duplicates)rKr4r4r5rs  zmanifest_maker.runcCstj|}|jtjdS)N/)rrreplacer!r#)rKr"r4r4r5_manifest_normalizes 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|qSr4)r)rr)rKr4r5r sz1manifest_maker.write_manifest..zwriting manifest file '%s'N)rrrrexecuterq)rKrmsgr4)rKr5rs  zmanifest_maker.write_manifestcCs|j|stj||dS)N)_should_suppress_warningr rs)rKrr4r4r5rs$s zmanifest_maker.warncCs tjd|S)z; suppress missing-file warnings from sdist zstandard file .*not found)r$r)rr4r4r5r(sz'manifest_maker._should_suppress_warningcCsttj||jj|j|jj|jtt}|rB|jj|nt j j |jrX|j |j d}|jj|jdS)Nr7)r rrrrrr\r rr!r"rrZ read_manifestget_finalized_commandrr7)rKZrcfilesZei_cmdr4r4r5r/s   zmanifest_maker.add_defaultscCsZ|jd}|jj}|jj|j|jj|tjtj }|jj d|d|dddS)Nbuildz(^|z)(RCS|CVS|\.svn)r)Zis_regex) rrV get_fullnamerr build_baser$r%r!r#Zexclude_pattern)rKrbase_dirr#r4r4r5r;s    zmanifest_maker.prune_file_listN)rrrrrLrprrrrs staticmethodrrrr4r4r4r5rs    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-8ryN)rer|r~r)rScontentsrr4r4r5rqEs   rqc Cs|tjd||jsx|jj}|j|j|_}|j|j|_}z|j |j Wd|||_|_Xt |jdd}t j |j |dS)Nz writing %sZzip_safe)rrzr}rVrgrErZrDrwrite_pkg_infor7getattrr Zwrite_safety_flag)cmdbasenamerSrgZoldverZoldnamesafer4r4r5rRs rcCstjj|rtjddS)NzsWARNING: 'depends.txt' is not used by setuptools 0.6! Use the install_requires/extras_require setup() args instead.)r!r"rrrrs)rrrSr4r4r5warn_depends_obsoletees rcCs0t|pf}dd}t|t|}|j|dS)NcSs|dS)Nrr4)rr4r4r5osz%_write_requirements..)rrsorted writelines)streamreqslinesZ append_crr4r4r5_write_requirementsms rcCsn|j}tj}t||j|jp"i}x2t|D]&}|jdjft t|||q.W|j d||j dS)Nz [{extra}] requirements) rVrStringIOrZinstall_requiresextras_requirerrformatvarsrxgetvalue)rrrSdistrvrextrar4r4r5write_requirementsts  rcCs,tj}t||jj|jd||jdS)Nzsetup-requirements)iorrrVZsetup_requiresrxr)rrrSrvr4r4r5write_setup_requirementssrcCs:tjdd|jjD}|jd|djt|ddS)NcSsg|]}|jdddqS).rr)r )rkr4r4r5rsz(write_toplevel_names..ztop-level namesr)rRfromkeysrVZiter_distribution_namesrqrer)rrrSpkgsr4r4r5write_toplevel_namessrcCst|||ddS)NT) write_arg)rrrSr4r4r5 overwrite_argsrFcCsHtjj|d}t|j|d}|dk r4dj|d}|j||||dS)Nrr)r!r"splitextrrVrerx)rrrSrwZargnamerNr4r4r5rs rcCs|jj}t|tjs|dkr"|}nr|dk rg}xZt|jD]J\}}t|tjsttj||}dj tt t |j }|j d||fqsR           (   SBEI