From 04e25a1bdfd8fd724ab46a9c946ae8aa11cd09af Mon Sep 17 00:00:00 2001 From: Greg Ward Date: Tue, 22 Aug 2000 01:48:54 +0000 Subject: Ensure destination directory exists before trying to create a tarball or ZIP file. --- Lib/distutils/archive_util.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/distutils/archive_util.py b/Lib/distutils/archive_util.py index 08a3c83..26cd7fb 100644 --- a/Lib/distutils/archive_util.py +++ b/Lib/distutils/archive_util.py @@ -10,7 +10,7 @@ __revision__ = "$Id$" import os from distutils.errors import DistutilsExecError from distutils.spawn import spawn - +from distutils.dir_util import mkpath def make_tarball (base_name, base_dir, compress="gzip", verbose=0, dry_run=0): @@ -42,6 +42,7 @@ def make_tarball (base_name, base_dir, compress="gzip", "bad value for 'compress': must be None, 'gzip', or 'compress'" archive_name = base_name + ".tar" + mkpath(os.path.dirname(archive_name), verbose=verbose, dry_run=dry_run) cmd = ["tar", "-cf", archive_name, base_dir] spawn (cmd, verbose=verbose, dry_run=dry_run) @@ -68,6 +69,7 @@ def make_zipfile (base_name, base_dir, verbose=0, dry_run=0): # no changes needed! zip_filename = base_name + ".zip" + mkpath(os.path.dirname(zip_filename), verbose=verbose, dry_run=dry_run) try: spawn (["zip", "-rq", zip_filename, base_dir], verbose=verbose, dry_run=dry_run) @@ -114,7 +116,7 @@ ARCHIVE_FORMATS = { 'bztar': (make_tarball, [('compress', 'bzip2')], "bzip2'ed tar-file"), 'ztar': (make_tarball, [('compress', 'compress')], "compressed tar file"), 'tar': (make_tarball, [('compress', None)], "uncompressed tar file"), - 'zip': (make_zipfile, [],"zip-file") + 'zip': (make_zipfile, [],"ZIP file") } def check_archive_formats (formats): -- cgit v0.12