Spade
Mini Shell
�
t�fc@sdZdZddlZddlZddlZddlmZddlmZddlm Z ddl
mZmZm
Z
mZddlmZdd lmZmZmZdd
lmZddl
mZddlmZd
�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_utiltarchive_util(tTextFile(tDistutilsPlatformErrortDistutilsOptionErrortDistutilsTemplateError(tFileList(tlog(tconvert_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����(tFancyGetopt(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.pytshow_formatss
tsdistcBs6eZdZd�Zd<d=d?d@dAdBdCdDdEddddfdFdGdHdIgZddddddgZd'd>d(efgZidd
6dd6Z id)d*6d+d,6Z
d-efgZd.�Zd/�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]suse-defaultssRinclude the default file
set in the manifest [default; disable with
--no-defaults]sno-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]shelp-formatss#list available distribution
formatstgztartposixtziptnttcheckcCsyd|_d|_d|_d|_d|_d|_d|_d|_d|_ d|_
d|_d|_d|_
dS(Nii(Rttemplatetmanifesttuse_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�td|�n|j
dkr�d|_
ndS(NtMANIFESTsMANIFEST.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(Rtfilelisttget_sub_commandstrun_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(RtPendingDeprecationWarningtdistributiontget_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
�|jr�|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.tadd_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]:}ttjj
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(RItscript_namet
isinstancettupleR;RMtexistsRARRtstringtjointfilterRNRtextendtget_finalized_commandthas_pure_modulestget_source_filest
data_filesthas_data_fileststrR
thas_ext_modulesthas_c_librariesthas_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�}zvxo|j�}|d
krhPny|jj|�WqLtt fk
r�}|j
d |j|j|f�qLXqLWd
|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_commentsitskip_blankst
join_linest lstrip_wst rstrip_wst
collapse_joins%s, line %d:
%sN(RtinfoR,RtreadlineRRAtprocess_template_lineR
t
ValueErrorRRytcurrent_linetclose(RR,tlinetmsg((s//usr/lib64/python2.7/distutils/command/sdist.pyRT,s( cCs�|jd�}|jj�}|jjdd|j�|jjdd|�tjdkred}nd}dddd d
ddg}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(
ReRItget_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'(
RORR�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.pyROvscCsytjd|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( RR�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(tmkpathRtcreate_treeR�thasattrR;RRRR�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 jd���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�RARtRRtpoptindextmake_archiveR4R5t
dist_filesR3R1Rtremove_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(suse-defaultsNsRinclude the default
file set in the manifest [default; disable with
--no-defaults](sno-defaultsNs"don't include the default file
set(spruneNs�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__tdescriptionRRtuser_optionstboolean_optionsRthelp_optionstnegative_optR:tsub_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.filelistRRtdistutils.utilR
RR(((s//usr/lib64/python2.7/distutils/command/sdist.pyt<module>s"