From bcba955249ae22b9cadab363a300fb7a828f0be8 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 5 Sep 2024 17:58:01 -0400 Subject: [PATCH] "Removed support for 'compress="compress"' to archive_util.make_tarball." --- distutils/archive_util.py | 26 ++++------------------ distutils/tests/test_archive_util.py | 33 ---------------------------- 2 files changed, 4 insertions(+), 55 deletions(-) diff --git a/distutils/archive_util.py b/distutils/archive_util.py index cc4699b1..5bb6df76 100644 --- a/distutils/archive_util.py +++ b/distutils/archive_util.py @@ -4,8 +4,6 @@ that sort of thing).""" import os -import sys -from warnings import warn try: import zipfile @@ -67,8 +65,7 @@ def make_tarball( """Create a (possibly compressed) tar file from all the files under 'base_dir'. - 'compress' must be "gzip" (the default), "bzip2", "xz", "compress", or - None. ("compress" will be deprecated in Python 3.2) + 'compress' must be "gzip" (the default), "bzip2", "xz", or None. 'owner' and 'group' can be used to define an owner and a group for the archive that is being built. If not provided, the current owner and group @@ -84,20 +81,17 @@ def make_tarball( 'bzip2': 'bz2', 'xz': 'xz', None: '', - 'compress': '', } - compress_ext = {'gzip': '.gz', 'bzip2': '.bz2', 'xz': '.xz', 'compress': '.Z'} + compress_ext = {'gzip': '.gz', 'bzip2': '.bz2', 'xz': '.xz'} # flags for compression program, each element of list will be an argument if compress is not None and compress not in compress_ext.keys(): raise ValueError( - "bad value for 'compress': must be None, 'gzip', 'bzip2', " - "'xz' or 'compress'" + "bad value for 'compress': must be None, 'gzip', 'bzip2', 'xz'" ) archive_name = base_name + '.tar' - if compress != 'compress': - archive_name += compress_ext.get(compress, '') + archive_name += compress_ext.get(compress, '') mkpath(os.path.dirname(archive_name), dry_run=dry_run) @@ -125,18 +119,6 @@ def _set_uid_gid(tarinfo): finally: tar.close() - # compression using `compress` - if compress == 'compress': - warn("'compress' is deprecated.", DeprecationWarning) - # the option varies depending on the platform - compressed_name = archive_name + compress_ext[compress] - if sys.platform == 'win32': - cmd = [compress, archive_name, compressed_name] - else: - cmd = [compress, '-f', archive_name] - spawn(cmd, dry_run=dry_run) - return compressed_name - return archive_name diff --git a/distutils/tests/test_archive_util.py b/distutils/tests/test_archive_util.py index 389eba16..3e4ed75a 100644 --- a/distutils/tests/test_archive_util.py +++ b/distutils/tests/test_archive_util.py @@ -6,7 +6,6 @@ import pathlib import sys import tarfile -import warnings from distutils import archive_util from distutils.archive_util import ( ARCHIVE_FORMATS, @@ -23,7 +22,6 @@ import pytest from test.support import patch -from .compat.py38 import check_warnings from .unix_compat import UID_0_SUPPORT, grp, pwd, require_uid_0, require_unix_id @@ -190,37 +188,6 @@ def test_tarfile_vs_tar(self): tarball = base_name + '.tar' assert os.path.exists(tarball) - @pytest.mark.skipif("not shutil.which('compress')") - def test_compress_deprecated(self): - tmpdir = self._create_files() - base_name = os.path.join(self.mkdtemp(), 'archive') - - # using compress and testing the DeprecationWarning - old_dir = os.getcwd() - os.chdir(tmpdir) - try: - with check_warnings() as w: - warnings.simplefilter("always") - make_tarball(base_name, 'dist', compress='compress') - finally: - os.chdir(old_dir) - tarball = base_name + '.tar.Z' - assert os.path.exists(tarball) - assert len(w.warnings) == 1 - - # same test with dry_run - os.remove(tarball) - old_dir = os.getcwd() - os.chdir(tmpdir) - try: - with check_warnings() as w: - warnings.simplefilter("always") - make_tarball(base_name, 'dist', compress='compress', dry_run=True) - finally: - os.chdir(old_dir) - assert not os.path.exists(tarball) - assert len(w.warnings) == 1 - @pytest.mark.usefixtures('needs_zlib') def test_make_zipfile(self): zipfile = pytest.importorskip('zipfile')