if not dry_run:
os.makedirs(archive_dir)
- # If zipfile module is not available, try spawning an external 'zip'
- # command.
- try:
- import zipfile
- except ImportError:
- zipfile = None
-
- if zipfile is None:
- _call_external_zip(base_dir, zip_filename, verbose, dry_run)
- else:
- if logger is not None:
- logger.info("creating '%s' and adding '%s' to it",
- zip_filename, base_dir)
+ if logger is not None:
+ logger.info("creating '%s' and adding '%s' to it",
+ zip_filename, base_dir)
- if not dry_run:
- with zipfile.ZipFile(zip_filename, "w",
- compression=zipfile.ZIP_DEFLATED) as zf:
- path = os.path.normpath(base_dir)
- zf.write(path, path)
- if logger is not None:
- logger.info("adding '%s'", path)
- for dirpath, dirnames, filenames in os.walk(base_dir):
- for name in sorted(dirnames):
- path = os.path.normpath(os.path.join(dirpath, name))
+ if not dry_run:
+ with zipfile.ZipFile(zip_filename, "w",
+ compression=zipfile.ZIP_DEFLATED) as zf:
++ path = os.path.normpath(base_dir)
++ zf.write(path, path)
++ if logger is not None:
++ logger.info("adding '%s'", path)
+ for dirpath, dirnames, filenames in os.walk(base_dir):
++ for name in sorted(dirnames):
++ path = os.path.normpath(os.path.join(dirpath, name))
++ zf.write(path, path)
++ if logger is not None:
++ logger.info("adding '%s'", path)
+ for name in filenames:
+ path = os.path.normpath(os.path.join(dirpath, name))
+ if os.path.isfile(path):
zf.write(path, path)
if logger is not None:
logger.info("adding '%s'", path)
formats = ['tar', 'gztar', 'zip']
if BZ2_SUPPORTED:
formats.append('bztar')
+ if LZMA_SUPPORTED:
+ formats.append('xztar')
root_dir, base_dir = self._create_files()
+ expected = rlistdir(root_dir)
+ expected.remove('outer')
for format in formats:
- expected = rlistdir(root_dir)
- expected.remove('outer')
- if format == 'zip':
- expected.remove('dist/sub2/')
base_name = os.path.join(self.mkdtemp(), 'archive')
filename = make_archive(base_name, format, root_dir, base_dir)
Core and Builtins
-----------------
+Library
+-------
+
++- Issue #24982: shutil.make_archive() with the "zip" format now adds entries
++ for directories (including empty directories) in ZIP file.
++
+- Issue #25019: Fixed a crash caused by setting non-string key of expat parser.
+ Based on patch by John Leitch.
+
+- Issue #16180: Exit pdb if file has syntax error, instead of trapping user
+ in an infinite loop. Patch by Xavier de Gaye.
+
- Issue #24891: Fix a race condition at Python startup if the file descriptor
of stdin (0), stdout (1) or stderr (2) is closed while Python is creating
sys.stdin, sys.stdout and sys.stderr objects. These attributes are now set