3 (\c@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+ddlm,Z,ddZ-GdddZ.Gddde.eZ/GdddeZGdddeZ0ddZ1ddZ2d d!Z3d"d#Z4d$d%Z5d&d'Z6d(d)Z7d*d+Z8d5d-d.Z9d/d0Z:d1d2Z;Gd3d4d4e,Zr5r5r5r6r8ws  r8c@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_namerK egg_versionbroken_egg_info)r;r5r5r6initialize_optionss zegg_info.initialize_optionscCsdS)Nr5)r;r5r5r6tag_svn_revisionszegg_info.tag_svn_revisioncCsdS)Nr5)r;valuer5r5r6r]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. rBrrC)rKN) collections OrderedDictrFr dict)r;filenamerKr5r5r6save_version_infos zegg_info.save_version_infoc CsB|j|_|j|_t|j}y6t|tjj}|r4dnd}t t ||j|jfWn,t k r~t j jd|j|jfYnX|jdkr|jj}|pijdtj|_|jdt|jd|_|jtjkrtjj|j|j|_d|jkr|j|j|jj_|jj}|dk r>|j|jjkr>|j|_t|j|_ d|j_dS)Nz%s==%sz%s===%sz2Invalid distribution name or version syntax: %s-%srrXz .egg-info-)!r<rYrArZr isinstancerr@Versionlistr ValueError distutilserrorsDistutilsOptionErrorrXr9 package_dirgetr"curdirensure_dirnamerrKr#joincheck_broken_egg_infometadataZ _patched_distkeylower_version_parsed_version)r;parsed_versionZ is_versionspecdirspdr5r5r6finalize_optionss6         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)r;whatrbdataforcer5r5r6write_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)r;rrbrfr5r5r6r|s   zegg_info.write_filecCs tjd||jstj|dS)z8Delete `filename` (if not a dry run) after announcing itz deleting %sN)rrrr"unlink)r;rbr5r5r6rs 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)mkpathrKr"utimer9Zfetch_build_eggrrequireresolver<r#rpr}r find_sources)r;repwriternlr5r5r6runs     z egg_info.runcCs4tjj|jd}t|j}||_|j|j|_dS)z"Generate SOURCES.txt manifest filez SOURCES.txtN) r"r#rprKmanifest_makerr9manifestrfilelist)r;Zmanifest_filenamemmr5r5r6r*s  zegg_info.find_sourcescCsd|jd}|jtjkr&tjj|j|}tjj|r`tjddddd||j |j |_ ||_ dS)Nz .egg-infordNz 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. ) rYrXr"rnr#rpr}rr~rKr[)r;Zbeir5r5r6rq2s    zegg_info.check_broken_egg_infoN)rLrMrN)rOrPrQ)rRrSrT)rUrVrW)F)rGrHrI description user_optionsboolean_options negative_optr\rJr]setterrcr{rr|rrrrqr5r5r5r6rKs$  1 rKc@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_printrprrr~rglobal_includeglobal_excluderecursive_includerecursive_excluderrr)r;lineactionpatternsdirZ dir_patternpatternr5r5r6process_template_lineEsd                 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)r; predicatefoundr1r5r5r6 _remove_filesszFileList._remove_filescCs$ddt|D}|j|t|S)z#Include files that match 'pattern'.cSsg|]}tjj|s|qSr5)r"r#isdir).0rr5r5r6 sz$FileList.include..)rextendbool)r;rrr5r5r6rs zFileList.includecCst|}|j|jS)z#Exclude files that match 'pattern'.)r7rmatch)r;rrr5r5r6rszFileList.excludecCs8tjj|d|}ddt|ddD}|j|t|S)zN Include all files anywhere in 'dir/' that match the pattern. z**cSsg|]}tjj|s|qSr5)r"r#r)rrr5r5r6rsz.FileList.recursive_include..T) recursive)r"r#rprrr)r;rrZ full_patternrr5r5r6rs zFileList.recursive_includecCs ttjj|d|}|j|jS)zM Exclude any file anywhere in 'dir/' that match the pattern. z**)r7r"r#rprr)r;rrrr5r5r6rszFileList.recursive_excludecCs$ddt|D}|j|t|S)zInclude all files from 'dir/'.cSs"g|]}tjj|D]}|qqSr5)rirfindall)rZ match_diritemr5r5r6rsz"FileList.graft..)rrr)r;rrr5r5r6rs  zFileList.graftcCsttjj|d}|j|jS)zFilter out files from 'dir/'.z**)r7r"r#rprr)r;rrr5r5r6rszFileList.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|qSr5)r)rr)rr5r6rsz+FileList.global_include..)allfilesrr7r"r#rprr)r;rrr5)rr6rs   zFileList.global_includecCsttjjd|}|j|jS)zD Exclude all files anywhere that match the pattern. z**)r7r"r#rprr)r;rrr5r5r6rszFileList.global_excludecCs8|jdr|dd}t|}|j|r4|jj|dS)N rr)r?r _safe_pathrappend)r;rr#r5r5r6rs    zFileList.appendcCs|jjt|j|dS)N)rrfilterr)r;pathsr5r5r6rszFileList.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)rgrrr)r;r5r5r6_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)r;r#Zenc_warnZu_pathZ utf8_pathr5r5r6rs  zFileList._safe_pathN)rGrHrIrrrrrrrrrrrrrrr5r5r5r6rBsI     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)r;r5r5r6r\ sz!manifest_maker.initialize_optionscCsdS)Nr5)r;r5r5r6r{szmanifest_maker.finalize_optionscCsdt|_tjj|js|j|jtjj|jr<|j |j |jj |jj |jdS)N) rrr"r#r}rwrite_manifest add_defaultstemplateZ read_templateprune_file_listsortZremove_duplicates)r;r5r5r6rs  zmanifest_maker.runcCstj|}|jtjdS)N/)rrreplacer"r$)r;r#r5r5r6_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|qSr5)r)rr)r;r5r6r*sz1manifest_maker.write_manifest..zwriting manifest file '%s'N)rrrrexecuter|)r;rmsgr5)r;r6r"s  zmanifest_maker.write_manifestcCs|j|stj||dS)N)_should_suppress_warningr r~)r;rr5r5r6r~.s zmanifest_maker.warncCs tjd|S)z; suppress missing-file warnings from sdist zstandard file .*not found)r%r)rr5r5r6r2sz'manifest_maker._should_suppress_warningcCstj||j|jj|j|jj|jtt}|rJ|jj |nt j j |jr`|j t j j drx|jjd|jd}|jj|jdS)Nzsetup.pyrK)r rZ check_licenserrrrrgr rr"r#r}Z read_manifestget_finalized_commandrrK)r;ZrcfilesZei_cmdr5r5r6r9s     zmanifest_maker.add_defaultscCsZ|jd}|jj}|jj|j|jj|tjtj }|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$r5r5r6rLs    zmanifest_maker.prune_file_listN)rGrHrIrr\r{rrrr~ staticmethodrrrr5r5r5r6rs   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)rprrr)rbcontentsrr5r5r6r|Vs   r|c Cs|tjd||jsx|jj}|j|j|_}|j|j|_}z|j |j Wd|||_|_Xt |jdd}t j |j |dS)Nz writing %sZzip_safe)rrrr9rrrZr@rYr<write_pkg_inforKgetattrr Zwrite_safety_flag)cmdbasenamerbrrZoldverZoldnamesafer5r5r6rcs 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~)rrrbr5r5r6warn_depends_obsoletevs rcCs,t|pf}dd}t||}|j|dS)NcSs|dS)Nrr5)rr5r5r6sz%_write_requirements..)rr writelines)streamreqslinesZ append_crr5r5r6_write_requirements~s  rcCsn|j}tj}t||j|jp"i}x2t|D]&}|jdjft t|||q.W|j d||j dS)Nz [{extra}] requirements) r9rStringIOrZinstall_requiresextras_requiresortedrformatvarsrgetvalue)rrrbdistrrextrar5r5r6write_requirementss  rcCs,tj}t||jj|jd||jdS)Nzsetup-requirements)iorrr9Zsetup_requiresrr)rrrbrr5r5r6write_setup_requirementssrcCs:tjdd|jjD}|jd|djt|ddS)NcSsg|]}|jdddqS).rr)r!)rkr5r5r6rsz(write_toplevel_names..ztop-level namesr)rafromkeysr9Ziter_distribution_namesr|rpr)rrrbpkgsr5r5r6write_toplevel_namessrcCst|||ddS)NT) write_arg)rrrbr5r5r6 overwrite_argsrFcCsHtjj|d}t|j|d}|dk r4dj|d}|j||||dS)Nrr)r"r#splitextrr9rpr)rrrbrZargnamer^r5r5r6rs rcCs|jj}t|tjs|dkr"|}nr|dk rg}xZt|jD]J\}}t|tjsttj||}dj tt t |j }|j d||fqsX           (    S2EP