ó {fc@sdZdZddlZddlZddlZddlmZddlmZddlm Z ddl m Z m Z m Z mZddlmZdd lmZmZmZdd lmZdd l mZdd lmZd „Zde fd„ƒYZdS(sadistutils.command.sdist Implements the Distutils 'sdist' command (create a source distribution).s$Id$iÿÿÿÿN(tglob(twarn(tCommand(tdir_utiltdep_utilt file_utilt archive_util(tTextFile(tDistutilsPlatformErrortDistutilsOptionErrortDistutilsTemplateError(tFileList(tlog(t convert_pathcCs€ddlm}ddlm}g}x6|jƒD](}|jd|d||dfƒq3W|jƒ||ƒjdƒdS(soPrint all possible values for the 'formats' option (used by the "--help-formats" command-line option). iÿÿÿÿ(t FancyGetopt(tARCHIVE_FORMATSsformats=is.List of available source distribution formats:N( tdistutils.fancy_getoptRtdistutils.archive_utilRtkeystappendtNonetsortt print_help(RRtformatstformat((s//usr/lib64/python2.7/distutils/command/sdist.pyt show_formatss  tsdistcBs6eZdZd„Zd<d=d?d@dAdBdCdDdEddddfdFdGdHdIgZdd ddddgZd'd>d(efgZidd 6d d6Z id)d*6d+d,6Z d-efgZ d.„Z d/„Z d0„Zd1„Zd2„Zd3„Zd4„Zd5„Zd6„Zd7„Zd8„Zd9„Zd:„Zd;„ZRS(Js6create a source distribution (tarball, zip file, etc.)cCs|jS(sYCallable used for the check sub-command. Placed here so user_options can view it(tmetadata_check(tself((s//usr/lib64/python2.7/distutils/command/sdist.pytchecking_metadata(ss template=tts5name of manifest template file [default: MANIFEST.in]s manifest=tms)name of manifest file [default: MANIFEST]s use-defaultssRinclude the default file set in the manifest [default; disable with --no-defaults]s no-defaultss"don't include the default file settprunes‰specifically exclude files/directories that should not be distributed (build tree, RCS/CVS dirs, etc.) [default; disable with --no-prune]sno-prunes$don't automatically exclude anythings manifest-onlytosEjust regenerate the manifest and then stop (implies --force-manifest)sforce-manifesttfskforcibly regenerate the manifest and carry on as usual. Deprecated: now the manifest is always regenerated.sformats=s6formats for source distribution (comma-separated list)s keep-temptks1keep the distribution tree around after creating sarchive file(s)s dist-dir=tdsFdirectory to put the source distribution archive(s) in [default: dist]smetadata-checks[Ensure that all required elements of meta-data are supplied. Warn if any missing. [default]sowner=tus@Owner name used when creating a tar file [default: current user]sgroup=tgsAGroup name used when creating a tar file [default: current group]s help-formatss#list available distribution formatstgztartposixtziptnttcheckcCsyd|_d|_d|_d|_d|_d|_d|_d|_d|_ d|_ d|_ d|_ d|_ dS(Nii(Rttemplatetmanifestt use_defaultsR t manifest_onlytforce_manifestRt keep_temptdist_dirt archive_filesRtownertgroup(R((s//usr/lib64/python2.7/distutils/command/sdist.pytinitialize_optionsfs            cCsÞ|jdkrd|_n|jdkr6d|_n|jdƒ|jdkr—y|jtjg|_Wq—tk r“t ddtj‚q—Xnt j |jƒ}|r¿t d|‚n|j dkrÚd|_ ndS(NtMANIFESTs MANIFEST.inRs.don't know how to create source distributions son platform %ssunknown archive format '%s'tdist(R-RR,tensure_string_listRtdefault_formattostnametKeyErrorRRtcheck_archive_formatsR R2(Rt bad_format((s//usr/lib64/python2.7/distutils/command/sdist.pytfinalize_options}s$     cCsUtƒ|_x!|jƒD]}|j|ƒqW|jƒ|jrGdS|jƒdS(N(R tfilelisttget_sub_commandst run_commandt get_file_listR/tmake_distribution(Rtcmd_name((s//usr/lib64/python2.7/distutils/command/sdist.pytrun”s   cCs7tdtƒ|jjdƒ}|jƒ|jƒdS(sDeprecated API.sadistutils.command.sdist.check_metadata is deprecated, use the check command insteadR+N(RtPendingDeprecationWarningt distributiontget_command_objtensure_finalizedRG(RR+((s//usr/lib64/python2.7/distutils/command/sdist.pytcheck_metadataªs   cCsåtjj|jƒ}| rP|jƒrP|jƒ|jjƒ|jjƒdS|sq|j dd|jƒn|jj ƒ|j r”|j ƒn|r§|j ƒn|jr½|jƒn|jjƒ|jjƒ|jƒdS(sCFigure 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. Ns&manifest template '%s' does not exist s(using default file list)(R;tpathtisfileR,t_manifest_is_not_generatedt read_manifestRARtremove_duplicatesRtfindallR.t add_defaultst read_templateR tprune_file_listtwrite_manifest(Rttemplate_exists((s//usr/lib64/python2.7/distutils/command/sdist.pyRD²s(            cCsd|jjg}xÅ|D]½}t|tƒr |}d}x:|D]2}tjj|ƒrAd}|jj|ƒPqAqAW|sÖ|j dt j |dƒƒqÖqtjj|ƒrÅ|jj|ƒq|j d|ƒqWdd g}xB|D]:}t tjj t|ƒƒ}|rí|jj|ƒqíqíW|jd ƒ}|jjƒrb|jj|jƒƒnxM|jD]B\} } } } x-| D]%} |jjtjj | | ƒƒq…WqlW|jjƒrlx¨|jjD]—}t|tƒrt|ƒ}tjj |ƒre|jj|ƒqeqÎ|\}} x?| D]7}t|ƒ}tjj |ƒr*|jj|ƒq*q*WqÎWn|jjƒr£|jd ƒ}|jj|jƒƒn|jjƒrÚ|jd ƒ}|jj|jƒƒn|jjƒr|jd ƒ}|jj|jƒƒndS(s9Add 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. tREADMEs README.txtiis,standard file not found: should have one of s, sstandard file '%s' not founds test/test*.pys setup.cfgtbuild_pyt build_extt build_clibt build_scriptsN(RXs README.txt(RIt script_namet isinstancettupleR;RMtexistsRARRtstringtjointfilterRNRtextendtget_finalized_commandthas_pure_modulestget_source_filest data_filesthas_data_fileststrR thas_ext_modulesthas_c_librariest has_scripts(Rt standardstfntaltstgot_ittoptionaltpatterntfilesRYtpkgtsrc_dirt build_dirt filenamestfilenametitemtdirnameR"RZR[R\((s//usr/lib64/python2.7/distutils/command/sdist.pyRSÚs^      '    cCsÏtjd|jƒt|jddddddddddddƒ}zwxp|jƒ}|d krhPny|jj|ƒWqLtt fk r·}|j d |j |j |fƒqLXqLWWd |j ƒXd S( sÈRead 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. sreading manifest template '%s'tstrip_commentsit skip_blankst join_linest lstrip_wst rstrip_wst collapse_joins%s, line %d: %sN(R tinfoR,RtreadlineRRAtprocess_template_lineR t ValueErrorRRyt current_linetclose(RR,tlinetmsg((s//usr/lib64/python2.7/distutils/command/sdist.pyRT,s(    cCs¼|jdƒ}|jjƒ}|jjdd|jƒ|jjdd|ƒtjdkred}nd}dddd d d d g}d |dj |ƒ|f}|jj|ddƒdS(svPrune 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 tbuildtprefixtwin32s/|\\t/tRCStCVSs\.svns\.hgs\.gits\.bzrt_darcss(^|%s)(%s)(%s).*t|tis_regexiN( ReRIt get_fullnameRAtexclude_patternRt build_basetsystplatformRb(RRŠtbase_dirtsepstvcs_dirstvcs_ptrn((s//usr/lib64/python2.7/distutils/command/sdist.pyRUMs  cCsk|jƒr$tjd|jƒdS|jj}|jddƒ|jtj |j|fd|jƒdS(s²Write the file list in 'self.filelist' (presumably as filled in by 'add_defaults()' and 'read_template()') to the manifest file named by 'self.manifest'. s5not writing to manually maintained manifest file '%s'Nis*# file GENERATED by distutils, do NOT editswriting manifest file '%s'( ROR R‚R-RARttinserttexecuteRt write_file(Rtcontent((s//usr/lib64/python2.7/distutils/command/sdist.pyRVgs    cCsStjj|jƒstSt|jdƒ}z|jƒ}Wd|jƒX|dkS(NtrUs+# file GENERATED by distutils, do NOT edit (R;RMRNR-tFalsetopenRƒR‡(Rtfpt first_line((s//usr/lib64/python2.7/distutils/command/sdist.pyROvs cCsytjd|jƒt|jƒ}xF|D]>}|jƒ}|jdƒs)| rWq)n|jj|ƒq)W|jƒdS(sªRead 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. sreading manifest file '%s't#N( R R‚R-R¢tstript startswithRARR‡(RR-Rˆ((s//usr/lib64/python2.7/distutils/command/sdist.pyRP‚s  cCsô|j|ƒtj||d|jƒttdƒrHd}d|}nd}d|}|sntjdƒn tj |ƒx_|D]W}tj j |ƒs®tjd|ƒq‚tj j ||ƒ}|j ||d|ƒq‚W|jjj|ƒdS( sÆCreate 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. tdry_runtlinkthardsmaking hard links in %s...scopying files to %s...s)no files to distribute -- empty manifest?s#'%s' not a regular file -- skippingN(tmkpathRt create_treeR¨thasattrR;RR RR‚RMRNRbt copy_fileRItmetadatatwrite_pkg_info(RR˜RtR©R‰tfiletdest((s//usr/lib64/python2.7/distutils/command/sdist.pytmake_release_tree‘s      c Cs|jjƒ}tjj|j|ƒ}|j||jjƒg}d|j kr}|j j |j j |j j dƒƒƒnxd|j D]Y}|j ||d|d|jd|jƒ}|j |ƒ|jjj dd|fƒq‡W||_|jstj|d|jƒndS( s¯Create 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()'. ttarR˜R4R5RtR¨N(RIR“R;RMRbR2R³RARtRRtpoptindext make_archiveR4R5t dist_filesR3R1Rt remove_treeR¨(RR˜t base_nameR3tfmtR±((s//usr/lib64/python2.7/distutils/command/sdist.pyRE»s +    cCs|jS(szReturn the list of archive files created when the command was run, or None if the command hasn't run yet. (R3(R((s//usr/lib64/python2.7/distutils/command/sdist.pytget_archive_filesÙs(s template=Rs5name of manifest template file [default: MANIFEST.in](s manifest=Rs)name of manifest file [default: MANIFEST]N(s use-defaultsNsRinclude the default file set in the manifest [default; disable with --no-defaults](s no-defaultsNs"don't include the default file set(R Ns‰specifically exclude files/directories that should not be distributed (build tree, RCS/CVS dirs, etc.) [default; disable with --no-prune](sno-pruneNs$don't automatically exclude anything(s manifest-onlyR!sEjust regenerate the manifest and then stop (implies --force-manifest)(sforce-manifestR"skforcibly regenerate the manifest and carry on as usual. Deprecated: now the manifest is always regenerated.(sformats=Ns6formats for source distribution (comma-separated list)(s dist-dir=R$sFdirectory to put the source distribution archive(s) in [default: dist](smetadata-checkNs[Ensure that all required elements of meta-data are supplied. Warn if any missing. [default](sowner=R%s@Owner name used when creating a tar file [default: current user](sgroup=R&sAGroup name used when creating a tar file [default: current group](t__name__t __module__t descriptionRRt user_optionstboolean_optionsRt help_optionst negative_optR:t sub_commandsR6R@RGRLRDRSRTRURVRORPR³RER½(((s//usr/lib64/python2.7/distutils/command/sdist.pyR$sn            ( R !    * (t__doc__t __revision__R;RaR–RtwarningsRtdistutils.coreRt distutilsRRRRtdistutils.text_fileRtdistutils.errorsRR R tdistutils.filelistR R tdistutils.utilR RR(((s//usr/lib64/python2.7/distutils/command/sdist.pyts   "