K iJdZddlmZddlZddlZddlmZddlmZm Z m Z ddl m Z ddl m Z ddlmZdd lmZd d lmZd d lmZmZd d lmZd dlmZd dlmZdZGddeZddZy)zadistutils.command.sdist Implements the Distutils 'sdist' command (create a source distribution).) annotationsN)Callable) archive_utildir_util file_util)log)glob) filterfalse)ClassVar)Command)DistutilsOptionErrorDistutilsTemplateError)FileList)TextFile) convert_pathcddlmddlm}t fdj D}||j dy)zoPrint all possible values for the 'formats' option (used by the "--help-formats" command-line option). r )ARCHIVE_FORMATS) FancyGetoptc3:K|]}d|zd|dfyw)formats=Nr ).0formatrs i/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/setuptools/_distutils/command/sdist.py zshow_formats..s/  f dOF$;A$>?sz.List of available source distribution formats:N)rr fancy_getoptrsortedkeys print_help)rformatsrs @r show_formatsr"sA/*%**,G##$TUceZdZUdZd*dZgdZgdZded<ddd efgZ d ed <d d dZ ded<defgZ dZ ded<dZ d+dZd+dZd+dZd+dZedZdZdZdZdZdZd Zd!Zd+d"Zd+d#Zd+d$Zd%Zd+d&Zd+d'Z d+d(Z!d)Z"y),sdistz6create a source distribution (tarball, zip file, etc.)c|jS)zYCallable used for the check sub-command. Placed here so user_options can view it)metadata_checkselfs rchecking_metadatazsdist.checking_metadata(s"""r#))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)pruneNzspecifically 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-onlyozEjust regenerate the manifest and then stop (implies --force-manifest))force-manifestfzkforcibly regenerate the manifest and carry on as usual. Deprecated: now the manifest is always regenerated.)rNz6formats for source distribution (comma-separated list)) keep-tempkz@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/r1r3r5r8zClassVar[list[str]]boolean_optionsz help-formatsNz#list available distribution formatszAClassVar[list[tuple[str, str | None, str, Callable[[], object]]]] help_optionsr-r/)r.r0zClassVar[dict[str, str]] negative_optcheck)READMEz README.txtz README.rstzClassVar[tuple[str, ...]]READMEScd|_d|_d|_d|_d|_d|_dg|_d|_d|_d|_ d|_ d|_ d|_ y)NTFgztar) templatemanifest use_defaultsr/ manifest_onlyforce_manifestr! keep_tempdist_dir archive_filesr'ownergroupr(s rinitialize_optionszsdist.initialize_options~sh  ! "#y  !"  r#c|jd|_|jd|_|jdtj|j }|rt d|d|jd|_yy)NMANIFESTz MANIFEST.inr!zunknown archive format ''dist)rDrCensure_string_listrcheck_archive_formatsr!rrI)r) bad_formats rfinalize_optionszsdist.finalize_optionsst == &DM == )DM  *!77 E &)A*Q'OP P == "DM !r#ct|_|jD]}|j||j |j ry|j yN)rfilelistget_sub_commands run_command get_file_listrFmake_distribution)r)cmd_names rrunz sdist.runs_!  --/ 'H   X & '       r#ctjj|j}|sU|j rE|j |j j|j jy|s|jd|jz|j j|jr|j|r|j|jr|j|j j|j j|j!y)aCFigure out the list of files to include in the source distribution, and put it in 'self.filelist'. This might involve reading the manifest template (and writing the manifest), or just reading the manifest, or just using the default file set -- it all depends on the user's options. Nz?manifest template '%s' does not exist (using default file list))ospathisfilerC_manifest_is_not_generated read_manifestrXsortremove_duplicateswarnfindallrE add_defaults read_templater/prune_file_listwrite_manifest)r)template_existss rr[zsdist.get_file_lists''..74#B#B#D    MM   MM + + -  IIW--               ::  "  '') r#c|j|j|j|j|j |j |j y)aLAdd all the default files to self.filelist: - README or README.txt - setup.py - tests/test*.py and test/test*.py - all pure Python modules mentioned in setup script - all files pointed by package_data (build_py) - all files defined in data_files. - all files defined as scripts. - all C sources listed as part of extensions or C libraries in the setup script (doesn't catch C headers!) Warns if (README or README.txt) or setup.py are missing; everything else is optional. N)_add_defaults_standards_add_defaults_optional_add_defaults_python_add_defaults_data_files_add_defaults_ext_add_defaults_c_libs_add_defaults_scriptsr(s rrizsdist.add_defaultssX $$& ##% !!# %%'   !!# ""$r#ctjj|sytjj|}tjj |\}}|tj |vS)z Case-sensitive path existence check >>> sdist._cs_path_exists(__file__) True >>> sdist._cs_path_exists(__file__.upper()) False F)r`raexistsabspathsplitlistdir)fspathrx directoryfilenames r_cs_path_existszsdist._cs_path_existssTww~~f%''//&) ggmmG4 82::i000r#c|j|jjg}|D]}t|trb|}d}|D]2}|j |sd}|j j|n|rQ|jddj|zu|j |r|j j||jd|dy)NFTz,standard file not found: should have one of z, zstandard file 'z ' not found) r@ distribution script_name isinstancetupler~rXappendrgjoin)r) standardsfnaltsgot_its rrozsdist._add_defaults_standards s\\4#4#4#@#@A  AB"e$B++B/!% ,,R0  IIFSWX''+MM((,IIt;?@% Ar#cgd}|D]J}ttjjt |}|j j |Ly)N)ztests/test*.pyz test/test*.pyz setup.cfg)filterr`rarbr rXextend)r)optionalpatternfiless rrpzsdist._add_defaults_optional s@C (G277>>4=9E MM  ' (r#cX|jd}|jjr)|jj |j |j D]G\}}}}|D];}|jjtjj||=Iy)Nbuild_py) get_finalized_commandrhas_pure_modulesrXrget_source_files data_filesrr`rar)r)r_pkgsrc_dir _build_dir filenamesr}s rrqzsdist._add_defaults_python&s--j9    - - / MM !:!:!< =5=4G4G F 0D':y% F $$RWW\\'8%DE F Fr#c|jjr|jjD]}t|trGt |}t jj|s>|jj|Z|\}}|D]H}t |}t jj|s.|jj|JyyrW) rhas_data_filesrrstrrr`rarbrXr)r)itemdirnamerr4s rrrzsdist._add_defaults_data_files6s    + + -))44 4dC('-Dww~~d+ ,,T2*.&GY&4(O77>>!, MM0034 4 .r#c|jjr;|jd}|jj |j yy)N build_ext)rhas_ext_modulesrrXrr)r)rs rrszsdist._add_defaults_extGsD    , , .22;?I MM !;!;!= > /r#c|jjr;|jd}|jj |j yy)N build_clib)rhas_c_librariesrrXrr)r)rs rrtzsdist._add_defaults_c_libsLsD    , , .33LAJ MM ! ? /r#c|jjr;|jd}|jj |j yy)N build_scripts)r has_scriptsrrXrr)r)rs rruzsdist._add_defaults_scriptsQsD    ( ( * 66GM MM !?!?!A B +r#c tjd|jt|jdddddd} |j }|n |j j |0 |jy#ttf$r@}|j|jdt|jd|Yd}~]d}~wwxYw#|jwxYw)zRead and parse manifest template file named by self.template. (usually "MANIFEST.in") The parsing and processing is done by 'self.filelist', which updates itself accordingly. zreading manifest template '%s'T)strip_comments skip_blanks join_lines lstrip_ws rstrip_ws collapse_joinNz, line z: )rinforCrreadlinerXprocess_template_liner ValueErrorrgr}int current_lineclose)r)rClinemsgs rrjzsdist.read_templateVs 14==A MM  ((*<MM77=  NN  / ;II#,,-WS9N9N5O4PPRSVRWX NN s5CB.CC6C C CCC%c|jd}|jj}|jj dt j |j|jj d|tjdk(rd}nd}gd}dj|d j||}|jj |d y) avPrune off branches that might slip into the file list as created by 'read_template()', but really don't belong there: * the build tree (typically "build") * the release tree itself (only an issue if we ran "sdist" previously with --keep-temp, or it aborted) * any RCS, CVS, .svn, .hg, .git, .bzr, _darcs directories buildN)prefixwin32z/|\\/)RCSCVSz\.svnz\.hgz\.gitz\.bzr_darcsz(^|{})({})({}).*|T)is_regex) rr get_fullnamerXexclude_patternr`r{ build_basesysplatformrr)r)rbase_dirsepsvcs_dirsvcs_ptrns rrkzsdist.prune_file_listys**73$$113 %%d299U=M=M3N%O %%d8%< <<7 "DDR&--dCHHX4FM %%h%>r#c8|jr$tjd|jdy|jj dd}|j dd|jtj|j|fd|jdy)zWrite the file list in 'self.filelist' (presumably as filled in by 'add_defaults()' and 'read_template()') to the manifest file named by 'self.manifest'. z2not writing to manually maintained manifest file 'rPNrz*# file GENERATED by distutils, do NOT editzwriting manifest file ') rcrrrDrXrinsertexecuter write_file)r)contents rrlzsdist.write_manifests  * * , HHDT]]OSTU  --%%a(qFG  ]]G $%dmm_A 6 r#ctjj|jsyt |jd5}t |}ddd|dk7S#1swYdk7SxYw)NFutf-8encodingz+# file GENERATED by distutils, do NOT edit )r`rarbrDopennext)r)fp first_lines rrcz sdist._manifest_is_not_generatedsZww~~dmm, $--' 2 "bbJ "KKK "KKKs  AA(c 2tjd|jt|jd5}|jj t dttttj|dddy#1swYyxYw)zRead the manifest file (named by 'self.manifest') and use it to fill in 'self.filelist', the list of files to include in the source distribution. zreading manifest file '%s'rrN) rrrDrrXrrr is_commentmaprstrip)r)liness rrdzsdist.read_manifestsj -t}}= $--' 2 e MM t[SE5JKL    s A B  Bc2|j|tj|||jt t dr d}d|d}nd}d|d}|st jdnt j||D]l}t jj|st jd |9t jj||}|j||| n|jjj|y) aCreate the directory tree that will become the source distribution archive. All directories implied by the filenames in 'files' are created under 'base_dir', and then we hard link or copy (if hard linking is unavailable) those files into place. Essentially, this duplicates the developer's source tree, but in a directory named after the distribution, containing only the files to be distributed. dry_runlinkhardzmaking hard links in z...Nzcopying files to z)no files to distribute -- empty manifest?z#'%s' not a regular file -- skipping)r)mkpathr create_treerhasattrr`rwarningrrarbr copy_filermetadatawrite_pkg_info)r)rrrrfiledests rmake_release_treezsdist.make_release_trees HXudllC 2v D)(37CD%hZs3C KKC D HHSM 6D77>>$' A4Hww||Hd3tT5  6 ""11(;r#c|jj}tjj |j |}|j ||jjg}d|jvrM|jj|jj|jjd|jD]e}|j||||j|j}|j||jj jdd|fg||_|j$s"t'j(||j*yy)aCreate the source distribution(s). First, we create the release tree with 'make_release_tree()'; then, we create all required archive files (according to 'self.formats') from the release tree. Finally, we clean up by blowing away the release tree (unless 'self.keep_temp' is true). The list of archive files created is stored so it can be retrieved later by 'get_archive_files()'. tar)rrKrLr%rN)rrr`rarrIrrXrr!rpopindex make_archiverKrL dist_filesrJrHr remove_treer)r)r base_namerJfmtrs rr\zsdist.make_distributions#$$113GGLL9  x)<)<= DLL LL   0 01C1CE1J K L<< EC$$34::%D   &    ( ( / /"d0C D  E+~~  4<< @r#c|jS)zzReturn the list of archive files created when the command was run, or None if the command hasn't run yet. )rJr(s rget_archive_fileszsdist.get_archive_filess!!!r#)returnbool)rNone)#__name__ __module__ __qualname__ descriptionr* user_optionsr;__annotations__r"r<r= sub_commandsr@rMrUr^r[ri staticmethodr~rorprqrrrsrtrurjrkrlrcrdrr\rrr#rr%r%%sJK# 8Lt,O( DlSWLS &.L* /01L)OG &O. #!,'R%,11 A,( F 4"? @ C !F?. &L ("r#r%c$|jdS)N#) startswith)rs rrrs ??3 r#)rrrr) __doc__ __future__rr`rcollections.abcr distutilsrrrdistutils._logrr itertoolsr typingr corer errorsrrrXr text_filerutilrr"r%rrr#rrsTL# $77!A  V`"G`"F r#