summaryrefslogtreecommitdiff
path: root/setuptools/_distutils/command
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2022-08-02 21:03:33 -0400
committerJason R. Coombs <jaraco@jaraco.com>2022-08-02 21:13:43 -0400
commite90b97304d50eb1246197014ca2d794987ce1934 (patch)
tree23e9f77cedeeb30cd3765fd1e35862c2eb89cffb /setuptools/_distutils/command
parent9b0cf7e1dfd8c3e11a47a9b3c7f4385745d50daf (diff)
parentc397f4c164e0a6f49a1ac3a70f5c80fe05785ed6 (diff)
downloadpython-setuptools-git-e90b97304d50eb1246197014ca2d794987ce1934.tar.gz
Merge https://github.com/pypa/distutils into bugfix/distutils-164
Diffstat (limited to 'setuptools/_distutils/command')
-rw-r--r--setuptools/_distutils/command/bdist.py31
-rw-r--r--setuptools/_distutils/command/bdist_dumb.py4
-rw-r--r--setuptools/_distutils/command/bdist_msi.py10
-rw-r--r--setuptools/_distutils/command/bdist_rpm.py8
-rw-r--r--setuptools/_distutils/command/bdist_wininst.py16
-rw-r--r--setuptools/_distutils/command/build.py2
-rw-r--r--setuptools/_distutils/command/build_ext.py2
-rw-r--r--setuptools/_distutils/command/check.py2
-rw-r--r--setuptools/_distutils/command/register.py6
-rw-r--r--setuptools/_distutils/command/sdist.py2
-rw-r--r--setuptools/_distutils/command/upload.py6
11 files changed, 40 insertions, 49 deletions
diff --git a/setuptools/_distutils/command/bdist.py b/setuptools/_distutils/command/bdist.py
index 53f13214..4af1b8e6 100644
--- a/setuptools/_distutils/command/bdist.py
+++ b/setuptools/_distutils/command/bdist.py
@@ -20,12 +20,6 @@ def show_formats():
pretty_printer.print_help("List of available distribution formats:")
-class ListCompat(dict):
- # adapter to allow for Setuptools compatibility in format_commands
- def append(self, item):
- return
-
-
class bdist(Command):
description = "create a built (binary) distribution"
@@ -71,23 +65,18 @@ class bdist(Command):
default_format = {'posix': 'gztar', 'nt': 'zip'}
# Define commands in preferred order for the --help-formats option
- format_commands = ListCompat(
- {
- 'rpm': ('bdist_rpm', "RPM distribution"),
- 'gztar': ('bdist_dumb', "gzip'ed tar file"),
- 'bztar': ('bdist_dumb', "bzip2'ed tar file"),
- 'xztar': ('bdist_dumb', "xz'ed tar file"),
- 'ztar': ('bdist_dumb', "compressed tar file"),
- 'tar': ('bdist_dumb', "tar file"),
- 'wininst': ('bdist_wininst', "Windows executable installer"),
- 'zip': ('bdist_dumb', "ZIP file"),
- 'msi': ('bdist_msi', "Microsoft Installer"),
- }
+ format_commands = dict(
+ rpm=('bdist_rpm', "RPM distribution"),
+ gztar=('bdist_dumb', "gzip'ed tar file"),
+ bztar=('bdist_dumb', "bzip2'ed tar file"),
+ xztar=('bdist_dumb', "xz'ed tar file"),
+ ztar=('bdist_dumb', "compressed tar file"),
+ tar=('bdist_dumb', "tar file"),
+ wininst=('bdist_wininst', "Windows executable installer"),
+ zip=('bdist_dumb', "ZIP file"),
+ msi=('bdist_msi', "Microsoft Installer"),
)
- # for compatibility until Setuptools references only format_commands
- format_command = format_commands
-
def initialize_options(self):
self.bdist_base = None
self.plat_name = None
diff --git a/setuptools/_distutils/command/bdist_dumb.py b/setuptools/_distutils/command/bdist_dumb.py
index d3f519e0..0f52330f 100644
--- a/setuptools/_distutils/command/bdist_dumb.py
+++ b/setuptools/_distutils/command/bdist_dumb.py
@@ -105,7 +105,9 @@ class bdist_dumb(Command):
# And make an archive relative to the root of the
# pseudo-installation tree.
- archive_basename = "%s.%s" % (self.distribution.get_fullname(), self.plat_name)
+ archive_basename = "{}.{}".format(
+ self.distribution.get_fullname(), self.plat_name
+ )
pseudoinstall_root = os.path.join(self.dist_dir, archive_basename)
if not self.relative:
diff --git a/setuptools/_distutils/command/bdist_msi.py b/setuptools/_distutils/command/bdist_msi.py
index 6e1e1abd..57931c73 100644
--- a/setuptools/_distutils/command/bdist_msi.py
+++ b/setuptools/_distutils/command/bdist_msi.py
@@ -253,7 +253,7 @@ class bdist_msi(Command):
if not target_version:
assert self.skip_build, "Should have already checked this"
target_version = '%d.%d' % sys.version_info[:2]
- plat_specifier = ".%s-%s" % (self.plat_name, target_version)
+ plat_specifier = ".{}-{}".format(self.plat_name, target_version)
build = self.get_finalized_command('build')
build.build_lib = os.path.join(build.build_base, 'lib' + plat_specifier)
@@ -286,7 +286,7 @@ class bdist_msi(Command):
# in Add-Remove-Programs (APR)
fullname = self.distribution.get_fullname()
if self.target_version:
- product_name = "Python %s %s" % (self.target_version, fullname)
+ product_name = "Python {} {}".format(self.target_version, fullname)
else:
product_name = "Python %s" % (fullname)
self.db = msilib.init_database(
@@ -347,7 +347,7 @@ class bdist_msi(Command):
for file in os.listdir(dir.absolute):
afile = os.path.join(dir.absolute, file)
if os.path.isdir(afile):
- short = "%s|%s" % (dir.make_short(file), file)
+ short = "{}|{}".format(dir.make_short(file), file)
default = file + version
newdir = Directory(db, cab, dir, file, default, short)
todo.append(newdir)
@@ -1103,12 +1103,12 @@ class bdist_msi(Command):
def get_installer_filename(self, fullname):
# Factored out to allow overriding in subclasses
if self.target_version:
- base_name = "%s.%s-py%s.msi" % (
+ base_name = "{}.{}-py{}.msi".format(
fullname,
self.plat_name,
self.target_version,
)
else:
- base_name = "%s.%s.msi" % (fullname, self.plat_name)
+ base_name = "{}.{}.msi".format(fullname, self.plat_name)
installer_name = os.path.join(self.dist_dir, base_name)
return installer_name
diff --git a/setuptools/_distutils/command/bdist_rpm.py b/setuptools/_distutils/command/bdist_rpm.py
index fcfd7cd8..6a50ef34 100644
--- a/setuptools/_distutils/command/bdist_rpm.py
+++ b/setuptools/_distutils/command/bdist_rpm.py
@@ -353,7 +353,7 @@ class bdist_rpm(Command):
nvr_string = "%{name}-%{version}-%{release}"
src_rpm = nvr_string + ".src.rpm"
non_src_rpm = "%{arch}/" + nvr_string + ".%{arch}.rpm"
- q_cmd = r"rpm -q --qf '%s %s\n' --specfile '%s'" % (
+ q_cmd = r"rpm -q --qf '{} {}\n' --specfile '{}'".format(
src_rpm,
non_src_rpm,
spec_path,
@@ -488,9 +488,9 @@ class bdist_rpm(Command):
):
val = getattr(self, field.lower())
if isinstance(val, list):
- spec_file.append('%s: %s' % (field, ' '.join(val)))
+ spec_file.append('{}: {}'.format(field, ' '.join(val)))
elif val is not None:
- spec_file.append('%s: %s' % (field, val))
+ spec_file.append('{}: {}'.format(field, val))
if self.distribution.get_url():
spec_file.append('Url: ' + self.distribution.get_url())
@@ -527,7 +527,7 @@ class bdist_rpm(Command):
# rpm scripts
# figure out default build script
- def_setup_call = "%s %s" % (self.python, os.path.basename(sys.argv[0]))
+ def_setup_call = "{} {}".format(self.python, os.path.basename(sys.argv[0]))
def_build = "%s build" % def_setup_call
if self.use_rpm_opt_flags:
def_build = 'env CFLAGS="$RPM_OPT_FLAGS" ' + def_build
diff --git a/setuptools/_distutils/command/bdist_wininst.py b/setuptools/_distutils/command/bdist_wininst.py
index 7e9a64a5..02bd7200 100644
--- a/setuptools/_distutils/command/bdist_wininst.py
+++ b/setuptools/_distutils/command/bdist_wininst.py
@@ -185,7 +185,7 @@ class bdist_wininst(Command):
if not target_version:
assert self.skip_build, "Should have already checked this"
target_version = '%d.%d' % sys.version_info[:2]
- plat_specifier = ".%s-%s" % (self.plat_name, target_version)
+ plat_specifier = ".{}-{}".format(self.plat_name, target_version)
build = self.get_finalized_command('build')
build.build_lib = os.path.join(build.build_base, 'lib' + plat_specifier)
@@ -259,8 +259,8 @@ class bdist_wininst(Command):
]:
data = getattr(metadata, name, "")
if data:
- info = info + ("\n %s: %s" % (name.capitalize(), escape(data)))
- lines.append("%s=%s" % (name, escape(data)))
+ info = info + ("\n {}: {}".format(name.capitalize(), escape(data)))
+ lines.append("{}={}".format(name, escape(data)))
# The [setup] section contains entries controlling
# the installer runtime.
@@ -280,7 +280,7 @@ class bdist_wininst(Command):
import time
import distutils
- build_info = "Built %s with distutils-%s" % (
+ build_info = "Built {} with distutils-{}".format(
time.ctime(time.time()),
distutils.__version__,
)
@@ -319,7 +319,7 @@ class bdist_wininst(Command):
# We need to normalize newlines, so we open in text mode and
# convert back to bytes. "latin-1" simply avoids any possible
# failures.
- with open(self.pre_install_script, "r", encoding="latin-1") as script:
+ with open(self.pre_install_script, encoding="latin-1") as script:
script_data = script.read().encode("latin-1")
cfgdata = cfgdata + script_data + b"\n\0"
else:
@@ -349,11 +349,11 @@ class bdist_wininst(Command):
# it's better to include this in the name
installer_name = os.path.join(
self.dist_dir,
- "%s.%s-py%s.exe" % (fullname, self.plat_name, self.target_version),
+ "{}.{}-py{}.exe".format(fullname, self.plat_name, self.target_version),
)
else:
installer_name = os.path.join(
- self.dist_dir, "%s.%s.exe" % (fullname, self.plat_name)
+ self.dist_dir, "{}.{}.exe".format(fullname, self.plat_name)
)
return installer_name
@@ -410,7 +410,7 @@ class bdist_wininst(Command):
else:
sfix = ''
- filename = os.path.join(directory, "wininst-%s%s.exe" % (bv, sfix))
+ filename = os.path.join(directory, "wininst-{}{}.exe".format(bv, sfix))
f = open(filename, "rb")
try:
return f.read()
diff --git a/setuptools/_distutils/command/build.py b/setuptools/_distutils/command/build.py
index e4b06425..6d453419 100644
--- a/setuptools/_distutils/command/build.py
+++ b/setuptools/_distutils/command/build.py
@@ -79,7 +79,7 @@ class build(Command):
"using './configure --help' on your platform)"
)
- plat_specifier = ".%s-%s" % (self.plat_name, sys.implementation.cache_tag)
+ plat_specifier = ".{}-{}".format(self.plat_name, sys.implementation.cache_tag)
# Make it so Python 2.x and Python 2.x with --with-pydebug don't
# share the same build directories. Doing so confuses the build
diff --git a/setuptools/_distutils/command/build_ext.py b/setuptools/_distutils/command/build_ext.py
index 153a0b6d..3c6cee7e 100644
--- a/setuptools/_distutils/command/build_ext.py
+++ b/setuptools/_distutils/command/build_ext.py
@@ -498,7 +498,7 @@ class build_ext(Command):
except (CCompilerError, DistutilsError, CompileError) as e:
if not ext.optional:
raise
- self.warn('building extension "%s" failed: %s' % (ext.name, e))
+ self.warn('building extension "{}" failed: {}'.format(ext.name, e))
def build_extension(self, ext):
sources = ext.sources
diff --git a/setuptools/_distutils/command/check.py b/setuptools/_distutils/command/check.py
index 9c3523a8..aaf30713 100644
--- a/setuptools/_distutils/command/check.py
+++ b/setuptools/_distutils/command/check.py
@@ -117,7 +117,7 @@ class check(Command):
if line is None:
warning = warning[1]
else:
- warning = '%s (line %s)' % (warning[1], line)
+ warning = '{} (line {})'.format(warning[1], line)
self.warn(warning)
def _check_rst_data(self, data):
diff --git a/setuptools/_distutils/command/register.py b/setuptools/_distutils/command/register.py
index d2351ab8..2c642472 100644
--- a/setuptools/_distutils/command/register.py
+++ b/setuptools/_distutils/command/register.py
@@ -174,7 +174,7 @@ Your selection [default 1]: ''',
auth.add_password(self.realm, host, username, password)
# send the info to the server and report the result
code, result = self.post_to_server(self.build_post_data('submit'), auth)
- self.announce('Server response (%s): %s' % (code, result), log.INFO)
+ self.announce('Server response ({}): {}'.format(code, result), log.INFO)
# possibly save the login
if code == 200:
@@ -224,7 +224,7 @@ Your selection [default 1]: ''',
log.info('Server response (%s): %s', code, result)
else:
log.info('You will receive an email shortly.')
- log.info(('Follow the instructions in it to ' 'complete registration.'))
+ log.info('Follow the instructions in it to ' 'complete registration.')
elif choice == '3':
data = {':action': 'password_reset'}
data['email'] = ''
@@ -265,7 +265,7 @@ Your selection [default 1]: ''',
'''Post a query to the server, and return a string response.'''
if 'name' in data:
self.announce(
- 'Registering %s to %s' % (data['name'], self.repository), log.INFO
+ 'Registering {} to {}'.format(data['name'], self.repository), log.INFO
)
# Build up the MIME payload for the urllib2 POST data
boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
diff --git a/setuptools/_distutils/command/sdist.py b/setuptools/_distutils/command/sdist.py
index ec3c97ac..d6e9489d 100644
--- a/setuptools/_distutils/command/sdist.py
+++ b/setuptools/_distutils/command/sdist.py
@@ -402,7 +402,7 @@ class sdist(Command):
seps = '/'
vcs_dirs = ['RCS', 'CVS', r'\.svn', r'\.hg', r'\.git', r'\.bzr', '_darcs']
- vcs_ptrn = r'(^|%s)(%s)(%s).*' % (seps, '|'.join(vcs_dirs), seps)
+ vcs_ptrn = r'(^|{})({})({}).*'.format(seps, '|'.join(vcs_dirs), seps)
self.filelist.exclude_pattern(vcs_ptrn, is_regex=1)
def write_manifest(self):
diff --git a/setuptools/_distutils/command/upload.py b/setuptools/_distutils/command/upload.py
index f2a8118e..6af53943 100644
--- a/setuptools/_distutils/command/upload.py
+++ b/setuptools/_distutils/command/upload.py
@@ -170,7 +170,7 @@ class upload(PyPIRCCommand):
body.write(end_boundary)
body = body.getvalue()
- msg = "Submitting %s to %s" % (filename, self.repository)
+ msg = "Submitting {} to {}".format(filename, self.repository)
self.announce(msg, log.INFO)
# build the Request
@@ -194,12 +194,12 @@ class upload(PyPIRCCommand):
raise
if status == 200:
- self.announce('Server response (%s): %s' % (status, reason), log.INFO)
+ self.announce('Server response ({}): {}'.format(status, reason), log.INFO)
if self.show_response:
text = self._read_pypi_response(result)
msg = '\n'.join(('-' * 75, text, '-' * 75))
self.announce(msg, log.INFO)
else:
- msg = 'Upload failed (%s): %s' % (status, reason)
+ msg = 'Upload failed ({}): {}'.format(status, reason)
self.announce(msg, log.ERROR)
raise DistutilsError(msg)