diff options
author | Benjamin Peterson <benjamin@python.org> | 2018-08-28 22:12:56 -0700 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2018-08-28 22:15:33 -0700 |
commit | add531a1e55b0a739b0f42582f1c9747e5649ace (patch) | |
tree | afa1d9b2b52423414af7bc8b47c2db81eab79d6e /Lib/shutil.py | |
parent | 491740f116755e220135e596ec802ea3a0f65596 (diff) | |
download | cpython-git-benjamin-external-zip.tar.gz |
closes bpo-34540: Convert shutil._call_external_zip to use subprocess rather than distutils.spawn.benjamin-external-zip
Diffstat (limited to 'Lib/shutil.py')
-rw-r--r-- | Lib/shutil.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/Lib/shutil.py b/Lib/shutil.py index 3462f7c5e9..0ab1a06f52 100644 --- a/Lib/shutil.py +++ b/Lib/shutil.py @@ -413,17 +413,21 @@ def _make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0, return archive_name -def _call_external_zip(base_dir, zip_filename, verbose=False, dry_run=False): +def _call_external_zip(base_dir, zip_filename, verbose, dry_run, logger): # XXX see if we want to keep an external call here if verbose: zipoptions = "-r" else: zipoptions = "-rq" - from distutils.errors import DistutilsExecError - from distutils.spawn import spawn + cmd = ["zip", zipoptions, zip_filename, base_dir] + if logger is not None: + logger.info(' '.join(cmd)) + if dry_run: + return + import subprocess try: - spawn(["zip", zipoptions, zip_filename, base_dir], dry_run=dry_run) - except DistutilsExecError: + subprocess.check_call(cmd) + except subprocess.CalledProcessError: # XXX really should distinguish between "couldn't find # external 'zip' command" and "zip failed". raise ExecError, \ @@ -458,7 +462,7 @@ def _make_zipfile(base_name, base_dir, verbose=0, dry_run=0, logger=None): zipfile = None if zipfile is None: - _call_external_zip(base_dir, zip_filename, verbose, dry_run) + _call_external_zip(base_dir, zip_filename, verbose, dry_run, logger) else: if logger is not None: logger.info("creating '%s' and adding '%s' to it", |