2000-02-17 23:56:15 +00:00
|
|
|
"""distutils.command.sdist
|
|
|
|
|
|
|
|
Implements the Distutils 'sdist' command (create a source distribution)."""
|
|
|
|
|
|
|
|
# created 1999/09/22, Greg Ward
|
|
|
|
|
2000-03-02 01:49:45 +00:00
|
|
|
__revision__ = "$Id$"
|
2000-02-17 23:56:15 +00:00
|
|
|
|
2000-07-30 01:05:02 +00:00
|
|
|
import sys, os, string
|
2000-02-17 23:56:15 +00:00
|
|
|
from types import *
|
|
|
|
from glob import glob
|
|
|
|
from distutils.core import Command
|
2000-08-05 01:31:54 +00:00
|
|
|
from distutils import dir_util, dep_util, file_util, archive_util
|
2000-02-17 23:56:15 +00:00
|
|
|
from distutils.text_file import TextFile
|
2000-07-30 01:47:16 +00:00
|
|
|
from distutils.errors import *
|
2000-07-30 01:05:02 +00:00
|
|
|
from distutils.filelist import FileList
|
2000-02-17 23:56:15 +00:00
|
|
|
|
|
|
|
|
2000-06-24 01:23:37 +00:00
|
|
|
def show_formats ():
|
|
|
|
"""Print all possible values for the 'formats' option (used by
|
|
|
|
the "--help-formats" command-line option).
|
|
|
|
"""
|
|
|
|
from distutils.fancy_getopt import FancyGetopt
|
|
|
|
from distutils.archive_util import ARCHIVE_FORMATS
|
|
|
|
formats=[]
|
|
|
|
for format in ARCHIVE_FORMATS.keys():
|
|
|
|
formats.append(("formats=" + format, None,
|
|
|
|
ARCHIVE_FORMATS[format][2]))
|
|
|
|
formats.sort()
|
|
|
|
pretty_printer = FancyGetopt(formats)
|
|
|
|
pretty_printer.print_help(
|
|
|
|
"List of available source distribution formats:")
|
|
|
|
|
|
|
|
|
2000-02-18 00:13:53 +00:00
|
|
|
class sdist (Command):
|
2000-02-17 23:56:15 +00:00
|
|
|
|
|
|
|
description = "create a source distribution (tarball, zip file, etc.)"
|
|
|
|
|
2000-02-18 00:25:39 +00:00
|
|
|
user_options = [
|
|
|
|
('template=', 't',
|
|
|
|
"name of manifest template file [default: MANIFEST.in]"),
|
|
|
|
('manifest=', 'm',
|
|
|
|
"name of manifest file [default: MANIFEST]"),
|
|
|
|
('use-defaults', None,
|
|
|
|
"include the default file set in the manifest "
|
|
|
|
"[default; disable with --no-defaults]"),
|
2000-06-29 02:06:29 +00:00
|
|
|
('no-defaults', None,
|
|
|
|
"don't include the default file set"),
|
|
|
|
('prune', None,
|
|
|
|
"specifically exclude files/directories that should not be "
|
|
|
|
"distributed (build tree, RCS/CVS dirs, etc.) "
|
|
|
|
"[default; disable with --no-prune]"),
|
|
|
|
('no-prune', None,
|
|
|
|
"don't automatically exclude anything"),
|
2000-04-26 01:14:33 +00:00
|
|
|
('manifest-only', 'o',
|
2000-06-08 00:46:45 +00:00
|
|
|
"just regenerate the manifest and then stop "
|
|
|
|
"(implies --force-manifest)"),
|
2000-04-26 01:14:33 +00:00
|
|
|
('force-manifest', 'f',
|
2000-02-18 00:25:39 +00:00
|
|
|
"forcibly regenerate the manifest and carry on as usual"),
|
|
|
|
('formats=', None,
|
2000-06-24 00:23:20 +00:00
|
|
|
"formats for source distribution (comma-separated list)"),
|
2000-09-25 01:51:01 +00:00
|
|
|
('keep-temp', 'k',
|
2000-02-18 00:25:39 +00:00
|
|
|
"keep the distribution tree around after creating " +
|
|
|
|
"archive file(s)"),
|
2000-07-05 03:06:46 +00:00
|
|
|
('dist-dir=', 'd',
|
|
|
|
"directory to put the source distribution archive(s) in "
|
|
|
|
"[default: dist]"),
|
2000-02-18 00:25:39 +00:00
|
|
|
]
|
2000-06-08 00:14:18 +00:00
|
|
|
|
2000-09-25 01:41:15 +00:00
|
|
|
boolean_options = ['use-defaults', 'prune',
|
|
|
|
'manifest-only', 'force-manifest',
|
2000-09-25 01:51:01 +00:00
|
|
|
'keep-temp']
|
2000-06-08 00:14:18 +00:00
|
|
|
|
2000-06-07 03:00:06 +00:00
|
|
|
help_options = [
|
|
|
|
('help-formats', None,
|
2000-06-24 00:23:20 +00:00
|
|
|
"list available distribution formats", show_formats),
|
2000-06-07 03:00:06 +00:00
|
|
|
]
|
|
|
|
|
2000-06-29 02:06:29 +00:00
|
|
|
negative_opt = {'no-defaults': 'use-defaults',
|
|
|
|
'no-prune': 'prune' }
|
2000-02-17 23:56:15 +00:00
|
|
|
|
|
|
|
default_format = { 'posix': 'gztar',
|
|
|
|
'nt': 'zip' }
|
|
|
|
|
2000-02-18 00:35:22 +00:00
|
|
|
def initialize_options (self):
|
2000-02-17 23:56:15 +00:00
|
|
|
# 'template' and 'manifest' are, respectively, the names of
|
|
|
|
# the manifest template and manifest file.
|
|
|
|
self.template = None
|
|
|
|
self.manifest = None
|
|
|
|
|
|
|
|
# 'use_defaults': if true, we will include the default file set
|
|
|
|
# in the manifest
|
|
|
|
self.use_defaults = 1
|
2000-06-29 02:06:29 +00:00
|
|
|
self.prune = 1
|
2000-02-17 23:56:15 +00:00
|
|
|
|
|
|
|
self.manifest_only = 0
|
|
|
|
self.force_manifest = 0
|
|
|
|
|
|
|
|
self.formats = None
|
2000-09-25 01:51:01 +00:00
|
|
|
self.keep_temp = 0
|
2000-07-05 03:06:46 +00:00
|
|
|
self.dist_dir = None
|
2000-02-17 23:56:15 +00:00
|
|
|
|
2000-06-01 01:10:56 +00:00
|
|
|
self.archive_files = None
|
|
|
|
|
2000-02-17 23:56:15 +00:00
|
|
|
|
2000-02-18 00:35:22 +00:00
|
|
|
def finalize_options (self):
|
2000-02-17 23:56:15 +00:00
|
|
|
if self.manifest is None:
|
|
|
|
self.manifest = "MANIFEST"
|
|
|
|
if self.template is None:
|
|
|
|
self.template = "MANIFEST.in"
|
|
|
|
|
2000-06-04 15:12:51 +00:00
|
|
|
self.ensure_string_list('formats')
|
2000-02-17 23:56:15 +00:00
|
|
|
if self.formats is None:
|
|
|
|
try:
|
|
|
|
self.formats = [self.default_format[os.name]]
|
|
|
|
except KeyError:
|
|
|
|
raise DistutilsPlatformError, \
|
2000-03-31 02:50:04 +00:00
|
|
|
"don't know how to create source distributions " + \
|
|
|
|
"on platform %s" % os.name
|
2000-02-17 23:56:15 +00:00
|
|
|
|
2000-08-05 01:31:54 +00:00
|
|
|
bad_format = archive_util.check_archive_formats (self.formats)
|
2000-04-22 03:11:55 +00:00
|
|
|
if bad_format:
|
|
|
|
raise DistutilsOptionError, \
|
|
|
|
"unknown archive format '%s'" % bad_format
|
|
|
|
|
2000-07-05 03:06:46 +00:00
|
|
|
if self.dist_dir is None:
|
|
|
|
self.dist_dir = "dist"
|
|
|
|
|
2000-02-17 23:56:15 +00:00
|
|
|
|
|
|
|
def run (self):
|
|
|
|
|
2000-07-30 01:30:31 +00:00
|
|
|
# 'filelist' contains the list of files that will make up the
|
|
|
|
# manifest
|
|
|
|
self.filelist = FileList()
|
2000-02-17 23:56:15 +00:00
|
|
|
|
|
|
|
# Ensure that all required meta-data is given; warn if not (but
|
|
|
|
# don't die, it's not *that* serious!)
|
|
|
|
self.check_metadata ()
|
|
|
|
|
|
|
|
# Do whatever it takes to get the list of files to process
|
|
|
|
# (process the manifest template, read an existing manifest,
|
2000-07-30 01:30:31 +00:00
|
|
|
# whatever). File list is accumulated in 'self.filelist'.
|
2000-02-17 23:56:15 +00:00
|
|
|
self.get_file_list ()
|
|
|
|
|
|
|
|
# If user just wanted us to regenerate the manifest, stop now.
|
|
|
|
if self.manifest_only:
|
|
|
|
return
|
|
|
|
|
|
|
|
# Otherwise, go ahead and create the source distribution tarball,
|
|
|
|
# or zipfile, or whatever.
|
|
|
|
self.make_distribution ()
|
|
|
|
|
|
|
|
|
|
|
|
def check_metadata (self):
|
2000-06-08 00:46:45 +00:00
|
|
|
"""Ensure that all required elements of meta-data (name, version,
|
|
|
|
URL, (author and author_email) or (maintainer and
|
|
|
|
maintainer_email)) are supplied by the Distribution object; warn if
|
|
|
|
any are missing.
|
|
|
|
"""
|
2000-04-21 04:37:12 +00:00
|
|
|
metadata = self.distribution.metadata
|
2000-02-17 23:56:15 +00:00
|
|
|
|
|
|
|
missing = []
|
|
|
|
for attr in ('name', 'version', 'url'):
|
2000-04-21 04:37:12 +00:00
|
|
|
if not (hasattr (metadata, attr) and getattr (metadata, attr)):
|
2000-02-17 23:56:15 +00:00
|
|
|
missing.append (attr)
|
|
|
|
|
|
|
|
if missing:
|
|
|
|
self.warn ("missing required meta-data: " +
|
|
|
|
string.join (missing, ", "))
|
|
|
|
|
2000-04-21 04:37:12 +00:00
|
|
|
if metadata.author:
|
|
|
|
if not metadata.author_email:
|
2000-02-17 23:56:15 +00:00
|
|
|
self.warn ("missing meta-data: if 'author' supplied, " +
|
|
|
|
"'author_email' must be supplied too")
|
2000-04-21 04:37:12 +00:00
|
|
|
elif metadata.maintainer:
|
|
|
|
if not metadata.maintainer_email:
|
2000-02-17 23:56:15 +00:00
|
|
|
self.warn ("missing meta-data: if 'maintainer' supplied, " +
|
|
|
|
"'maintainer_email' must be supplied too")
|
|
|
|
else:
|
|
|
|
self.warn ("missing meta-data: either (author and author_email) " +
|
|
|
|
"or (maintainer and maintainer_email) " +
|
|
|
|
"must be supplied")
|
|
|
|
|
|
|
|
# check_metadata ()
|
|
|
|
|
|
|
|
|
|
|
|
def get_file_list (self):
|
|
|
|
"""Figure out the list of files to include in the source
|
2000-07-30 01:30:31 +00:00
|
|
|
distribution, and put it in 'self.filelist'. This might involve
|
2000-06-08 00:24:01 +00:00
|
|
|
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 and the state of the filesystem.
|
|
|
|
"""
|
2000-06-21 03:29:57 +00:00
|
|
|
|
|
|
|
# If we have a manifest template, see if it's newer than the
|
|
|
|
# manifest; if so, we'll regenerate the manifest.
|
2000-07-30 01:30:31 +00:00
|
|
|
template_exists = os.path.isfile(self.template)
|
2000-02-17 23:56:15 +00:00
|
|
|
if template_exists:
|
2000-08-05 01:31:54 +00:00
|
|
|
template_newer = dep_util.newer(self.template, self.manifest)
|
2000-02-17 23:56:15 +00:00
|
|
|
|
2000-06-21 03:29:57 +00:00
|
|
|
# The contents of the manifest file almost certainly depend on the
|
|
|
|
# setup script as well as the manifest template -- so if the setup
|
|
|
|
# script is newer than the manifest, we'll regenerate the manifest
|
|
|
|
# from the template. (Well, not quite: if we already have a
|
|
|
|
# manifest, but there's no template -- which will happen if the
|
|
|
|
# developer elects to generate a manifest some other way -- then we
|
|
|
|
# can't regenerate the manifest, so we don't.)
|
2000-08-29 01:15:18 +00:00
|
|
|
self.debug_print("checking if %s newer than %s" %
|
|
|
|
(self.distribution.script_name, self.manifest))
|
|
|
|
setup_newer = dep_util.newer(self.distribution.script_name,
|
|
|
|
self.manifest)
|
2000-06-21 03:29:57 +00:00
|
|
|
|
|
|
|
# cases:
|
|
|
|
# 1) no manifest, template exists: generate manifest
|
|
|
|
# (covered by 2a: no manifest == template newer)
|
|
|
|
# 2) manifest & template exist:
|
|
|
|
# 2a) template or setup script newer than manifest:
|
|
|
|
# regenerate manifest
|
|
|
|
# 2b) manifest newer than both:
|
|
|
|
# do nothing (unless --force or --manifest-only)
|
|
|
|
# 3) manifest exists, no template:
|
|
|
|
# do nothing (unless --force or --manifest-only)
|
|
|
|
# 4) no manifest, no template: generate w/ warning ("defaults only")
|
|
|
|
|
2000-09-06 02:08:24 +00:00
|
|
|
manifest_outofdate = (template_exists and
|
|
|
|
(template_newer or setup_newer))
|
|
|
|
force_regen = self.force_manifest or self.manifest_only
|
|
|
|
manifest_exists = os.path.isfile(self.manifest)
|
|
|
|
neither_exists = (not template_exists and not manifest_exists)
|
2000-02-17 23:56:15 +00:00
|
|
|
|
2000-09-06 02:08:24 +00:00
|
|
|
# Regenerate the manifest if necessary (or if explicitly told to)
|
|
|
|
if manifest_outofdate or neither_exists or force_regen:
|
2000-02-17 23:56:15 +00:00
|
|
|
if not template_exists:
|
2000-07-30 01:30:31 +00:00
|
|
|
self.warn(("manifest template '%s' does not exist " +
|
|
|
|
"(using default file list)") %
|
|
|
|
self.template)
|
2000-02-17 23:56:15 +00:00
|
|
|
|
2000-07-30 01:47:16 +00:00
|
|
|
self.filelist.findall()
|
|
|
|
|
2000-02-17 23:56:15 +00:00
|
|
|
# Add default file set to 'files'
|
|
|
|
if self.use_defaults:
|
2000-07-30 01:30:31 +00:00
|
|
|
self.add_defaults()
|
2000-02-17 23:56:15 +00:00
|
|
|
|
|
|
|
# Read manifest template if it exists
|
|
|
|
if template_exists:
|
2000-07-30 01:30:31 +00:00
|
|
|
self.read_template()
|
2000-02-17 23:56:15 +00:00
|
|
|
|
2000-06-29 02:06:29 +00:00
|
|
|
# Prune away any directories that don't belong in the source
|
|
|
|
# distribution
|
|
|
|
if self.prune:
|
|
|
|
self.prune_file_list()
|
2000-06-08 01:06:02 +00:00
|
|
|
|
2000-02-17 23:56:15 +00:00
|
|
|
# File list now complete -- sort it so that higher-level files
|
|
|
|
# come first
|
2000-07-30 01:30:31 +00:00
|
|
|
self.filelist.sort()
|
2000-02-17 23:56:15 +00:00
|
|
|
|
|
|
|
# Remove duplicates from the file list
|
2000-07-30 01:30:31 +00:00
|
|
|
self.filelist.remove_duplicates()
|
2000-02-17 23:56:15 +00:00
|
|
|
|
|
|
|
# And write complete file list (including default file set) to
|
|
|
|
# the manifest.
|
2000-07-30 01:30:31 +00:00
|
|
|
self.write_manifest()
|
2000-02-17 23:56:15 +00:00
|
|
|
|
|
|
|
# Don't regenerate the manifest, just read it in.
|
|
|
|
else:
|
2000-07-30 01:30:31 +00:00
|
|
|
self.read_manifest()
|
2000-02-17 23:56:15 +00:00
|
|
|
|
|
|
|
# get_file_list ()
|
|
|
|
|
|
|
|
|
2000-06-08 00:52:52 +00:00
|
|
|
def add_defaults (self):
|
2000-07-30 01:30:31 +00:00
|
|
|
"""Add all the default files to self.filelist:
|
2000-06-08 00:46:45 +00:00
|
|
|
- README or README.txt
|
|
|
|
- setup.py
|
|
|
|
- test/test*.py
|
|
|
|
- all pure Python modules mentioned in setup script
|
|
|
|
- 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.
|
|
|
|
"""
|
2000-06-08 01:22:48 +00:00
|
|
|
|
2000-09-06 02:08:24 +00:00
|
|
|
standards = [('README', 'README.txt'), self.distribution.script_name]
|
2000-02-17 23:56:15 +00:00
|
|
|
for fn in standards:
|
|
|
|
if type (fn) is TupleType:
|
|
|
|
alts = fn
|
2000-02-24 03:17:43 +00:00
|
|
|
got_it = 0
|
2000-02-17 23:56:15 +00:00
|
|
|
for fn in alts:
|
|
|
|
if os.path.exists (fn):
|
|
|
|
got_it = 1
|
2000-07-30 01:30:31 +00:00
|
|
|
self.filelist.append (fn)
|
2000-02-17 23:56:15 +00:00
|
|
|
break
|
|
|
|
|
|
|
|
if not got_it:
|
|
|
|
self.warn ("standard file not found: should have one of " +
|
|
|
|
string.join (alts, ', '))
|
|
|
|
else:
|
|
|
|
if os.path.exists (fn):
|
2000-07-30 01:30:31 +00:00
|
|
|
self.filelist.append (fn)
|
2000-02-17 23:56:15 +00:00
|
|
|
else:
|
|
|
|
self.warn ("standard file '%s' not found" % fn)
|
|
|
|
|
2000-06-08 01:22:48 +00:00
|
|
|
optional = ['test/test*.py', 'setup.cfg']
|
2000-02-17 23:56:15 +00:00
|
|
|
for pattern in optional:
|
|
|
|
files = filter (os.path.isfile, glob (pattern))
|
|
|
|
if files:
|
2000-07-30 01:30:31 +00:00
|
|
|
self.filelist.extend (files)
|
2000-02-17 23:56:15 +00:00
|
|
|
|
2000-03-31 02:50:04 +00:00
|
|
|
if self.distribution.has_pure_modules():
|
2000-05-27 17:27:23 +00:00
|
|
|
build_py = self.get_finalized_command ('build_py')
|
2000-07-30 01:30:31 +00:00
|
|
|
self.filelist.extend (build_py.get_source_files ())
|
2000-02-17 23:56:15 +00:00
|
|
|
|
2000-03-31 02:50:04 +00:00
|
|
|
if self.distribution.has_ext_modules():
|
2000-05-27 17:27:23 +00:00
|
|
|
build_ext = self.get_finalized_command ('build_ext')
|
2000-07-30 01:30:31 +00:00
|
|
|
self.filelist.extend (build_ext.get_source_files ())
|
2000-04-09 03:51:40 +00:00
|
|
|
|
|
|
|
if self.distribution.has_c_libraries():
|
2000-05-27 17:27:23 +00:00
|
|
|
build_clib = self.get_finalized_command ('build_clib')
|
2000-07-30 01:30:31 +00:00
|
|
|
self.filelist.extend (build_clib.get_source_files ())
|
2000-02-17 23:56:15 +00:00
|
|
|
|
2000-06-08 00:52:52 +00:00
|
|
|
# add_defaults ()
|
|
|
|
|
2000-02-17 23:56:15 +00:00
|
|
|
|
|
|
|
def read_template (self):
|
2000-07-30 01:30:31 +00:00
|
|
|
|
2000-02-17 23:56:15 +00:00
|
|
|
"""Read and parse the manifest template file named by
|
2000-07-30 01:30:31 +00:00
|
|
|
'self.template' (usually "MANIFEST.in"). The parsing and
|
|
|
|
processing is done by 'self.filelist', which updates itself
|
|
|
|
accordingly.
|
2000-06-08 00:24:01 +00:00
|
|
|
"""
|
2000-06-08 00:08:14 +00:00
|
|
|
self.announce("reading manifest template '%s'" % self.template)
|
2000-02-17 23:56:15 +00:00
|
|
|
template = TextFile (self.template,
|
|
|
|
strip_comments=1,
|
|
|
|
skip_blanks=1,
|
|
|
|
join_lines=1,
|
|
|
|
lstrip_ws=1,
|
|
|
|
rstrip_ws=1,
|
2000-09-18 00:41:10 +00:00
|
|
|
collapse_join=1)
|
2000-02-17 23:56:15 +00:00
|
|
|
|
|
|
|
while 1:
|
|
|
|
line = template.readline()
|
|
|
|
if line is None: # end of file
|
|
|
|
break
|
|
|
|
|
2000-07-30 01:47:16 +00:00
|
|
|
try:
|
|
|
|
self.filelist.process_template_line(line)
|
|
|
|
except DistutilsTemplateError, msg:
|
|
|
|
self.warn("%s, line %d: %s" % (template.filename,
|
|
|
|
template.current_line,
|
|
|
|
msg))
|
2000-02-17 23:56:15 +00:00
|
|
|
|
2000-06-08 01:06:02 +00:00
|
|
|
# read_template ()
|
|
|
|
|
2000-05-27 03:03:23 +00:00
|
|
|
|
2000-06-08 01:06:02 +00:00
|
|
|
def prune_file_list (self):
|
|
|
|
"""Prune off branches that might slip into the file list as created
|
2000-06-29 02:06:29 +00:00
|
|
|
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"
|
2000-09-25 01:51:01 +00:00
|
|
|
previously with --keep-temp, or it aborted)
|
2000-06-29 02:06:29 +00:00
|
|
|
* any RCS or CVS directories
|
2000-06-08 01:06:02 +00:00
|
|
|
"""
|
|
|
|
build = self.get_finalized_command('build')
|
2000-05-27 03:03:23 +00:00
|
|
|
base_dir = self.distribution.get_fullname()
|
2000-06-08 00:08:14 +00:00
|
|
|
|
2000-07-30 01:30:31 +00:00
|
|
|
self.filelist.exclude_pattern(None, prefix=build.build_base)
|
|
|
|
self.filelist.exclude_pattern(None, prefix=base_dir)
|
|
|
|
self.filelist.exclude_pattern(r'/(RCS|CVS)/.*', is_regex=1)
|
2000-06-08 00:08:14 +00:00
|
|
|
|
|
|
|
|
2000-02-17 23:56:15 +00:00
|
|
|
def write_manifest (self):
|
2000-07-30 01:30:31 +00:00
|
|
|
"""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'.
|
2000-06-08 00:24:01 +00:00
|
|
|
"""
|
2000-08-05 01:31:54 +00:00
|
|
|
self.execute(file_util.write_file,
|
2000-07-30 01:30:31 +00:00
|
|
|
(self.manifest, self.filelist.files),
|
2000-06-08 00:08:14 +00:00
|
|
|
"writing manifest file '%s'" % self.manifest)
|
2000-02-17 23:56:15 +00:00
|
|
|
|
|
|
|
# write_manifest ()
|
|
|
|
|
|
|
|
|
|
|
|
def read_manifest (self):
|
2000-06-08 00:24:01 +00:00
|
|
|
"""Read the manifest file (named by 'self.manifest') and use it to
|
2000-07-30 01:30:31 +00:00
|
|
|
fill in 'self.filelist', the list of files to include in the source
|
2000-06-08 00:24:01 +00:00
|
|
|
distribution.
|
|
|
|
"""
|
2000-06-08 00:08:14 +00:00
|
|
|
self.announce("reading manifest file '%s'" % self.manifest)
|
2000-02-17 23:56:15 +00:00
|
|
|
manifest = open (self.manifest)
|
|
|
|
while 1:
|
|
|
|
line = manifest.readline ()
|
|
|
|
if line == '': # end of file
|
|
|
|
break
|
|
|
|
if line[-1] == '\n':
|
|
|
|
line = line[0:-1]
|
2000-07-30 01:30:31 +00:00
|
|
|
self.filelist.append (line)
|
2000-02-17 23:56:15 +00:00
|
|
|
|
|
|
|
# read_manifest ()
|
|
|
|
|
|
|
|
|
|
|
|
def make_release_tree (self, base_dir, files):
|
2000-06-08 00:46:45 +00:00
|
|
|
"""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.
|
|
|
|
"""
|
2000-03-31 02:50:04 +00:00
|
|
|
# Create all the directories under 'base_dir' necessary to
|
2000-09-06 02:18:59 +00:00
|
|
|
# put 'files' there; the 'mkpath()' is just so we don't die
|
|
|
|
# if the manifest happens to be empty.
|
|
|
|
self.mkpath(base_dir)
|
|
|
|
dir_util.create_tree(base_dir, files,
|
|
|
|
verbose=self.verbose, dry_run=self.dry_run)
|
2000-02-17 23:56:15 +00:00
|
|
|
|
|
|
|
# And walk over the list of files, either making a hard link (if
|
|
|
|
# os.link exists) to each one that doesn't already exist in its
|
|
|
|
# corresponding location under 'base_dir', or copying each file
|
|
|
|
# that's out-of-date in 'base_dir'. (Usually, all files will be
|
|
|
|
# out-of-date, because by default we blow away 'base_dir' when
|
|
|
|
# we're done making the distribution archives.)
|
|
|
|
|
2000-03-31 02:50:04 +00:00
|
|
|
if hasattr (os, 'link'): # can make hard links on this system
|
|
|
|
link = 'hard'
|
2000-02-17 23:56:15 +00:00
|
|
|
msg = "making hard links in %s..." % base_dir
|
2000-03-31 02:50:04 +00:00
|
|
|
else: # nope, have to copy
|
|
|
|
link = None
|
2000-02-17 23:56:15 +00:00
|
|
|
msg = "copying files to %s..." % base_dir
|
|
|
|
|
2000-09-06 02:18:59 +00:00
|
|
|
if not files:
|
|
|
|
self.warn("no files to distribute -- empty manifest?")
|
|
|
|
else:
|
|
|
|
self.announce (msg)
|
2000-02-17 23:56:15 +00:00
|
|
|
for file in files:
|
2000-09-06 02:18:59 +00:00
|
|
|
if not os.path.isfile(file):
|
|
|
|
self.warn("'%s' not a regular file -- skipping" % file)
|
|
|
|
else:
|
|
|
|
dest = os.path.join (base_dir, file)
|
|
|
|
self.copy_file (file, dest, link=link)
|
2000-02-17 23:56:15 +00:00
|
|
|
|
|
|
|
# make_release_tree ()
|
|
|
|
|
|
|
|
|
|
|
|
def make_distribution (self):
|
2000-06-08 00:46:45 +00:00
|
|
|
"""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
|
2000-09-25 01:51:01 +00:00
|
|
|
'self.keep_temp' is true). The list of archive files created is
|
2000-06-08 00:46:45 +00:00
|
|
|
stored so it can be retrieved later by 'get_archive_files()'.
|
|
|
|
"""
|
2000-03-31 02:50:04 +00:00
|
|
|
# Don't warn about missing meta-data here -- should be (and is!)
|
|
|
|
# done elsewhere.
|
2000-04-22 02:51:25 +00:00
|
|
|
base_dir = self.distribution.get_fullname()
|
2000-07-05 03:06:46 +00:00
|
|
|
base_name = os.path.join(self.dist_dir, base_dir)
|
2000-02-17 23:56:15 +00:00
|
|
|
|
2000-07-30 01:30:31 +00:00
|
|
|
self.make_release_tree (base_dir, self.filelist.files)
|
2000-06-01 01:10:56 +00:00
|
|
|
archive_files = [] # remember names of files we create
|
2000-02-17 23:56:15 +00:00
|
|
|
for fmt in self.formats:
|
2000-07-05 03:06:46 +00:00
|
|
|
file = self.make_archive (base_name, fmt, base_dir=base_dir)
|
2000-06-01 01:10:56 +00:00
|
|
|
archive_files.append(file)
|
|
|
|
|
|
|
|
self.archive_files = archive_files
|
2000-02-17 23:56:15 +00:00
|
|
|
|
2000-09-25 01:51:01 +00:00
|
|
|
if not self.keep_temp:
|
2000-08-05 01:31:54 +00:00
|
|
|
dir_util.remove_tree (base_dir, self.verbose, self.dry_run)
|
2000-02-17 23:56:15 +00:00
|
|
|
|
2000-06-01 01:10:56 +00:00
|
|
|
def get_archive_files (self):
|
|
|
|
"""Return the list of archive files created when the command
|
|
|
|
was run, or None if the command hasn't run yet.
|
|
|
|
"""
|
|
|
|
return self.archive_files
|
|
|
|
|
2000-05-25 01:10:04 +00:00
|
|
|
# class sdist
|