\d=JdZddlZddlZddlmZddlmZddlmZddlm Z ddlm Z ddlm Z dd l m Z dd lmZdd lmZdd lmZdd lmZmZdZGddeZdS)zadistutils.command.sdist Implements the Distutils 'sdist' command (create a source distribution).N)glob)warn)Command)dir_util) file_util) archive_util)TextFile)FileList)log) convert_path)DistutilsTemplateErrorDistutilsOptionErrorcddlm}ddlm}g}|D])}|d|zd||df*|||ddS)zoPrint all possible values for the 'formats' option (used by the "--help-formats" command-line option). r) FancyGetopt)ARCHIVE_FORMATSformats=Nz.List of available source distribution formats:)distutils.fancy_getoptrdistutils.archive_utilrkeysappendsort print_help)rrformatsformats (..\python\lib\distutils\command\sdist.py show_formatsrs322222666666G!&&((55 V+T'/24 5 5 5 5 LLNNNK##8:::::ceZdZdZdZgdZgdZdddefgZdd d Z d efgZ d Z d Z dZ dZdZdZdZedZdZdZdZdZdZdZdZdZdZdZdZdZd Z d!Z!d"Z"dS)#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*r,r.r0r3z help-formatsNz#list available distribution formatsr(r*)r)r+check)READMEz README.txtz README.rstcd|_d|_d|_d|_d|_d|_dg|_d|_d|_d|_ d|_ d|_ d|_ dS)Nrgztar) templatemanifest use_defaultsr* manifest_onlyforce_manifestr keep_tempdist_dir archive_filesr"ownergroupr#s rinitialize_optionszsdist.initialize_optionsesl   y  !  rc|jd|_|jd|_|dtj|j}|rt d|z|j d|_dSdS)NMANIFESTz MANIFEST.inrzunknown archive format '%s'dist)r<r;ensure_string_listrcheck_archive_formatsrrrA)r$ bad_formats rfinalize_optionszsdist.finalize_options|s = &DM = )DM  ***!7 EE  >&/*<>> > = "DMMM ! rct|_|D]}||||jrdS|dSN)r filelistget_sub_commands run_command get_file_listr>make_distribution)r$cmd_names rrunz sdist.runs!  --// ' 'H   X & & & &     F      rctdt|jd}||dS)zDeprecated API.zadistutils.command.sdist.check_metadata is deprecated, use the check command insteadr6N)rPendingDeprecationWarning distributionget_command_objensure_finalizedrU)r$r6s rcheck_metadatazsdist.check_metadatasX -.G I I I!11'::     rctj|j}|s\|rH||j|jdS|s| d|jz|j |j r| |r| |jr||j|j|dS)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))ospathisfiler;_manifest_is_not_generated read_manifestrOrremove_duplicatesrfindallr= add_defaults read_templater*prune_file_listwrite_manifest)r$template_existss rrRzsdist.get_file_listsI'..77 4#B#B#D#D     M   M + + - - - F ' II4 & ' ' '           !    : #  " " "  ''))) rc|||||||dS)a9Add all the default files to self.filelist: - README or README.txt - setup.py - 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 rrdzsdist.add_defaultss $$&&& ##%%% !!### %%'''     !!### ""$$$$$rctj|sdStj|}tj|\}}|tj|vS)z Case-sensitive path existence check >>> sdist._cs_path_exists(__file__) True >>> sdist._cs_path_exists(__file__.upper()) False F)r]r^existsabspathsplitlistdir)fspathrs directoryfilenames r_cs_path_existszsdist._cs_path_existss_w~~f%% 5'//&)) gmmG44 82:i0000rc|j|jjg}|D]}t|trj|}d}|D]5}||rd}|j|n6|s+|dd |z||r|j||d|zdS)NFTz,standard file not found: should have one of z, zstandard file '%s' not found) READMESrX script_name isinstancetupleryrOrrjoin)r$ standardsfnaltsgot_its rrjzsdist._add_defaults_standardss\4#4#@A  C CB"e$$ CB++B//!% ,,R000 /IIL"iioo.///''++CM((,,,,II4==99E M  ' ' ' ' ( (rcR|d}|jr,|j||jD]D\}}}}|D]:}|jtj ||;EdS)Nbuild_py) get_finalized_commandrXhas_pure_modulesrOrget_source_files data_filesrr]r^r)r$rpkgsrc_dir build_dir filenamesrxs rrlzsdist._add_defaults_pythons--j99   - - / / > M !:!:!>!,,4 M003334 4 4 4 4rc|jrC|d}|j|dSdS)N build_ext)rXhas_ext_modulesrrOrr)r$rs rrnzsdist._add_defaults_ext5s^   , , . . ?22;??I M !;!;!=!= > > > > > ? ?rc|jrC|d}|j|dSdS)N build_clib)rXhas_c_librariesrrOrr)r$rs rrozsdist._add_defaults_c_libs:sa   , , . . @33LAAJ M !!> ? ? ? ? ? @ @rc|jrC|d}|j|dSdS)N build_scripts)rX has_scriptsrrOrr)r$rs rrpzsdist._add_defaults_scripts?sa   ( ( * * C 66GGM M !?!?!A!A B B B B B C Crc tjd|jt|jdddddd} |}|n` |j|nC#ttf$r/}| d|j |j |fzYd}~nd}~wwxYww | dS#| wxYw)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'r9)strip_comments skip_blanks join_lines lstrip_ws rstrip_ws collapse_joinTNz%s, line %d: %s) r infor;r readlinerOprocess_template_liner ValueErrorrrx current_lineclose)r$r;linemsgs rrezsdist.read_templateDs( 14=AAADM!'(A*+---  9((**<9M77====/ ;999II/83D3;3H36388999999999 9 NN     HNN    s5CA+*C+B+<%B&!C&B++CCc|d}|j}|jd|j|jd|t jdkrd}nd}gd}d|d d |d |d }|j|d dS)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(^|z)(|z).*r9)is_regex) rrX get_fullnamerOexclude_pattern build_basesysplatformr)r$rbase_dirsepsvcs_dirsvcs_ptrns rrfzsdist.prune_file_listas**733$1133 %%d53C%DDD %%d8%<<< <7 " "DDD*.$$0B0B0B0BDDDI %%h%;;;;;rc|rtjd|jzdS|jjdd}|dd|tj |j|fd|jzdS)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'. z5not writing to manually maintained manifest file '%s'Nrz*# file GENERATED by distutils, do NOT editzwriting manifest file '%s') r`r rr<rOrinsertexecuter write_file)r$contents rrgzsdist.write_manifestys  * * , ,  H*,0M: ; ; ; F-%aaa(qFGGG Y)DM7+C1DMA C C C C Crctj|jsdSt |j} |}|n#|wxYw|dkS)NFz+# file GENERATED by distutils, do NOT edit )r]r^r_r<openrr)r$fp first_lines rr`z sdist._manifest_is_not_generatedsmw~~dm,, 5 $-  J HHJJJJBHHJJJJKKKs A%%A;c,tjd|jt|j5}|D]H}|}|ds|s.|j|I ddddS#1swxYwYdS)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'#N)r rr<rstrip startswithrOr)r$r<rs rrazsdist.read_manifests -t}=== $-  +H  + +zz||??3''t $$T****  + + + + + + + + + + + + + + + + + + +sA B  B B c(||tj|||jt t drd}d|z}nd}d|z}|st jdnt j||D]o}t j |st jd|7t j ||}| ||| p|j j|dS) 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 %s...Nzcopying files to %s...z)no files to distribute -- empty manifest?z#'%s' not a regular file -- skipping)r)mkpathr create_treerhasattrr]r rrr^r_r copy_filerXmetadatawrite_pkg_info)r$rrrrfiledests rmake_release_treezsdist.make_release_trees HXudlCCCC 2v   6D.9CCD*X5C  H@ A A A A HSMMM 6 6D7>>$'' 6>EEEEw||Hd33tT5555 "11(;;;;;rc|j}tj|j|}|||jjg}d|j vrJ|j |j |j d|j D]]}| ||||j|j}| ||jj dd|f^||_|jst'j||jdSdS)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)rrCrDr rN)rXrr]r^rrArrOrrrpopindex make_archiverCrD dist_filesrBr@r remove_treer)r$r base_namerBfmtrs rrSzsdist.make_distributionsE$1133GLL99  x)<=== DL L   0 01C1CE1J1J K K L L L< E EC$$Yh+/:TZ%IID   & & &   ( / /"d0C D D D D*~ A  4< @ @ @ @ @ @ A Arc|jS)zzReturn the list of archive files created when the command was run, or None if the command hasn't run yet. )rBr#s rget_archive_fileszsdist.get_archive_filess !!r)#__name__ __module__ __qualname__ descriptionr% user_optionsboolean_optionsr help_options negative_opt sub_commandsr{rErLrUr[rRrd staticmethodryrjrkrlrmrnrorprerfrgr`rarrSrrrr r $sJK### % % % LN666O  .  > L $2 '**L/01L4G.### !!!,&&&P%%%,11\1 CCC*((( FFF 444"??? @@@ CCC :<<<0 C C C L L L + + +(<(<(rs>LL """"""""""""((((((''''''''''''IIIIIIII : : :J"J"J"J"J"GJ"J"J"J"J"r