diff options
author | Greg Ward <gward@python.net> | 2000-03-29 02:47:29 (GMT) |
---|---|---|
committer | Greg Ward <gward@python.net> | 2000-03-29 02:47:29 (GMT) |
commit | 03d1ae1f0152ef5a6fe4f8a21302387979bd04c9 (patch) | |
tree | 9427de226a34c511b7a7ea3d3f1e2f54bd52e436 /Lib | |
parent | f00c34da1d0ba4641829adb264fcb20c663b872e (diff) | |
download | cpython-03d1ae1f0152ef5a6fe4f8a21302387979bd04c9.zip cpython-03d1ae1f0152ef5a6fe4f8a21302387979bd04c9.tar.gz cpython-03d1ae1f0152ef5a6fe4f8a21302387979bd04c9.tar.bz2 |
Moved the guts of 'make_tarball()' and 'make_zipfile()' to distutils.util
in preparation for the 'bdist_dumb' command; these methods remain as
trivial wrappers around the versions in distutils.util.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/distutils/command/sdist.py | 57 |
1 files changed, 4 insertions, 53 deletions
diff --git a/Lib/distutils/command/sdist.py b/Lib/distutils/command/sdist.py index 0c15177..19e1773 100644 --- a/Lib/distutils/command/sdist.py +++ b/Lib/distutils/command/sdist.py @@ -11,7 +11,7 @@ import fnmatch from types import * from glob import glob from distutils.core import Command -from distutils.util import newer, remove_tree +from distutils.util import newer, remove_tree, make_tarball, make_zipfile from distutils.text_file import TextFile from distutils.errors import DistutilsExecError @@ -503,60 +503,11 @@ class sdist (Command): # make_release_tree () - def make_tarball (self, base_dir, compress="gzip"): - - # XXX GNU tar 1.13 has a nifty option to add a prefix directory. - # It's pretty new, though, so we certainly can't require it -- - # but it would be nice to take advantage of it to skip the - # "create a tree of hardlinks" step! (Would also be nice to - # detect GNU tar to use its 'z' option and save a step.) - - if compress is not None and compress not in ('gzip', 'compress'): - raise ValueError, \ - "if given, 'compress' must be 'gzip' or 'compress'" - - archive_name = base_dir + ".tar" - self.spawn (["tar", "-cf", archive_name, base_dir]) - - if compress: - self.spawn ([compress, archive_name]) - + def make_tarball (self, base_dir, compress): + make_tarball (base_dir, compress, self.verbose, self.dry_run) def make_zipfile (self, base_dir): - - # This initially assumed the Unix 'zip' utility -- but - # apparently InfoZIP's zip.exe works the same under Windows, so - # no changes needed! - - try: - self.spawn (["zip", "-r", base_dir + ".zip", base_dir]) - except DistutilsExecError: - - # XXX really should distinguish between "couldn't find - # external 'zip' command" and "zip failed" -- shouldn't try - # again in the latter case. (I think fixing this will - # require some cooperation from the spawn module -- perhaps - # a utility function to search the path, so we can fallback - # on zipfile.py without the failed spawn.) - try: - import zipfile - except ImportError: - raise DistutilsExecError, \ - ("unable to create zip file '%s.zip': " + - "could neither find a standalone zip utility nor " + - "import the 'zipfile' module") % base_dir - - z = zipfile.ZipFile (base_dir + ".zip", "wb", - compression=zipfile.ZIP_DEFLATED) - - def visit (z, dirname, names): - for name in names: - path = os.path.join (dirname, name) - if os.path.isfile (path): - z.write (path, path) - - os.path.walk (base_dir, visit, z) - z.close() + make_zipfile (base_dir, self.verbose, self.dry_run) def make_distribution (self): |