a oeg@sdZddlmZddlmZddlmZddlm Z ddlZddlZddl Z ddl Z ddl Z ddl Z ddlZddlZddlmZdd lmZmZd d lmZdd lmZdd lmZddlmZddlmZddlmZddlm Z ddl!m"Z"ddl#m$Z$ddl%m&Z&dj'e j(Z)ddZ*GdddZ+Gddde+eZ,GdddeZGdddeZ-dd Z.d!d"Z/d#d$Z0ej1Z1ej2Z2d%d&Z3d'd(Z4d2d*d+Z5d,d-Z6d3d.d/Z7Gd0d1d1e&Z8dS)4zUsetuptools.command.egg_info Create a distribution's .egg-info directory and contents)FileList)DistutilsInternalError) convert_path)logN)metadata) _entry_points_normalization) _requirestxt)Command)sdist) walk_revctrl) edit_config) bdist_egg)glob) packaging)SetuptoolsDeprecationWarningz{}.{}cCsd}|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]r **z.*z (?:%s+%s)*r*?[!]^Nz[%s]z\Z)flags) splitospathsepreescape enumeratelencompile MULTILINEDOTALL)rpatchunksr Z valid_charcchunkZ last_chunkiZ chunk_lencharZinner_iinnerZ char_classr/r/r/r0r=szInfoCommon._already_tagged)r@c CsLztd|jddWStjjyFt|jddYS0dS)N0r  .)r r:r<rr?ZInvalidVersionr4replacer6r/r/r0rBszInfoCommon._safe_tagscCs,d}|jr||j7}|jr(|td7}|S)Nrz%Y%m%d) tag_buildtag_datetimestrftimer>r/r/r0tagss  zInfoCommon.tags)__name__ __module__ __qualname__rGrHpropertyr8r;r9strboolr=rBrKr<r/r/r/r0r2xs  r2c@seZdZdZgdZdgZddiZddZeddZ e j d dZ d d Z d d Z e dfddZdddZddZddZddZddZdS)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]rTrWcCs"d|_d|_d|_d|_d|_dS)NF)egg_baseegg_namerR egg_versionignore_egg_info_in_manifestr6r/r/r0initialize_optionss zegg_info.initialize_optionscCsdSr3r/r6r/r/r0tag_svn_revisionszegg_info.tag_svn_revisioncCsdSr3r/)r7valuer/r/r0r^scCs0t}||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)rRN) collections OrderedDictrKrdict)r7filenamerRr/r/r0save_version_infos zegg_info.save_version_infoc Csd|j|_||_tj|j}z6t|tjj}|r8dnd}tj ||j|jfWn>t y}z&t j d|j|jf|WYd}~n d}~00|jdur|jj}|pidtj|_|dt|jd|_|jtjkrtj|j|j|_|j|jj_|jj}t|ddp$t|dd}|dur`||jkr`|j|_tj|j|_d|j_dS) Nz%s==%sz%s===%sz2Invalid distribution name or version syntax: %s-%srrY .egg-infokeyr8) r8rZr;r[rr?ZVersion isinstanceZ requirementsZ Requirement ValueError distutilserrorsZDistutilsOptionErrorrYr5Z package_dirgetrcurdirZensure_dirnamer filename_componentrRrjoinrZ _patched_distgetattrlowerZ_versionZ_parsed_version)r7Zparsed_versionZ is_versionspecrSdirspdrfr/r/r0finalize_optionss:       zegg_info.finalize_optionsNcCst|j|j||S)0Compute filename of the output egg. Private API.) _egg_basenamerZr[)r7 py_versionplatformr/r/r0_get_egg_basenameszegg_info._get_egg_basenameFcCsL|r||||n4tj|rH|dur>|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_filerrexistsrwarn delete_file)r7whatrcdataforcer/r/r0write_or_delete_file s   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)r7r~rcrfr/r/r0rzs    zegg_info.write_filecCs td||jst|dS)z8Delete `filename` (if not a dry run) after announcing itz deleting %sN)rrrrunlink)r7rcr/r/r0r}+s zegg_info.delete_filec Cs||jzt|jdWn@ty^}z(d|jd}tj||WYd}~n d}~00tj ddD](}| }|||j tj |j|j qltj |jd}tj |r|||dS)Nz'Cannot update time stamp of directory ''zegg_info.writers)groupznative_libs.txt)ZmkpathrRrutimeOSErrorrirjZDistutilsFileErrorr entry_pointsloadr8rrnr{r} find_sources)r7rSmsgZepwriternlr/r/r0run1s $  z egg_info.runcCs<tj|jd}t|j}|j|_||_| |j |_ dS)z"Generate SOURCES.txt manifest filez SOURCES.txtN) rrrnrRmanifest_makerr5r\ignore_egg_info_dirmanifestrfilelist)r7Zmanifest_filenameZmmr/r/r0rCs  zegg_info.find_sources)F)rLrMrN descriptionZ user_optionsZboolean_optionsZ negative_optr]rOr^setterrdrtPY_MAJORryrrzr}rrr/r/r/r0rRs$     ,  rRcseZdZd!fdd ZddZddZd d Zd d Zd dZddZ ddZ ddZ ddZ ddZ ddZddZddZdd ZZS)"rNFcst||||_dSr3)super__init__r)r7r| debug_printr __class__r/r0rPszFileList.__init__c Cs ||\}}}}|j|j|j|jt|j|t|j||j |j d}dddddddd d}z ||}Wn"t yt d j |d Yn0|d } |d vr|g}| r|fnd} ||} |d|g| r|gng||D] } || stj| | g| RqdS)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->rrr/rD)Z_parse_template_linerrglobal_includeglobal_exclude functoolspartialrecursive_includerecursive_excluderrKeyErrorrformat startswithrrnrr|) r7linerpatternsdirZ dir_patternZ action_mapZlog_mapZprocess_actionZaction_is_recursiveZextra_log_argsZlog_tmplpatternr/r/r0process_template_lineTsX    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 Fr z removing T)ranger$filesr)r7 predicatefoundr,r/r/r0 _remove_filesszFileList._remove_filescCs$ddt|D}||t|S)z#Include files that match 'pattern'.cSsg|]}tj|s|qSr/rrisdir.0rr/r/r0 z$FileList.include..rextendrQr7rrr/r/r0rs zFileList.includecCst|}||jS)z#Exclude files that match 'pattern'.)r1rmatchr7rrr/r/r0rszFileList.excludecCs8tj|d|}ddt|ddD}||t|S)zN Include all files anywhere in 'dir/' that match the pattern. rcSsg|]}tj|s|qSr/rrr/r/r0rrz.FileList.recursive_include..T) recursive)rrrnrrrQ)r7rrZ full_patternrr/r/r0rs zFileList.recursive_includecCs ttj|d|}||jS)zM Exclude any file anywhere in 'dir/' that match the pattern. rr1rrrnrr)r7rrrr/r/r0rszFileList.recursive_excludecCs$ddt|D}||t|S)zInclude all files from 'dir/'.cSs"g|]}tj|D]}|qqSr/)rirfindall)rZ match_diritemr/r/r0rsz"FileList.graft..r)r7rrr/r/r0rs  zFileList.graftcCsttj|d}||jS)zFilter out files from 'dir/'.rr)r7rrr/r/r0rszFileList.prunecsJ|jdur|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|qSr/rrrr/r0rrz+FileList.global_include..)Zallfilesrr1rrrnrrQrr/rr0rs   zFileList.global_includecCsttjd|}||jS)zD Exclude all files anywhere that match the pattern. rrrr/r/r0rszFileList.global_excludecCs8|dr|dd}t|}||r4|j|dS)N r)rAr _safe_pathrappend)r7rrr/r/r0rs    zFileList.appendcCs|jt|j|dSr3)rrfilterr)r7pathsr/r/r0rszFileList.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)listrrrr6r/r/r0_repairszFileList._repairc Csd}t|}|dur(td|dSt|d}|durNt||ddSzBd|vp^d|v}|jrp|rpWdStj|stj|rWdSWn$t yt||t Yn0dS)Nz!'%s' not %s encodable -- skippingz''%s' in unexpected encoding -- skippingFrres .egg-infoT) unicode_utilsfilesys_decoderr|Z try_encoderrrr{UnicodeEncodeErrorsysgetfilesystemencoding)r7rZenc_warnZu_pathZ utf8_pathZ is_egg_infor/r/r0rs"     zFileList._safe_path)NNF)rLrMrNrrrrrrrrrrrrrrr __classcell__r/r/rr0rMsG     rc@steZdZdZddZddZddZdd Zd d Zd d Z e ddZ ddZ ddZ ddZddZddZdS)rz MANIFEST.incCs"d|_d|_d|_d|_d|_dS)Nr F)Z use_defaultsrZ manifest_onlyZforce_manifestrr6r/r/r0r]s z!manifest_maker.initialize_optionscCsdSr3r/r6r/r/r0rt szmanifest_maker.finalize_optionscCszt|jd|_tj|js$||tj|j rB| | | | |j|j|dS)N)r)rrrrrr{rwrite_manifest add_defaultstemplateZ read_templateadd_license_files_add_referenced_filesprune_file_listsortZremove_duplicatesr6r/r/r0r#s  zmanifest_maker.runcCst|}|tjdS)N/)rrrFrr )r7rr/r/r0_manifest_normalize1s 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|]}|qSr/)rrr6r/r0r=rz1manifest_maker.write_manifest..zwriting manifest file '%s'N)rrrrZexecuterz)r7rrr/r6r0r5s  zmanifest_maker.write_manifestcCs||st||dSr3)_should_suppress_warningr r|)r7rr/r/r0r|As zmanifest_maker.warncCs td|S)z; suppress missing-file warnings from sdist zstandard file .*not found)r!r)rr/r/r0rEsz'manifest_maker._should_suppress_warningcCst||j|j|j|jtt}|rB|j|nt j |jrX| t j drp|jd| d}|j|jdS)Nzsetup.pyrR)r rrrrrrrrrrr{Z read_manifestget_finalized_commandrrR)r7ZrcfilesZei_cmdr/r/r0rLs     zmanifest_maker.add_defaultscCs4|jjjp g}|D]}td|q|j|dS)Nzadding license file '%s')r5r license_filesrrrr)r7rZlfr/r/r0r^sz manifest_maker.add_license_filescCs4t|jdg}|D]}td|q|j|dS)zGAdd files referenced by the config (e.g. `file:` directive) to filelistZ_referenced_filesz%adding file referenced by config '%s'N)ror5rdebugrr)r7Z referencedZrfr/r/r0rdsz$manifest_maker._add_referenced_filescCsZ|d}|j}|j|j|j|ttj }|jj d|d|dddS)Nbuildz(^|z)(RCS|CVS|\.svn)r )Zis_regex) rr5Z get_fullnamerrZ build_baser!r"rr Zexclude_pattern)r7rbase_dirr r/r/r0rls    zmanifest_maker.prune_file_listcCs*t|dr|Stjdddd|S)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_manifestz@`build_py` command does not inherit from setuptools' `build_py`.z Custom 'build_py' does not implement 'get_data_files_without_manifest'. Please extend command classes from setuptools instead of distutils. z!https://peps.python.org/pep-0632/)Zsee_url)hasattrrremitZget_data_files)r7Zbuild_pyr/r/r0_safe_data_filesvs  zmanifest_maker._safe_data_filesN)rLrMrNrr]rtrrrr| staticmethodrrrrrrr/r/r/r0rs   rcCsLd|}|d}t|d}||Wdn1s>0YdS)z{Create a file with the specified name and write 'contents' (a sequence of strings without line terminators) to it.  rrN)rnrrr)rccontentsrr/r/r0rzs   rzc Cstd||js|jj}|j|j|_}|j|j|_}z| |j W|||_|_n|||_|_0t |jdd}t |j |dS)Nz writing %sZzip_safe)rrrr5rr[r?rZr8write_pkg_inforRrorZwrite_safety_flag)cmdbasenamercrZoldverZoldnamesafer/r/r0rs  rcCsdS)aj Unused: left to avoid errors when updating (from source) from <= 67.8. Old installations have a .dist-info directory with the entry-point ``depends.txt = setuptools.command.egg_info:warn_depends_obsolete``. This may trigger errors when running the first egg_info in build_meta. TODO: Remove this function in a version sufficiently > 68. Nr/rrrcr/r/r0warn_depends_obsoletesrcCs:tdd|jD}|d|dt|ddS)NcSsg|]}|dddqS)rEr r)r)rkr/r/r0rrz(write_toplevel_names..ztop-level namesr)rbfromkeysr5Ziter_distribution_namesrzrnsorted)rrrcZpkgsr/r/r0write_toplevel_namessrcCst|||ddS)NT) write_argrr/r/r0 overwrite_argsrFcCsHtj|d}t|j|d}|dur4d|d}|||||dS)Nrr)rrsplitextror5rnr)rrrcrargnamer_r/r/r0rs rcCs,t|jj}t|}|d||ddS)Nz entry pointsT)rrr5rZrenderr)rrrcZepsZdefnr/r/r0 write_entriess rcCsBt|}t|}|d|d|p&t}|r>|d|7}|S)ru-z-py)r rmr)rZr[rwrxr8r?Zeggr/r/r0rvs   rvc@seZdZdZdS)EggInfoDeprecationWarningz?Deprecated behavior warning for EggInfo, bypassing suppression.N)rLrMrN__doc__r/r/r/r0rsr)F)NN)9rZdistutils.filelistrZ _FileListZdistutils.errorsrZdistutils.utilrrirrrr!rrIr`Z _importlibrrrr r Z setuptoolsr Zsetuptools.command.sdistr rZsetuptools.command.setoptrZsetuptools.commandrZsetuptools.unicode_utilsrZsetuptools.globrZsetuptools.externrwarningsrr version_inforr1r2rRrrzrrZwrite_requirementsZwrite_setup_requirementsrrrrrvrr/r/r/r0sV                S/'Jy