summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/distutils/archive_util.py24
-rw-r--r--Lib/distutils/command/bdist.py4
-rw-r--r--Lib/distutils/command/sdist.py3
3 files changed, 20 insertions, 11 deletions
diff --git a/Lib/distutils/archive_util.py b/Lib/distutils/archive_util.py
index bae425b..050ea41 100644
--- a/Lib/distutils/archive_util.py
+++ b/Lib/distutils/archive_util.py
@@ -15,12 +15,12 @@ from distutils.spawn import spawn
def make_tarball (base_name, base_dir, compress="gzip",
verbose=0, dry_run=0):
"""Create a (possibly compressed) tar file from all the files under
- 'base_dir'. 'compress' must be "gzip" (the default), "compress", or
- None. Both "tar" and the compression utility named by 'compress'
- must be on the default program search path, so this is probably
- Unix-specific. The output tar file will be named 'base_dir' +
- ".tar", possibly plus the appropriate compression extension
- (".gz" or ".Z"). Return the output filename."""
+ 'base_dir'. 'compress' must be "gzip" (the default), "compress",
+ "bzip2", or None. Both "tar" and the compression utility named by
+ 'compress' must be on the default program search path, so this is
+ probably Unix-specific. The output tar file will be named 'base_dir'
+ + ".tar", possibly plus the appropriate compression extension (".gz",
+ ".bz2" or ".Z"). Return the output filename."""
# 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 --
@@ -29,9 +29,15 @@ def make_tarball (base_name, base_dir, compress="gzip",
# detect GNU tar to use its 'z' option and save a step.)
compress_ext = { 'gzip': ".gz",
+ 'bzip2': '.bz2',
'compress': ".Z" }
+
+ # flags for compression program, each element of list will be an argument
+ compress_flags = {'gzip': ["-f9"],
+ 'compress': ["-f"],
+ 'bzip2': ['-f9']}
- if compress is not None and compress not in ('gzip', 'compress'):
+ if compress is not None and compress not in compress_ext.keys():
raise ValueError, \
"bad value for 'compress': must be None, 'gzip', or 'compress'"
@@ -40,7 +46,8 @@ def make_tarball (base_name, base_dir, compress="gzip",
spawn (cmd, verbose=verbose, dry_run=dry_run)
if compress:
- spawn ([compress, archive_name], verbose=verbose, dry_run=dry_run)
+ spawn ([compress] + compress_flags[compress] + [archive_name],
+ verbose=verbose, dry_run=dry_run)
return archive_name + compress_ext[compress]
else:
return archive_name
@@ -104,6 +111,7 @@ def make_zipfile (base_name, base_dir, verbose=0, dry_run=0):
ARCHIVE_FORMATS = {
'gztar': (make_tarball, [('compress', 'gzip')]),
+ 'bztar': (make_tarball, [('compress', 'bzip2')]),
'ztar': (make_tarball, [('compress', 'compress')]),
'tar': (make_tarball, [('compress', None)]),
'zip': (make_zipfile, [])
diff --git a/Lib/distutils/command/bdist.py b/Lib/distutils/command/bdist.py
index 685f525..cde8dd6 100644
--- a/Lib/distutils/command/bdist.py
+++ b/Lib/distutils/command/bdist.py
@@ -18,7 +18,8 @@ class bdist (Command):
description = "create a built (binary) distribution"
user_options = [('format=', 'f',
- "format for distribution (tar, ztar, gztar, zip, ... )"),
+ "format for distribution " +
+ "(tar, ztar, gztar, bztar, zip, ... )"),
]
# This won't do in reality: will need to distinguish RPM-ish Linux,
@@ -27,6 +28,7 @@ class bdist (Command):
'nt': 'zip', }
format_command = { 'gztar': 'bdist_dumb',
+ 'bztar': 'bdist_dumb',
'ztar': 'bdist_dumb',
'tar': 'bdist_dumb',
'zip': 'bdist_dumb', }
diff --git a/Lib/distutils/command/sdist.py b/Lib/distutils/command/sdist.py
index 8aa4618..8d9a465 100644
--- a/Lib/distutils/command/sdist.py
+++ b/Lib/distutils/command/sdist.py
@@ -33,9 +33,8 @@ class sdist (Command):
"just regenerate the manifest and then stop"),
('force-manifest', None,
"forcibly regenerate the manifest and carry on as usual"),
-
('formats=', None,
- "formats for source distribution (tar, ztar, gztar, or zip)"),
+ "formats for source distribution (tar, ztar, gztar, bztar, or zip)"),
('keep-tree', 'k',
"keep the distribution tree around after creating " +
"archive file(s)"),