Index: E:/Programmazione/Python/Sources/[PRJ] - pyftpdlib/__svn/python/Lib/distutils/archive_util.py =================================================================== --- E:/Programmazione/Python/Sources/[PRJ] - pyftpdlib/__svn/python/Lib/distutils/archive_util.py (revision 60172) +++ E:/Programmazione/Python/Sources/[PRJ] - pyftpdlib/__svn/python/Lib/distutils/archive_util.py (working copy) @@ -8,6 +8,10 @@ __revision__ = "$Id$" import os +try: + import tarfile +except ImportError: + tarfile = None from distutils.errors import DistutilsExecError from distutils.spawn import spawn from distutils.dir_util import mkpath @@ -17,11 +21,15 @@ 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", - "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. + "bzip2", or None. + For creating tar, gztar and bztar archives the tarfile module is + used as default. + If tarfile module is not available 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 -- @@ -42,6 +50,19 @@ raise ValueError, \ "bad value for 'compress': must be None, 'gzip', or 'compress'" + if (tarfile is not None) and (compress in (None, "gzip", "bzip2")): + if compress is None: + ext = '.tar' + mode = 'w' + else: + ext = '.tar' + compress_ext[compress] + mode = 'w' + compress_ext[compress].replace('.', '|') + archive_name = base_name + ext + tar = tarfile.open(archive_name, mode) + tar.add(base_dir) + tar.close() + return archive_name + archive_name = base_name + ".tar" mkpath(os.path.dirname(archive_name), dry_run=dry_run) cmd = ["tar", "-cf", archive_name, base_dir] Index: E:/Programmazione/Python/Sources/[PRJ] - pyftpdlib/__svn/python/Lib/distutils/command/sdist.py =================================================================== --- E:/Programmazione/Python/Sources/[PRJ] - pyftpdlib/__svn/python/Lib/distutils/command/sdist.py (revision 60172) +++ E:/Programmazione/Python/Sources/[PRJ] - pyftpdlib/__svn/python/Lib/distutils/command/sdist.py (working copy) @@ -446,6 +446,10 @@ self.make_release_tree(base_dir, self.filelist.files) archive_files = [] # remember names of files we create + # bugfix #1885: if need to create more than one distribution + # formats, the tar archive must be created for last + if 'tar' in self.formats: + self.formats.append(self.formats.pop(self.formats.index('tar'))) for fmt in self.formats: file = self.make_archive(base_name, fmt, base_dir=base_dir) archive_files.append(file)