Skip to content

Commit bcba955

Browse files
committed
"Removed support for 'compress="compress"' to archive_util.make_tarball."
1 parent e2ab601 commit bcba955

File tree

2 files changed

+4
-55
lines changed

2 files changed

+4
-55
lines changed

distutils/archive_util.py

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
that sort of thing)."""
55

66
import os
7-
import sys
8-
from warnings import warn
97

108
try:
119
import zipfile
@@ -67,8 +65,7 @@ def make_tarball(
6765
"""Create a (possibly compressed) tar file from all the files under
6866
'base_dir'.
6967
70-
'compress' must be "gzip" (the default), "bzip2", "xz", "compress", or
71-
None. ("compress" will be deprecated in Python 3.2)
68+
'compress' must be "gzip" (the default), "bzip2", "xz", or None.
7269
7370
'owner' and 'group' can be used to define an owner and a group for the
7471
archive that is being built. If not provided, the current owner and group
@@ -84,20 +81,17 @@ def make_tarball(
8481
'bzip2': 'bz2',
8582
'xz': 'xz',
8683
None: '',
87-
'compress': '',
8884
}
89-
compress_ext = {'gzip': '.gz', 'bzip2': '.bz2', 'xz': '.xz', 'compress': '.Z'}
85+
compress_ext = {'gzip': '.gz', 'bzip2': '.bz2', 'xz': '.xz'}
9086

9187
# flags for compression program, each element of list will be an argument
9288
if compress is not None and compress not in compress_ext.keys():
9389
raise ValueError(
94-
"bad value for 'compress': must be None, 'gzip', 'bzip2', "
95-
"'xz' or 'compress'"
90+
"bad value for 'compress': must be None, 'gzip', 'bzip2', 'xz'"
9691
)
9792

9893
archive_name = base_name + '.tar'
99-
if compress != 'compress':
100-
archive_name += compress_ext.get(compress, '')
94+
archive_name += compress_ext.get(compress, '')
10195

10296
mkpath(os.path.dirname(archive_name), dry_run=dry_run)
10397

@@ -125,18 +119,6 @@ def _set_uid_gid(tarinfo):
125119
finally:
126120
tar.close()
127121

128-
# compression using `compress`
129-
if compress == 'compress':
130-
warn("'compress' is deprecated.", DeprecationWarning)
131-
# the option varies depending on the platform
132-
compressed_name = archive_name + compress_ext[compress]
133-
if sys.platform == 'win32':
134-
cmd = [compress, archive_name, compressed_name]
135-
else:
136-
cmd = [compress, '-f', archive_name]
137-
spawn(cmd, dry_run=dry_run)
138-
return compressed_name
139-
140122
return archive_name
141123

142124

distutils/tests/test_archive_util.py

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import pathlib
77
import sys
88
import tarfile
9-
import warnings
109
from distutils import archive_util
1110
from distutils.archive_util import (
1211
ARCHIVE_FORMATS,
@@ -23,7 +22,6 @@
2322
import pytest
2423
from test.support import patch
2524

26-
from .compat.py38 import check_warnings
2725
from .unix_compat import UID_0_SUPPORT, grp, pwd, require_uid_0, require_unix_id
2826

2927

@@ -190,37 +188,6 @@ def test_tarfile_vs_tar(self):
190188
tarball = base_name + '.tar'
191189
assert os.path.exists(tarball)
192190

193-
@pytest.mark.skipif("not shutil.which('compress')")
194-
def test_compress_deprecated(self):
195-
tmpdir = self._create_files()
196-
base_name = os.path.join(self.mkdtemp(), 'archive')
197-
198-
# using compress and testing the DeprecationWarning
199-
old_dir = os.getcwd()
200-
os.chdir(tmpdir)
201-
try:
202-
with check_warnings() as w:
203-
warnings.simplefilter("always")
204-
make_tarball(base_name, 'dist', compress='compress')
205-
finally:
206-
os.chdir(old_dir)
207-
tarball = base_name + '.tar.Z'
208-
assert os.path.exists(tarball)
209-
assert len(w.warnings) == 1
210-
211-
# same test with dry_run
212-
os.remove(tarball)
213-
old_dir = os.getcwd()
214-
os.chdir(tmpdir)
215-
try:
216-
with check_warnings() as w:
217-
warnings.simplefilter("always")
218-
make_tarball(base_name, 'dist', compress='compress', dry_run=True)
219-
finally:
220-
os.chdir(old_dir)
221-
assert not os.path.exists(tarball)
222-
assert len(w.warnings) == 1
223-
224191
@pytest.mark.usefixtures('needs_zlib')
225192
def test_make_zipfile(self):
226193
zipfile = pytest.importorskip('zipfile')

0 commit comments

Comments
 (0)