U e5d=Jã@s´ddlZddlZddlmZddlmZddlmZddlmZddlm Z ddlm Z ddl m Z dd l mZdd lmZdd lmZdd lmZmZd d„ZGdd„deƒZdS)éN)Úglob)Úwarn)ÚCommand)Údir_util)Ú file_util)Ú archive_util)ÚTextFile)ÚFileList)Úlog)Ú convert_path)ÚDistutilsTemplateErrorÚDistutilsOptionErrorcCs`ddlm}ddlm}g}| ¡D] }| d|d||df¡q$| ¡||ƒ d¡dS)Nr)Ú FancyGetopt)ÚARCHIVE_FORMATSúformats=éz.List of available source distribution formats:)Zdistutils.fancy_getoptrZdistutils.archive_utilrÚkeysÚappendÚsortZ print_help)rrÚformatsÚformat©rú//usr/lib64/python3.8/distutils/command/sdist.pyÚ show_formatss     ÿÿrc@s"eZdZdZdd„Zdddddd d d d d ddddgZddddddgZdddefgZdddœZ defgZ dZ dd„Z d d!„Z d"d#„Zd$d%„Zd&d'„Zd(d)„Zed*d+„ƒZd,d-„Zd.d/„Zd0d1„Zd2d3„Zd4d5„Zd6d7„Zd8d9„Zd:d;„Zdd?„Zd@dA„ZdBdC„ZdDdE„Z dFdG„Z!dHdI„Z"dS)JÚsdistz6create a source distribution (tarball, zip file, etc.)cCs|jS©N)Úmetadata_check©ÚselfrrrÚchecking_metadata(szsdist.checking_metadata)z template=Útz5name of manifest template file [default: MANIFEST.in])z manifest=Úmz)name of manifest file [default: MANIFEST])ú use-defaultsNzRinclude the default file set in the manifest [default; disable with --no-defaults])ú no-defaultsNz"don't include the default file set)ÚpruneNz‰specifically exclude files/directories that should not be distributed (build tree, RCS/CVS dirs, etc.) [default; disable with --no-prune])úno-pruneNz$don't automatically exclude anything)ú manifest-onlyÚozEjust regenerate the manifest and then stop (implies --force-manifest))úforce-manifestÚfzkforcibly regenerate the manifest and carry on as usual. Deprecated: now the manifest is always regenerated.)rNz6formats for source distribution (comma-separated list))ú keep-tempÚkz@keep the distribution tree around after creating archive file(s))z dist-dir=ÚdzFdirectory to put the source distribution archive(s) in [default: dist])úmetadata-checkNz[Ensure that all required elements of meta-data are supplied. Warn if any missing. [default])zowner=Úuz@Owner name used when creating a tar file [default: current user])zgroup=ÚgzAGroup name used when creating a tar file [default: current group]r"r$r&r(r*r-z help-formatsNz#list available distribution formats)r#r%Úcheck)ZREADMEz README.txtz README.rstcCsTd|_d|_d|_d|_d|_d|_dg|_d|_d|_d|_ d|_ d|_ d|_ dS)NérZgztar) ÚtemplateÚmanifestÚ use_defaultsr$Ú manifest_onlyZforce_manifestrÚ keep_tempÚdist_dirÚ archive_filesrÚownerÚgrouprrrrÚinitialize_optionseszsdist.initialize_optionscCsZ|jdkrd|_|jdkr d|_| d¡t |j¡}|rFtd|ƒ‚|jdkrVd|_dS)NZMANIFESTz MANIFEST.inrzunknown archive format '%s'Zdist)r3r2Zensure_string_listrZcheck_archive_formatsrr r7)rZ bad_formatrrrÚfinalize_options|s    ÿ zsdist.finalize_optionscCs>tƒ|_| ¡D]}| |¡q| ¡|jr2dS| ¡dSr)r ÚfilelistZget_sub_commandsZ run_commandÚ get_file_listr5Úmake_distribution)rZcmd_namerrrÚrunŒs  z sdist.runcCs*tdtƒ|j d¡}| ¡| ¡dS)Nzadistutils.command.sdist.check_metadata is deprecated, use the check command insteadr0)rÚPendingDeprecationWarningÚ distributionZget_command_objZensure_finalizedr@)rr0rrrÚcheck_metadata¢s ÿ zsdist.check_metadatacCs tj |j¡}|s:| ¡r:| ¡|j ¡|j ¡dS|sN|  d|j¡|j  ¡|j rf|  ¡|rr|  ¡|jr€| ¡|j ¡|j ¡| ¡dS)Nz?manifest template '%s' does not exist (using default file list))ÚosÚpathÚisfiler2Ú_manifest_is_not_generatedÚ read_manifestr=rZremove_duplicatesrÚfindallr4Ú add_defaultsÚ read_templater$Úprune_file_listÚwrite_manifest)rZtemplate_existsrrrr>ªs(   þ   zsdist.get_file_listcCs<| ¡| ¡| ¡| ¡| ¡| ¡| ¡dSr)Ú_add_defaults_standardsÚ_add_defaults_optionalÚ_add_defaults_pythonÚ_add_defaults_data_filesÚ_add_defaults_extÚ_add_defaults_c_libsÚ_add_defaults_scriptsrrrrrJÒszsdist.add_defaultscCs:tj |¡sdStj |¡}tj |¡\}}|t |¡kS)NF)rDrEÚexistsÚabspathÚsplitÚlistdir)ÚfspathrVZ directoryÚfilenamerrrÚ_cs_path_existsès  zsdist._cs_path_existscCs–|j|jjg}|D]~}t|tƒrj|}d}|D]"}| |¡r,d}|j |¡qPq,|s| dd  |¡¡q| |¡r‚|j |¡q| d|¡qdS)NFTz,standard file not found: should have one of z, zstandard file '%s' not found) ÚREADMESrBZ script_nameÚ isinstanceÚtupler[r=rrÚjoin)rZ standardsÚfnZaltsZgot_itrrrrNùs"   ÿ zsdist._add_defaults_standardscCs4ddg}|D]"}ttjjt|ƒƒ}|j |¡q dS)Nz test/test*.pyz setup.cfg)ÚfilterrDrErFrr=Úextend)rZoptionalÚpatternÚfilesrrrrOszsdist._add_defaults_optionalcCs\| d¡}|j ¡r$|j | ¡¡|jD],\}}}}|D]}|j tj   ||¡¡q:q*dS)NÚbuild_py) Úget_finalized_commandrBZhas_pure_modulesr=rbÚget_source_filesÚ data_filesrrDrEr_)rreZpkgZsrc_dirZ build_dirÚ filenamesrZrrrrPs   zsdist._add_defaults_pythoncCsz|j ¡rv|jjD]b}t|tƒrBt|ƒ}tj |¡rt|j   |¡q|\}}|D]$}t|ƒ}tj |¡rN|j   |¡qNqdSr) rBZhas_data_filesrhr]Ústrr rDrErFr=r)rÚitemÚdirnamerir)rrrrQ$s     zsdist._add_defaults_data_filescCs(|j ¡r$| d¡}|j | ¡¡dS)NÚ build_ext)rBZhas_ext_modulesrfr=rbrg)rrmrrrrR5s  zsdist._add_defaults_extcCs(|j ¡r$| d¡}|j | ¡¡dS)NÚ build_clib)rBZhas_c_librariesrfr=rbrg)rrnrrrrS:s  zsdist._add_defaults_c_libscCs(|j ¡r$| d¡}|j | ¡¡dS)NÚ build_scripts)rBZ has_scriptsrfr=rbrg)rrorrrrT?s  zsdist._add_defaults_scriptsc Csžt d|j¡t|jddddddd}zh| ¡}|dkr:qŒz|j |¡Wq(tt fk rˆ}z|  d|j |j |f¡W5d}~XYq(Xq(W5| ¡XdS)Nzreading manifest template '%s'r1)Zstrip_commentsZ skip_blanksZ join_linesZ lstrip_wsZ rstrip_wsZ collapse_joinz%s, line %d: %s) r Úinfor2rÚcloseÚreadliner=Zprocess_template_liner Ú ValueErrorrrZZ current_line)rr2ÚlineÚmsgrrrrKDs& þ þ zsdist.read_templatecCs„| d¡}|j ¡}|jjd|jd|jjd|dtjdkrFd}nd}dddd d d d g}d |d |¡|f}|jj|dddS)NÚbuild)ÚprefixZwin32z/|\\ú/ZRCSZCVSz\.svnz\.hgz\.gitz\.bzrZ_darcsz(^|%s)(%s)(%s).*ú|r1)Zis_regex) rfrBÚ get_fullnamer=Zexclude_patternZ build_baseÚsysÚplatformr_)rrvÚbase_dirZsepsZvcs_dirsZvcs_ptrnrrrrLas    ÿzsdist.prune_file_listcCsX| ¡rt d|j¡dS|jjdd…}| dd¡| tj |j|fd|j¡dS)Nz5not writing to manually maintained manifest file '%s'rz*# file GENERATED by distutils, do NOT editzwriting manifest file '%s') rGr rpr3r=rdÚinsertZexecuterZ write_file)rZcontentrrrrMysÿ ÿzsdist.write_manifestcCs<tj |j¡sdSt|jƒ}z | ¡}W5| ¡X|dkS)NFz+# file GENERATED by distutils, do NOT edit )rDrErFr3Úopenrqrr)rÚfpZ first_linerrrrGˆs   z sdist._manifest_is_not_generatedc CsVt d|j¡t|jƒ4}|D](}| ¡}| d¡s|s:q|j |¡qW5QRXdS)Nzreading manifest file '%s'ú#)r rpr3rÚstripÚ startswithr=r)rr3rtrrrrH”s zsdist.read_manifestcCs®| |¡tj|||jdttdƒr4d}d|}n d}d|}|sPt d¡n t |¡|D]<}tj   |¡s|t d|¡q^tj   ||¡}|j |||dq^|j j |¡dS) N©Údry_runÚlinkZhardzmaking hard links in %s...zcopying files to %s...z)no files to distribute -- empty manifest?z#'%s' not a regular file -- skipping)r†)ZmkpathrZ create_treer…ÚhasattrrDr rrprErFr_Z copy_filerBZmetadataZwrite_pkg_info)rr}rdr†ruÚfileÚdestrrrÚmake_release_tree¢s      zsdist.make_release_treecCs¶|j ¡}tj |j|¡}| ||jj¡g}d|j krT|j   |j   |j   d¡¡¡|j D]:}|j ||||j|jd}|  |¡|jj  dd|f¡qZ||_|js²tj||jddS)NZtar)r}r9r:rÚr„)rBrzrDrEr_r7rŠr=rdrrÚpopÚindexZ make_archiver9r:Z dist_filesr8r6rZ remove_treer…)rr}Z base_namer8Zfmtrˆrrrr?Ìs    ÿ zsdist.make_distributioncCs|jSr)r8rrrrÚget_archive_filesêszsdist.get_archive_files)#Ú__name__Ú __module__Ú __qualname__Z descriptionrZ user_optionsZboolean_optionsrZ help_optionsZ negative_optZ sub_commandsr\r;r<r@rCr>rJÚ staticmethodr[rNrOrPrQrRrSrTrKrLrMrGrHrŠr?rŽrrrrr$spÝ'þÿÿÿ (  *r)rDr{rÚwarningsrZdistutils.corerZ distutilsrrrZdistutils.text_filerZdistutils.filelistr r Zdistutils.utilr Zdistutils.errorsr r rrrrrrÚs