Skip to content

Commit

Permalink
"Removed support for 'compress="compress"' to archive_util.make_tarba…
Browse files Browse the repository at this point in the history
…ll."
  • Loading branch information
jaraco committed Sep 5, 2024
1 parent e2ab601 commit 24787ed
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions distutils/archive_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
that sort of thing)."""

import os
import sys
from warnings import warn

try:
import zipfile
Expand Down Expand Up @@ -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
Expand All @@ -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)

Expand Down Expand Up @@ -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


Expand Down

0 comments on commit 24787ed

Please sign in to comment.