3 M(Ya@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*ddl+m,Z,ddZ-GdddeZ.GdddeZGdddeZ/ddZ0ddZ1ddZ2dd Z3d!d"Z4d#d$Z5d%d&Z6d'd(Z7d0d*d+Z8d,d-Z9d.d/Z:dS)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_iinnerZ char_classr3I/private/tmp/pip-build-nl73fm5q/setuptools/setuptools/command/egg_info.pytranslate_pattern$sV         r5c@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_baser6 tag_buildtag_datebroken_egg_infovtags)selfr3r3r4initialize_optionsszegg_info.initialize_optionscCsdS)Nr3)rJr3r3r4tag_svn_revisionszegg_info.tag_svn_revisioncCsdS)Nr3)rJvaluer3r3r4rLscCs:ttdt}|}|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. OrderedDictrFrrG)r6N)getattr collectionsdicttagsr )rJfilenameZodictr6r3r3r4save_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-%srrEz .egg-info-)$r distributionget_namerCrRrItagged_versionrDr isinstancerversionVersionlistr ValueError distutilserrorsDistutilsOptionErrorrE package_dirgetr!curdirensure_dirnamerr6r"joincheck_broken_egg_infometadataZ _patched_distkeylower_version_parsed_version)rJparsed_versionZ is_versionspecdirspdr3r3r4finalize_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)rJwhatrSdataforcer3r3r4write_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)rJrurSrvfr3r3r4rqs   zegg_info.write_filecCs tjd||jstj|dS)z8Delete `filename` (if not a dry run) after announcing itz deleting %sN)rrzr}r!unlink)rJrSr3r3r4rts zegg_info.delete_filecCs2|jj}|jr$|j|jr$t|St||jS)N)rV get_versionrIendswithr)rJrZr3r3r4rXs 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)mkpathr6rVZfetch_build_eggrrequireresolvenamer!r"rerrrt find_sources)rJrepwriternlr3r3r4run s     z egg_info.runcCs,d}|jr||j7}|jr(|tjd7}|S)Nrz-%Y%m%d)rFrGtimestrftime)rJrZr3r3r4rRs  z egg_info.tagscCs4tjj|jd}t|j}||_|j|j|_dS)z"Generate SOURCES.txt manifest filez SOURCES.txtN) r!r"rer6manifest_makerrVmanifestrfilelist)rJZmanifest_filenamemmr3r3r4r"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. ) rCrEr!rcr"rerrrrsr6rH)rJZbeir3r3r4rf*s    zegg_info.check_broken_egg_infoN)r7r8r9)r:r;r<)r=r>r?)r@rArB)F)__name__ __module__ __qualname__ description user_optionsboolean_options negative_optrKpropertyrLsetterrTrprxrqrtrXrrRrrfr3r3r3r4r6ws( / r6c@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)rJlineactionpatternsdirZ dir_patternpatternr3r3r4process_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)rJ predicatefoundr0r3r3r4 _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)rJrrr3r3r4rs zFileList.includecCst|}|j|jS)z#Exclude files that match 'pattern'.)r5rmatch)rJrrr3r3r4rszFileList.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"rerrr)rJrrZ full_patternrr3r3r4rs zFileList.recursive_includecCs ttjj|d|}|j|jS)zM Exclude any file anywhere in 'dir/' that match the pattern. z**)r5r!r"rerr)rJrrrr3r3r4rszFileList.recursive_excludecCs$ddt|D}|j|t|S)zInclude all files from 'dir/'.cSs"g|]}tjj|D]}|qqSr3)r^rfindall)rZ match_diritemr3r3r4rsz"FileList.graft..)rrr)rJrrr3r3r4rs  zFileList.graftcCsttjj|d}|j|jS)zFilter out files from 'dir/'.z**)r5r!r"rerr)rJrrr3r3r4rszFileList.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"rerr)rJrrr3)rr4rs   zFileList.global_includecCsttjjd|}|j|jS)zD Exclude all files anywhere that match the pattern. z**)r5r!r"rerr)rJrrr3r3r4rszFileList.global_excludecCs8|jdr|dd}t|}|j|r4|jj|dS)N rr)rr _safe_pathrappend)rJrr"r3r3r4rs    zFileList.appendcCs|jjt|j|dS)N)rrfilterr)rJpathsr3r3r4rszFileList.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)rJr3r3r4_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)rJr"Zenc_warnZu_pathZ utf8_pathr3r3r4rs  zFileList._safe_pathN)rrrrrrrrrrrrrrrrrr3r3r3r4r:sI     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)rJr3r3r4rKsz!manifest_maker.initialize_optionscCsdS)Nr3)rJr3r3r4rpszmanifest_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)rJr3r3r4r s  zmanifest_maker.runcCstj|}|jtjdS)N/)rrreplacer!r#)rJr"r3r3r4_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|qSr3)r)rr)rJr3r4r"sz1manifest_maker.write_manifest..zwriting manifest file '%s'N)rrrrexecuterq)rJrmsgr3)rJr4rs  zmanifest_maker.write_manifestcCs|j|stj||dS)N)_should_suppress_warningr rs)rJrr3r3r4rs&s zmanifest_maker.warncCs tjd|S)z; suppress missing-file warnings from sdist zstandard file .*not found)r$r)rr3r3r4r*sz'manifest_maker._should_suppress_warningcCsttj||jj|j|jj|jtt}|rB|jj|nt j j |jrX|j |j d}|jj|jdS)Nr6)r rrrrrr\r rr!r"rrZ read_manifestget_finalized_commandrr6)rJZrcfilesZei_cmdr3r3r4r1s   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)rJrbase_dirr#r3r3r4r=s    zmanifest_maker.prune_file_listN)rrrrrKrprrrrs staticmethodrrrr3r3r3r4rs    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)rScontentsrr3r3r4rqGs   rqc Cstjd||js|jj}|j|j|_}|j|j|_}t |jd|_ z|j |j Wd|||_|_Xt |jdd}t j|j |dS)Nz writing %slong_description_content_typeZzip_safe)rrzr}rVrgrDrZrCrrOrwrite_pkg_infor6r Zwrite_safety_flag)cmdbasenamerSrgZoldverZoldnamesafer3r3r4rTs rcCstjj|rtjddS)NzsWARNING: 'depends.txt' is not used by setuptools 0.6! Use the install_requires/extras_require setup() args instead.)r!r"rrrrs)rrrSr3r3r4warn_depends_obsoletejs rcCs,t|pf}dd}t||}|j|dS)NcSs|dS)Nrr3)rr3r3r4tsz%_write_requirements..)rr writelines)streamreqslinesZ append_crr3r3r4_write_requirementsrs  rcCsn|j}tj}t||j|jp"i}x2t|D]&}|jdjft t|||q.W|j d||j dS)Nz [{extra}] requirements) rVrStringIOrZinstall_requiresextras_requiresortedrformatvarsrxgetvalue)rrrSdistrvrextrar3r3r4write_requirementsys  rcCs*t}t||jj|jd||jdS)Nzsetup-requirements)rrrVZsetup_requiresrxr)rrrSrvr3r3r4write_setup_requirementssrcCs:tjdd|jjD}|jd|djt|ddS)NcSsg|]}|jdddqS).rr)r )rkr3r3r4rsz(write_toplevel_names..ztop-level namesr)rQfromkeysrVZiter_distribution_namesrqrer)rrrSpkgsr3r3r4write_toplevel_namessrcCst|||ddS)NT) write_arg)rrrSr3r3r4 overwrite_argsrFcCsHtjj|d}t|j|d}|dk r4dj|d}|j||||dS)Nrr)r!r"splitextrOrVrerx)rrrSrwZargnamerMr3r3r4rs rcCs|jj}t|tjs|dkr"|}nr|dk rg}xZt|jD]J\}}t|tjsttj||}dj tt t |j }|j d||fqsR           (   SDEI