summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/archive_util.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-03-15 20:02:59 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2011-03-15 20:02:59 (GMT)
commit2c50a09ac47e701768a4e20f8a03d17263e8db8f (patch)
treec825f5ed587fe4229ec825f3371556738e284dd2 /Lib/distutils/archive_util.py
parent7dedcb46441803444a3bdb0f9773d9d9b10186e9 (diff)
downloadcpython-2c50a09ac47e701768a4e20f8a03d17263e8db8f.zip
cpython-2c50a09ac47e701768a4e20f8a03d17263e8db8f.tar.gz
cpython-2c50a09ac47e701768a4e20f8a03d17263e8db8f.tar.bz2
On behalf of Tarek: Issue #11501: disutils.archive_utils.make_zipfile no
longer fails if zlib is not installed. Instead, the zipfile.ZIP_STORED compression is used to create the ZipFile. Patch by Natalia B. Bidart.
Diffstat (limited to 'Lib/distutils/archive_util.py')
-rw-r--r--Lib/distutils/archive_util.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/Lib/distutils/archive_util.py b/Lib/distutils/archive_util.py
index 6dd0445..c06eba3 100644
--- a/Lib/distutils/archive_util.py
+++ b/Lib/distutils/archive_util.py
@@ -9,6 +9,12 @@ import os
from warnings import warn
import sys
+try:
+ import zipfile
+except ImportError:
+ zipfile = None
+
+
from distutils.errors import DistutilsExecError
from distutils.spawn import spawn
from distutils.dir_util import mkpath
@@ -74,11 +80,6 @@ def make_zipfile(base_name, base_dir, verbose=0, dry_run=0):
available, raises DistutilsExecError. Returns the name of the output zip
file.
"""
- try:
- import zipfile
- except ImportError:
- zipfile = None
-
zip_filename = base_name + ".zip"
mkpath(os.path.dirname(zip_filename), dry_run=dry_run)
@@ -105,8 +106,12 @@ def make_zipfile(base_name, base_dir, verbose=0, dry_run=0):
zip_filename, base_dir)
if not dry_run:
- zip = zipfile.ZipFile(zip_filename, "w",
- compression=zipfile.ZIP_DEFLATED)
+ try:
+ zip = zipfile.ZipFile(zip_filename, "w",
+ compression=zipfile.ZIP_DEFLATED)
+ except RuntimeError:
+ zip = zipfile.ZipFile(zip_filename, "w",
+ compression=zipfile.ZIP_STORED)
for dirpath, dirnames, filenames in os.walk(base_dir):
for name in filenames: