aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2025-01-20 22:58:34 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2025-01-20 23:35:05 +0300
commit4c5957b4d22d3e94079c335ea6f2da8fc786de47 (patch)
tree00128ce0a17332e1e519368158742bf08ed5da22
parent6d1e12141d962a0b930005bd2019fe29aee28ace (diff)
downloadydb-4c5957b4d22d3e94079c335ea6f2da8fc786de47.tar.gz
Intermediate changes
commit_hash:723bd7a1ba6f9f6935191482507173119b20ba23
-rw-r--r--contrib/python/setuptools/py3/.dist-info/METADATA8
-rw-r--r--contrib/python/setuptools/py3/pkg_resources/__init__.py63
-rw-r--r--contrib/python/setuptools/py3/setuptools/__init__.py6
-rw-r--r--contrib/python/setuptools/py3/setuptools/_core_metadata.py8
-rw-r--r--contrib/python/setuptools/py3/setuptools/_distutils/ccompiler.py39
-rw-r--r--contrib/python/setuptools/py3/setuptools/_distutils/cmd.py27
-rw-r--r--contrib/python/setuptools/py3/setuptools/_distutils/command/bdist.py5
-rw-r--r--contrib/python/setuptools/py3/setuptools/_distutils/command/build.py3
-rw-r--r--contrib/python/setuptools/py3/setuptools/_distutils/command/build_clib.py6
-rw-r--r--contrib/python/setuptools/py3/setuptools/_distutils/command/build_ext.py14
-rw-r--r--contrib/python/setuptools/py3/setuptools/_distutils/command/build_scripts.py3
-rw-r--r--contrib/python/setuptools/py3/setuptools/_distutils/command/check.py8
-rw-r--r--contrib/python/setuptools/py3/setuptools/_distutils/command/install.py4
-rw-r--r--contrib/python/setuptools/py3/setuptools/_distutils/command/install_data.py5
-rw-r--r--contrib/python/setuptools/py3/setuptools/_distutils/command/install_egg_info.py11
-rw-r--r--contrib/python/setuptools/py3/setuptools/_distutils/command/install_headers.py4
-rw-r--r--contrib/python/setuptools/py3/setuptools/_distutils/command/sdist.py6
-rw-r--r--contrib/python/setuptools/py3/setuptools/_distutils/compat/__init__.py4
-rw-r--r--contrib/python/setuptools/py3/setuptools/_distutils/compat/py38.py34
-rw-r--r--contrib/python/setuptools/py3/setuptools/_distutils/core.py5
-rw-r--r--contrib/python/setuptools/py3/setuptools/_distutils/dist.py39
-rw-r--r--contrib/python/setuptools/py3/setuptools/_distutils/extension.py36
-rw-r--r--contrib/python/setuptools/py3/setuptools/_distutils/fancy_getopt.py22
-rw-r--r--contrib/python/setuptools/py3/setuptools/_distutils/file_util.py10
-rw-r--r--contrib/python/setuptools/py3/setuptools/_distutils/filelist.py5
-rw-r--r--contrib/python/setuptools/py3/setuptools/_distutils/spawn.py2
-rw-r--r--contrib/python/setuptools/py3/setuptools/_distutils/sysconfig.py4
-rw-r--r--contrib/python/setuptools/py3/setuptools/_distutils/text_file.py4
-rw-r--r--contrib/python/setuptools/py3/setuptools/_distutils/util.py19
-rw-r--r--contrib/python/setuptools/py3/setuptools/_distutils/version.py3
-rw-r--r--contrib/python/setuptools/py3/setuptools/_imp.py6
-rw-r--r--contrib/python/setuptools/py3/setuptools/archive_util.py8
-rw-r--r--contrib/python/setuptools/py3/setuptools/command/_requirestxt.py4
-rw-r--r--contrib/python/setuptools/py3/setuptools/command/alias.py4
-rw-r--r--contrib/python/setuptools/py3/setuptools/command/bdist_egg.py4
-rw-r--r--contrib/python/setuptools/py3/setuptools/command/bdist_wheel.py6
-rw-r--r--contrib/python/setuptools/py3/setuptools/command/build_clib.py16
-rw-r--r--contrib/python/setuptools/py3/setuptools/command/build_ext.py4
-rw-r--r--contrib/python/setuptools/py3/setuptools/command/build_py.py4
-rw-r--r--contrib/python/setuptools/py3/setuptools/command/dist_info.py2
-rw-r--r--contrib/python/setuptools/py3/setuptools/command/easy_install.py42
-rw-r--r--contrib/python/setuptools/py3/setuptools/command/editable_wheel.py2
-rw-r--r--contrib/python/setuptools/py3/setuptools/command/egg_info.py13
-rw-r--r--contrib/python/setuptools/py3/setuptools/command/install_egg_info.py2
-rw-r--r--contrib/python/setuptools/py3/setuptools/command/sdist.py4
-rw-r--r--contrib/python/setuptools/py3/setuptools/command/setopt.py2
-rw-r--r--contrib/python/setuptools/py3/setuptools/config/expand.py2
-rw-r--r--contrib/python/setuptools/py3/setuptools/config/pyprojecttoml.py2
-rw-r--r--contrib/python/setuptools/py3/setuptools/config/setupcfg.py4
-rw-r--r--contrib/python/setuptools/py3/setuptools/depends.py2
-rw-r--r--contrib/python/setuptools/py3/setuptools/dist.py28
-rw-r--r--contrib/python/setuptools/py3/setuptools/monkey.py2
-rw-r--r--contrib/python/setuptools/py3/setuptools/msvc.py87
-rw-r--r--contrib/python/setuptools/py3/setuptools/package_index.py42
-rw-r--r--contrib/python/setuptools/py3/setuptools/wheel.py8
-rw-r--r--contrib/python/setuptools/py3/ya.make3
56 files changed, 358 insertions, 352 deletions
diff --git a/contrib/python/setuptools/py3/.dist-info/METADATA b/contrib/python/setuptools/py3/.dist-info/METADATA
index d9f4d9351b..96aa363053 100644
--- a/contrib/python/setuptools/py3/.dist-info/METADATA
+++ b/contrib/python/setuptools/py3/.dist-info/METADATA
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: setuptools
-Version: 75.6.0
+Version: 75.7.0
Summary: Easily download, build, install, upgrade, and uninstall Python packages
Author-email: Python Packaging Authority <distutils-sig@python.org>
Project-URL: Source, https://github.com/pypa/setuptools
@@ -27,7 +27,7 @@ Requires-Dist: pip>=19.1; extra == "test"
Requires-Dist: packaging>=24.2; extra == "test"
Requires-Dist: jaraco.envs>=2.2; extra == "test"
Requires-Dist: pytest-xdist>=3; extra == "test"
-Requires-Dist: jaraco.path>=3.2.0; extra == "test"
+Requires-Dist: jaraco.path>=3.7.2; extra == "test"
Requires-Dist: build[virtualenv]>=1.0.3; extra == "test"
Requires-Dist: filelock>=3.4.0; extra == "test"
Requires-Dist: ini2toml[lite]>=0.14; extra == "test"
@@ -71,14 +71,14 @@ Requires-Dist: more_itertools; extra == "core"
Provides-Extra: check
Requires-Dist: pytest-checkdocs>=2.4; extra == "check"
Requires-Dist: pytest-ruff>=0.2.1; sys_platform != "cygwin" and extra == "check"
-Requires-Dist: ruff>=0.7.0; sys_platform != "cygwin" and extra == "check"
+Requires-Dist: ruff>=0.8.0; sys_platform != "cygwin" and extra == "check"
Provides-Extra: cover
Requires-Dist: pytest-cov; extra == "cover"
Provides-Extra: enabler
Requires-Dist: pytest-enabler>=2.2; extra == "enabler"
Provides-Extra: type
Requires-Dist: pytest-mypy; extra == "type"
-Requires-Dist: mypy<1.14,>=1.12; extra == "type"
+Requires-Dist: mypy==1.14.*; extra == "type"
Requires-Dist: importlib_metadata>=7.0.2; python_version < "3.10" and extra == "type"
Requires-Dist: jaraco.develop>=7.21; sys_platform != "cygwin" and extra == "type"
diff --git a/contrib/python/setuptools/py3/pkg_resources/__init__.py b/contrib/python/setuptools/py3/pkg_resources/__init__.py
index 273bff7a65..df522e5b86 100644
--- a/contrib/python/setuptools/py3/pkg_resources/__init__.py
+++ b/contrib/python/setuptools/py3/pkg_resources/__init__.py
@@ -200,7 +200,9 @@ def get_supported_platform():
m = macosVersionString.match(plat)
if m is not None and sys.platform == "darwin":
try:
- plat = 'macosx-%s-%s' % ('.'.join(_macos_vers()[:2]), m.group(3))
+ major_minor = '.'.join(_macos_vers()[:2])
+ build = m.group(3)
+ plat = f'macosx-{major_minor}-{build}'
except ValueError:
# not macOS
pass
@@ -449,12 +451,8 @@ def get_build_platform():
if sys.platform == "darwin" and not plat.startswith('macosx-'):
try:
version = _macos_vers()
- machine = os.uname()[4].replace(" ", "_")
- return "macosx-%d.%d-%s" % (
- int(version[0]),
- int(version[1]),
- _macos_arch(machine),
- )
+ machine = _macos_arch(os.uname()[4].replace(" ", "_"))
+ return f"macosx-{version[0]}.{version[1]}-{machine}"
except ValueError:
# if someone is running a non-Mac darwin system, this will fall
# through to the default implementation
@@ -492,7 +490,7 @@ def compatible_platforms(provided: str | None, required: str | None) -> bool:
provDarwin = darwinVersionString.match(provided)
if provDarwin:
dversion = int(provDarwin.group(1))
- macosversion = "%s.%s" % (reqMac.group(1), reqMac.group(2))
+ macosversion = f"{reqMac.group(1)}.{reqMac.group(2)}"
if (
dversion == 7
and macosversion >= "10.3"
@@ -875,9 +873,7 @@ class WorkingSet:
# Mapping of requirement to set of distributions that required it;
# useful for reporting info about conflicts.
- required_by: collections.defaultdict[Requirement, set[str]] = (
- collections.defaultdict(set)
- )
+ required_by = collections.defaultdict[Requirement, set[str]](set)
while requirements:
# process dependencies breadth-first
@@ -1316,7 +1312,7 @@ class Environment:
for dist in other[project]:
self.add(dist)
else:
- raise TypeError("Can't add %r to environment" % (other,))
+ raise TypeError(f"Can't add {other!r} to environment")
return self
def __add__(self, other: Distribution | Environment) -> Self:
@@ -1699,7 +1695,7 @@ class NullProvider:
except UnicodeDecodeError as exc:
# Include the path in the error message to simplify
# troubleshooting, and without changing the exception type.
- exc.reason += ' in {} file at path: {}'.format(name, path)
+ exc.reason += f' in {name} file at path: {path}'
raise
def get_metadata_lines(self, name: str) -> Iterator[str]:
@@ -2018,7 +2014,7 @@ class ZipProvider(EggProvider):
return ''
if fspath.startswith(self.zip_pre):
return fspath[len(self.zip_pre) :]
- raise AssertionError("%s is not a subpath of %s" % (fspath, self.zip_pre))
+ raise AssertionError(f"{fspath} is not a subpath of {self.zip_pre}")
def _parts(self, zip_path):
# Convert a zipfile subpath into an egg-relative path part list.
@@ -2026,7 +2022,7 @@ class ZipProvider(EggProvider):
fspath = self.zip_pre + zip_path
if fspath.startswith(self.egg_root + os.sep):
return fspath[len(self.egg_root) + 1 :].split(os.sep)
- raise AssertionError("%s is not a subpath of %s" % (fspath, self.egg_root))
+ raise AssertionError(f"{fspath} is not a subpath of {self.egg_root}")
@property
def zipinfo(self):
@@ -2729,15 +2725,16 @@ class EntryPoint:
self.dist = dist
def __str__(self) -> str:
- s = "%s = %s" % (self.name, self.module_name)
+ s = f"{self.name} = {self.module_name}"
if self.attrs:
s += ':' + '.'.join(self.attrs)
if self.extras:
- s += ' [%s]' % ','.join(self.extras)
+ extras = ','.join(self.extras)
+ s += f' [{extras}]'
return s
def __repr__(self) -> str:
- return "EntryPoint.parse(%r)" % str(self)
+ return f"EntryPoint.parse({str(self)!r})"
@overload
def load(
@@ -3049,9 +3046,7 @@ class Distribution:
version = self._get_version()
if version is None:
path = self._get_metadata_path_for_display(self.PKG_INFO)
- msg = ("Missing 'Version:' header and/or {} file at path: {}").format(
- self.PKG_INFO, path
- )
+ msg = f"Missing 'Version:' header and/or {self.PKG_INFO} file at path: {path}"
raise ValueError(msg, self) from e
return version
@@ -3107,9 +3102,7 @@ class Distribution:
try:
deps.extend(dm[safe_extra(ext)])
except KeyError as e:
- raise UnknownExtra(
- "%s has no such extra feature %r" % (self, ext)
- ) from e
+ raise UnknownExtra(f"{self} has no such extra feature {ext!r}") from e
return deps
def _get_metadata_path_for_display(self, name):
@@ -3150,11 +3143,7 @@ class Distribution:
def egg_name(self):
"""Return what this distribution's standard .egg filename should be"""
- filename = "%s-%s-py%s" % (
- to_filename(self.project_name),
- to_filename(self.version),
- self.py_version or PY_MAJOR,
- )
+ filename = f"{to_filename(self.project_name)}-{to_filename(self.version)}-py{self.py_version or PY_MAJOR}"
if self.platform:
filename += '-' + self.platform
@@ -3162,7 +3151,7 @@ class Distribution:
def __repr__(self) -> str:
if self.location:
- return "%s (%s)" % (self, self.location)
+ return f"{self} ({self.location})"
else:
return str(self)
@@ -3172,7 +3161,7 @@ class Distribution:
except ValueError:
version = None
version = version or "[unknown version]"
- return "%s %s" % (self.project_name, version)
+ return f"{self.project_name} {version}"
def __getattr__(self, attr: str):
"""Delegate all unrecognized public attributes to .metadata provider"""
@@ -3200,9 +3189,9 @@ class Distribution:
def as_requirement(self):
"""Return a ``Requirement`` that matches this distribution exactly"""
if isinstance(self.parsed_version, packaging.version.Version):
- spec = "%s==%s" % (self.project_name, self.parsed_version)
+ spec = f"{self.project_name}=={self.parsed_version}"
else:
- spec = "%s===%s" % (self.project_name, self.parsed_version)
+ spec = f"{self.project_name}==={self.parsed_version}"
return Requirement.parse(spec)
@@ -3210,7 +3199,7 @@ class Distribution:
"""Return the `name` entry point of `group` or raise ImportError"""
ep = self.get_entry_info(group, name)
if ep is None:
- raise ImportError("Entry point %r not found" % ((group, name),))
+ raise ImportError(f"Entry point {(group, name)!r} not found")
return ep.load()
@overload
@@ -3327,8 +3316,8 @@ class Distribution:
):
continue
issue_warning(
- "Module %s was already imported from %s, but %s is being added"
- " to sys.path" % (modname, fn, self.location),
+ f"Module {modname} was already imported from {fn}, "
+ f"but {self.location} is being added to sys.path",
)
def has_version(self) -> bool:
@@ -3512,7 +3501,7 @@ class Requirement(packaging.requirements.Requirement):
return self.__hash
def __repr__(self) -> str:
- return "Requirement.parse(%r)" % str(self)
+ return f"Requirement.parse({str(self)!r})"
@staticmethod
def parse(s: str | Iterable[str]) -> Requirement:
diff --git a/contrib/python/setuptools/py3/setuptools/__init__.py b/contrib/python/setuptools/py3/setuptools/__init__.py
index 4f5c01708a..64464dfaa3 100644
--- a/contrib/python/setuptools/py3/setuptools/__init__.py
+++ b/contrib/python/setuptools/py3/setuptools/__init__.py
@@ -181,9 +181,7 @@ class Command(_Command):
setattr(self, option, default)
return default
elif not isinstance(val, str):
- raise DistutilsOptionError(
- "'%s' must be a %s (got `%s`)" % (option, what, val)
- )
+ raise DistutilsOptionError(f"'{option}' must be a {what} (got `{val}`)")
return val
def ensure_string_list(self, option: str) -> None:
@@ -210,7 +208,7 @@ class Command(_Command):
ok = False
if not ok:
raise DistutilsOptionError(
- "'%s' must be a list of strings (got %r)" % (option, val)
+ f"'{option}' must be a list of strings (got {val!r})"
)
@overload
diff --git a/contrib/python/setuptools/py3/setuptools/_core_metadata.py b/contrib/python/setuptools/py3/setuptools/_core_metadata.py
index 2e9c48a77b..642b80df31 100644
--- a/contrib/python/setuptools/py3/setuptools/_core_metadata.py
+++ b/contrib/python/setuptools/py3/setuptools/_core_metadata.py
@@ -150,7 +150,7 @@ def write_pkg_file(self, file): # noqa: C901 # is too complex (14) # FIXME
version = self.get_metadata_version()
def write_field(key, value):
- file.write("%s: %s\n" % (key, value))
+ file.write(f"{key}: {value}\n")
write_field('Metadata-Version', str(version))
write_field('Name', self.get_name())
@@ -178,8 +178,8 @@ def write_pkg_file(self, file): # noqa: C901 # is too complex (14) # FIXME
if license:
write_field('License', rfc822_escape(license))
- for project_url in self.project_urls.items():
- write_field('Project-URL', '%s, %s' % project_url)
+ for label, url in self.project_urls.items():
+ write_field('Project-URL', f'{label}, {url}')
keywords = ','.join(self.get_keywords())
if keywords:
@@ -209,7 +209,7 @@ def write_pkg_file(self, file): # noqa: C901 # is too complex (14) # FIXME
long_description = self.get_long_description()
if long_description:
- file.write("\n%s" % long_description)
+ file.write(f"\n{long_description}")
if not long_description.endswith("\n"):
file.write("\n")
diff --git a/contrib/python/setuptools/py3/setuptools/_distutils/ccompiler.py b/contrib/python/setuptools/py3/setuptools/_distutils/ccompiler.py
index 5e73e56d02..714f13d8d3 100644
--- a/contrib/python/setuptools/py3/setuptools/_distutils/ccompiler.py
+++ b/contrib/python/setuptools/py3/setuptools/_distutils/ccompiler.py
@@ -4,6 +4,7 @@ Contains CCompiler, an abstract base class that defines the interface
for the Distutils compiler abstraction model."""
import os
+import pathlib
import re
import sys
import types
@@ -969,27 +970,33 @@ int main (int argc, char **argv) {{
return dict.fromkeys(self.src_extensions, self.obj_extension)
def _make_out_path(self, output_dir, strip_dir, src_name):
- base, ext = os.path.splitext(src_name)
- base = self._make_relative(base)
+ return self._make_out_path_exts(
+ output_dir, strip_dir, src_name, self.out_extensions
+ )
+
+ @classmethod
+ def _make_out_path_exts(cls, output_dir, strip_dir, src_name, extensions):
+ r"""
+ >>> exts = {'.c': '.o'}
+ >>> CCompiler._make_out_path_exts('.', False, '/foo/bar.c', exts).replace('\\', '/')
+ './foo/bar.o'
+ >>> CCompiler._make_out_path_exts('.', True, '/foo/bar.c', exts).replace('\\', '/')
+ './bar.o'
+ """
+ src = pathlib.PurePath(src_name)
+ # Ensure base is relative to honor output_dir (python/cpython#37775).
+ base = cls._make_relative(src)
try:
- new_ext = self.out_extensions[ext]
+ new_ext = extensions[src.suffix]
except LookupError:
- raise UnknownFileError(f"unknown file type '{ext}' (from '{src_name}')")
+ raise UnknownFileError(f"unknown file type '{src.suffix}' (from '{src}')")
if strip_dir:
- base = os.path.basename(base)
- return os.path.join(output_dir, base + new_ext)
+ base = pathlib.PurePath(base.name)
+ return os.path.join(output_dir, base.with_suffix(new_ext))
@staticmethod
- def _make_relative(base):
- """
- In order to ensure that a filename always honors the
- indicated output_dir, make sure it's relative.
- Ref python/cpython#37775.
- """
- # Chop off the drive
- no_drive = os.path.splitdrive(base)[1]
- # If abs, chop off leading /
- return no_drive[os.path.isabs(no_drive) :]
+ def _make_relative(base: pathlib.Path):
+ return base.relative_to(base.anchor)
def shared_object_filename(self, basename, strip_dir=False, output_dir=''):
assert output_dir is not None
diff --git a/contrib/python/setuptools/py3/setuptools/_distutils/cmd.py b/contrib/python/setuptools/py3/setuptools/_distutils/cmd.py
index 2bb97956ab..9c6fa6566c 100644
--- a/contrib/python/setuptools/py3/setuptools/_distutils/cmd.py
+++ b/contrib/python/setuptools/py3/setuptools/_distutils/cmd.py
@@ -4,15 +4,21 @@ Provides the Command class, the base class for the command classes
in the distutils.command package.
"""
+from __future__ import annotations
+
import logging
import os
import re
import sys
+from collections.abc import Callable
+from typing import Any, ClassVar, TypeVar, overload
from . import _modified, archive_util, dir_util, file_util, util
from ._log import log
from .errors import DistutilsOptionError
+_CommandT = TypeVar("_CommandT", bound="Command")
+
class Command:
"""Abstract base class for defining command classes, the "worker bees"
@@ -44,7 +50,14 @@ class Command:
# 'sub_commands' is usually defined at the *end* of a class, because
# predicates can be unbound methods, so they must already have been
# defined. The canonical example is the "install" command.
- sub_commands = []
+ sub_commands: ClassVar[ # Any to work around variance issues
+ list[tuple[str, Callable[[Any], bool] | None]]
+ ] = []
+
+ user_options: ClassVar[
+ # Specifying both because list is invariant. Avoids mypy override assignment issues
+ list[tuple[str, str, str]] | list[tuple[str, str | None, str]]
+ ] = []
# -- Creation/initialization methods -------------------------------
@@ -305,7 +318,17 @@ class Command:
# XXX rename to 'get_reinitialized_command()'? (should do the
# same in dist.py, if so)
- def reinitialize_command(self, command, reinit_subcommands=False):
+ @overload
+ def reinitialize_command(
+ self, command: str, reinit_subcommands: bool = False
+ ) -> Command: ...
+ @overload
+ def reinitialize_command(
+ self, command: _CommandT, reinit_subcommands: bool = False
+ ) -> _CommandT: ...
+ def reinitialize_command(
+ self, command: str | Command, reinit_subcommands=False
+ ) -> Command:
return self.distribution.reinitialize_command(command, reinit_subcommands)
def run_command(self, command):
diff --git a/contrib/python/setuptools/py3/setuptools/_distutils/command/bdist.py b/contrib/python/setuptools/py3/setuptools/_distutils/command/bdist.py
index f334075159..1ec3c35f40 100644
--- a/contrib/python/setuptools/py3/setuptools/_distutils/command/bdist.py
+++ b/contrib/python/setuptools/py3/setuptools/_distutils/command/bdist.py
@@ -5,6 +5,7 @@ distribution)."""
import os
import warnings
+from typing import ClassVar
from ..core import Command
from ..errors import DistutilsOptionError, DistutilsPlatformError
@@ -23,7 +24,7 @@ def show_formats():
pretty_printer.print_help("List of available distribution formats:")
-class ListCompat(dict):
+class ListCompat(dict[str, tuple[str, str]]):
# adapter to allow for Setuptools compatibility in format_commands
def append(self, item):
warnings.warn(
@@ -70,7 +71,7 @@ class bdist(Command):
]
# The following commands do not take a format option from bdist
- no_format_option = ('bdist_rpm',)
+ no_format_option: ClassVar[tuple[str, ...]] = ('bdist_rpm',)
# This won't do in reality: will need to distinguish RPM-ish Linux,
# Debian-ish Linux, Solaris, FreeBSD, ..., Windows, Mac OS.
diff --git a/contrib/python/setuptools/py3/setuptools/_distutils/command/build.py b/contrib/python/setuptools/py3/setuptools/_distutils/command/build.py
index caf55073af..ccd2c706a3 100644
--- a/contrib/python/setuptools/py3/setuptools/_distutils/command/build.py
+++ b/contrib/python/setuptools/py3/setuptools/_distutils/command/build.py
@@ -113,7 +113,8 @@ class build(Command):
self.build_temp = os.path.join(self.build_base, 'temp' + plat_specifier)
if self.build_scripts is None:
self.build_scripts = os.path.join(
- self.build_base, 'scripts-%d.%d' % sys.version_info[:2]
+ self.build_base,
+ f'scripts-{sys.version_info.major}.{sys.version_info.minor}',
)
if self.executable is None and sys.executable:
diff --git a/contrib/python/setuptools/py3/setuptools/_distutils/command/build_clib.py b/contrib/python/setuptools/py3/setuptools/_distutils/command/build_clib.py
index a600d09373..3e1832768b 100644
--- a/contrib/python/setuptools/py3/setuptools/_distutils/command/build_clib.py
+++ b/contrib/python/setuptools/py3/setuptools/_distutils/command/build_clib.py
@@ -16,6 +16,7 @@ module."""
import os
from distutils._log import log
+from typing import ClassVar
from ..core import Command
from ..errors import DistutilsSetupError
@@ -31,7 +32,7 @@ def show_compilers():
class build_clib(Command):
description = "build C/C++ libraries used by Python extensions"
- user_options = [
+ user_options: ClassVar[list[tuple[str, str, str]]] = [
('build-clib=', 'b', "directory to build C/C++ libraries to"),
('build-temp=', 't', "directory to put temporary build by-products"),
('debug', 'g', "compile with debugging information"),
@@ -138,8 +139,7 @@ class build_clib(Command):
if '/' in name or (os.sep != '/' and os.sep in name):
raise DistutilsSetupError(
- f"bad library name '{lib[0]}': "
- "may not contain directory separators"
+ f"bad library name '{lib[0]}': may not contain directory separators"
)
if not isinstance(build_info, dict):
diff --git a/contrib/python/setuptools/py3/setuptools/_distutils/command/build_ext.py b/contrib/python/setuptools/py3/setuptools/_distutils/command/build_ext.py
index a7e3038be6..cf60bd0ad8 100644
--- a/contrib/python/setuptools/py3/setuptools/_distutils/command/build_ext.py
+++ b/contrib/python/setuptools/py3/setuptools/_distutils/command/build_ext.py
@@ -23,7 +23,7 @@ from ..errors import (
)
from ..extension import Extension
from ..sysconfig import customize_compiler, get_config_h_filename, get_python_version
-from ..util import get_platform, is_mingw
+from ..util import get_platform, is_freethreaded, is_mingw
# An extension name is just a dot-separated list of Python NAMEs (ie.
# the same as a fully-qualified module name).
@@ -333,6 +333,12 @@ class build_ext(Command):
if os.name == 'nt' and self.plat_name != get_platform():
self.compiler.initialize(self.plat_name)
+ # The official Windows free threaded Python installer doesn't set
+ # Py_GIL_DISABLED because its pyconfig.h is shared with the
+ # default build, so define it here (pypa/setuptools#4662).
+ if os.name == 'nt' and is_freethreaded():
+ self.compiler.define_macro('Py_GIL_DISABLED', '1')
+
# And make sure that any compile/link-related options (which might
# come from the command-line or from the setup script) are set in
# that CCompiler object -- that way, they automatically apply to
@@ -437,8 +443,7 @@ class build_ext(Command):
for macro in macros:
if not (isinstance(macro, tuple) and len(macro) in (1, 2)):
raise DistutilsSetupError(
- "'macros' element of build info dict "
- "must be 1- or 2-tuple"
+ "'macros' element of build info dict must be 1- or 2-tuple"
)
if len(macro) == 1:
ext.undef_macros.append(macro[0])
@@ -666,8 +671,7 @@ class build_ext(Command):
return "swig.exe"
else:
raise DistutilsPlatformError(
- "I don't know how to find (much less run) SWIG "
- f"on platform '{os.name}'"
+ f"I don't know how to find (much less run) SWIG on platform '{os.name}'"
)
# -- Name generators -----------------------------------------------
diff --git a/contrib/python/setuptools/py3/setuptools/_distutils/command/build_scripts.py b/contrib/python/setuptools/py3/setuptools/_distutils/command/build_scripts.py
index 9e5963c243..1c6fd3caff 100644
--- a/contrib/python/setuptools/py3/setuptools/_distutils/command/build_scripts.py
+++ b/contrib/python/setuptools/py3/setuptools/_distutils/command/build_scripts.py
@@ -8,6 +8,7 @@ import tokenize
from distutils import sysconfig
from distutils._log import log
from stat import ST_MODE
+from typing import ClassVar
from .._modified import newer
from ..core import Command
@@ -25,7 +26,7 @@ first_line_re = shebang_pattern
class build_scripts(Command):
description = "\"build\" scripts (copy and fixup #! line)"
- user_options = [
+ user_options: ClassVar[list[tuple[str, str, str]]] = [
('build-dir=', 'd', "directory to \"build\" (copy) to"),
('force', 'f', "forcibly build everything (ignore file timestamps"),
('executable=', 'e', "specify final destination interpreter path"),
diff --git a/contrib/python/setuptools/py3/setuptools/_distutils/command/check.py b/contrib/python/setuptools/py3/setuptools/_distutils/command/check.py
index 93d754e73d..078c1ce87e 100644
--- a/contrib/python/setuptools/py3/setuptools/_distutils/command/check.py
+++ b/contrib/python/setuptools/py3/setuptools/_distutils/command/check.py
@@ -4,6 +4,7 @@ Implements the Distutils 'check' command.
"""
import contextlib
+from typing import ClassVar
from ..core import Command
from ..errors import DistutilsSetupError
@@ -41,15 +42,12 @@ class check(Command):
"""This command checks the meta-data of the package."""
description = "perform some checks on the package"
- user_options = [
+ user_options: ClassVar[list[tuple[str, str, str]]] = [
('metadata', 'm', 'Verify meta-data'),
(
'restructuredtext',
'r',
- (
- 'Checks if long string meta-data syntax '
- 'are reStructuredText-compliant'
- ),
+ 'Checks if long string meta-data syntax are reStructuredText-compliant',
),
('strict', 's', 'Will exit with an error if a check fails'),
]
diff --git a/contrib/python/setuptools/py3/setuptools/_distutils/command/install.py b/contrib/python/setuptools/py3/setuptools/_distutils/command/install.py
index ceb453e041..9400995024 100644
--- a/contrib/python/setuptools/py3/setuptools/_distutils/command/install.py
+++ b/contrib/python/setuptools/py3/setuptools/_distutils/command/install.py
@@ -407,8 +407,8 @@ class install(Command):
'dist_version': self.distribution.get_version(),
'dist_fullname': self.distribution.get_fullname(),
'py_version': py_version,
- 'py_version_short': '%d.%d' % sys.version_info[:2],
- 'py_version_nodot': '%d%d' % sys.version_info[:2],
+ 'py_version_short': f'{sys.version_info.major}.{sys.version_info.minor}',
+ 'py_version_nodot': f'{sys.version_info.major}{sys.version_info.minor}',
'sys_prefix': prefix,
'prefix': prefix,
'sys_exec_prefix': exec_prefix,
diff --git a/contrib/python/setuptools/py3/setuptools/_distutils/command/install_data.py b/contrib/python/setuptools/py3/setuptools/_distutils/command/install_data.py
index a90ec3b4d0..36f5bcc8bf 100644
--- a/contrib/python/setuptools/py3/setuptools/_distutils/command/install_data.py
+++ b/contrib/python/setuptools/py3/setuptools/_distutils/command/install_data.py
@@ -9,7 +9,7 @@ from __future__ import annotations
import functools
import os
-from typing import Iterable
+from collections.abc import Iterable
from ..core import Command
from ..util import change_root, convert_path
@@ -22,8 +22,7 @@ class install_data(Command):
(
'install-dir=',
'd',
- "base directory for installing data files "
- "[default: installation base dir]",
+ "base directory for installing data files [default: installation base dir]",
),
('root=', None, "install everything relative to this alternate root directory"),
('force', 'f', "force installation (overwrite existing files)"),
diff --git a/contrib/python/setuptools/py3/setuptools/_distutils/command/install_egg_info.py b/contrib/python/setuptools/py3/setuptools/_distutils/command/install_egg_info.py
index 4fbb3440ab..230e94ab46 100644
--- a/contrib/python/setuptools/py3/setuptools/_distutils/command/install_egg_info.py
+++ b/contrib/python/setuptools/py3/setuptools/_distutils/command/install_egg_info.py
@@ -8,6 +8,7 @@ a package's PKG-INFO metadata.
import os
import re
import sys
+from typing import ClassVar
from .. import dir_util
from .._log import log
@@ -18,7 +19,7 @@ class install_egg_info(Command):
"""Install an .egg-info file for the package"""
description = "Install package's PKG-INFO metadata as an .egg-info file"
- user_options = [
+ user_options: ClassVar[list[tuple[str, str, str]]] = [
('install-dir=', 'd', "directory to install to"),
]
@@ -31,11 +32,9 @@ class install_egg_info(Command):
Allow basename to be overridden by child class.
Ref pypa/distutils#2.
"""
- return "%s-%s-py%d.%d.egg-info" % (
- to_filename(safe_name(self.distribution.get_name())),
- to_filename(safe_version(self.distribution.get_version())),
- *sys.version_info[:2],
- )
+ name = to_filename(safe_name(self.distribution.get_name()))
+ version = to_filename(safe_version(self.distribution.get_version()))
+ return f"{name}-{version}-py{sys.version_info.major}.{sys.version_info.minor}.egg-info"
def finalize_options(self):
self.set_undefined_options('install_lib', ('install_dir', 'install_dir'))
diff --git a/contrib/python/setuptools/py3/setuptools/_distutils/command/install_headers.py b/contrib/python/setuptools/py3/setuptools/_distutils/command/install_headers.py
index fbb3b242ea..586121e089 100644
--- a/contrib/python/setuptools/py3/setuptools/_distutils/command/install_headers.py
+++ b/contrib/python/setuptools/py3/setuptools/_distutils/command/install_headers.py
@@ -3,6 +3,8 @@
Implements the Distutils 'install_headers' command, to install C/C++ header
files to the Python include directory."""
+from typing import ClassVar
+
from ..core import Command
@@ -10,7 +12,7 @@ from ..core import Command
class install_headers(Command):
description = "install C/C++ header files"
- user_options = [
+ user_options: ClassVar[list[tuple[str, str, str]]] = [
('install-dir=', 'd', "directory to install header files to"),
('force', 'f', "force installation (overwrite existing files)"),
]
diff --git a/contrib/python/setuptools/py3/setuptools/_distutils/command/sdist.py b/contrib/python/setuptools/py3/setuptools/_distutils/command/sdist.py
index d723a1c9fb..acb3a41650 100644
--- a/contrib/python/setuptools/py3/setuptools/_distutils/command/sdist.py
+++ b/contrib/python/setuptools/py3/setuptools/_distutils/command/sdist.py
@@ -8,6 +8,7 @@ from distutils import archive_util, dir_util, file_util
from distutils._log import log
from glob import glob
from itertools import filterfalse
+from typing import ClassVar
from ..core import Command
from ..errors import DistutilsOptionError, DistutilsTemplateError
@@ -114,7 +115,7 @@ class sdist(Command):
sub_commands = [('check', checking_metadata)]
- READMES = ('README', 'README.txt', 'README.rst')
+ READMES: ClassVar[tuple[str, ...]] = ('README', 'README.txt', 'README.rst')
def initialize_options(self):
# 'template' and 'manifest' are, respectively, the names of
@@ -362,8 +363,7 @@ class sdist(Command):
# convert_path function
except (DistutilsTemplateError, ValueError) as msg:
self.warn(
- "%s, line %d: %s"
- % (template.filename, template.current_line, msg)
+ f"{template.filename}, line {int(template.current_line)}: {msg}"
)
finally:
template.close()
diff --git a/contrib/python/setuptools/py3/setuptools/_distutils/compat/__init__.py b/contrib/python/setuptools/py3/setuptools/_distutils/compat/__init__.py
index e12534a32c..c715ee9cc5 100644
--- a/contrib/python/setuptools/py3/setuptools/_distutils/compat/__init__.py
+++ b/contrib/python/setuptools/py3/setuptools/_distutils/compat/__init__.py
@@ -1,7 +1,5 @@
from __future__ import annotations
-from .py38 import removeprefix
-
def consolidate_linker_args(args: list[str]) -> list[str] | str:
"""
@@ -12,4 +10,4 @@ def consolidate_linker_args(args: list[str]) -> list[str] | str:
if not all(arg.startswith('-Wl,') for arg in args):
return args
- return '-Wl,' + ','.join(removeprefix(arg, '-Wl,') for arg in args)
+ return '-Wl,' + ','.join(arg.removeprefix('-Wl,') for arg in args)
diff --git a/contrib/python/setuptools/py3/setuptools/_distutils/compat/py38.py b/contrib/python/setuptools/py3/setuptools/_distutils/compat/py38.py
deleted file mode 100644
index afe5345553..0000000000
--- a/contrib/python/setuptools/py3/setuptools/_distutils/compat/py38.py
+++ /dev/null
@@ -1,34 +0,0 @@
-import sys
-
-if sys.version_info < (3, 9):
-
- def removesuffix(self, suffix):
- # suffix='' should not call self[:-0].
- if suffix and self.endswith(suffix):
- return self[: -len(suffix)]
- else:
- return self[:]
-
- def removeprefix(self, prefix):
- if self.startswith(prefix):
- return self[len(prefix) :]
- else:
- return self[:]
-
-else:
-
- def removesuffix(self, suffix):
- return self.removesuffix(suffix)
-
- def removeprefix(self, prefix):
- return self.removeprefix(prefix)
-
-
-def aix_platform(osname, version, release):
- try:
- import _aix_support
-
- return _aix_support.aix_platform()
- except ImportError:
- pass
- return f"{osname}-{version}.{release}"
diff --git a/contrib/python/setuptools/py3/setuptools/_distutils/core.py b/contrib/python/setuptools/py3/setuptools/_distutils/core.py
index bc06091abb..bd62546bdd 100644
--- a/contrib/python/setuptools/py3/setuptools/_distutils/core.py
+++ b/contrib/python/setuptools/py3/setuptools/_distutils/core.py
@@ -6,9 +6,12 @@ indirectly provides the Distribution and Command classes, although they are
really defined in distutils.dist and distutils.cmd.
"""
+from __future__ import annotations
+
import os
import sys
import tokenize
+from collections.abc import Iterable
from .cmd import Command
from .debug import DEBUG
@@ -215,7 +218,7 @@ def run_commands(dist):
return dist
-def run_setup(script_name, script_args=None, stop_after="run"):
+def run_setup(script_name, script_args: Iterable[str] | None = None, stop_after="run"):
"""Run a setup script in a somewhat controlled environment, and
return the Distribution instance that drives things. This is useful
if you need to find out the distribution meta-data (passed as
diff --git a/contrib/python/setuptools/py3/setuptools/_distutils/dist.py b/contrib/python/setuptools/py3/setuptools/_distutils/dist.py
index 154301baff..33ed8ebd7a 100644
--- a/contrib/python/setuptools/py3/setuptools/_distutils/dist.py
+++ b/contrib/python/setuptools/py3/setuptools/_distutils/dist.py
@@ -4,6 +4,8 @@ Provides the Distribution class, which represents the module distribution
being built/installed/distributed.
"""
+from __future__ import annotations
+
import contextlib
import logging
import os
@@ -13,6 +15,7 @@ import sys
import warnings
from collections.abc import Iterable
from email import message_from_file
+from typing import TYPE_CHECKING, Literal, TypeVar, overload
from packaging.utils import canonicalize_name, canonicalize_version
@@ -27,6 +30,12 @@ from .errors import (
from .fancy_getopt import FancyGetopt, translate_longopt
from .util import check_environ, rfc822_escape, strtobool
+if TYPE_CHECKING:
+ # type-only import because of mutual dependence between these modules
+ from .cmd import Command
+
+_CommandT = TypeVar("_CommandT", bound="Command")
+
# Regex to define acceptable Distutils command names. This is not *quite*
# the same as a Python NAME -- I don't allow leading underscores. The fact
# that they're very similar is no coincidence; the default naming scheme is
@@ -139,7 +148,7 @@ Common commands: (see '--help-commands' for more)
self.dry_run = False
self.help = False
for attr in self.display_option_names:
- setattr(self, attr, 0)
+ setattr(self, attr, False)
# Store the distribution meta-data (name, version, author, and so
# forth) in a separate object -- we're getting to have enough
@@ -169,7 +178,7 @@ Common commands: (see '--help-commands' for more)
# and sys.argv[1:], but they can be overridden when the caller is
# not necessarily a setup script run from the command-line.
self.script_name = None
- self.script_args = None
+ self.script_args: list[str] | None = None
# 'command_options' is where we store command options between
# parsing them (from config files, the command-line, etc.) and when
@@ -269,6 +278,8 @@ Common commands: (see '--help-commands' for more)
self.want_user_cfg = True
if self.script_args is not None:
+ # Coerce any possible iterable from attrs into a list
+ self.script_args = list(self.script_args)
for arg in self.script_args:
if not arg.startswith('-'):
break
@@ -722,7 +733,7 @@ Common commands: (see '--help-commands' for more)
except AttributeError:
description = "(no description available)"
- print(" %-*s %s" % (max_length, cmd, description))
+ print(f" {cmd:<{max_length}} {description}")
def print_commands(self):
"""Print out a help message listing all available commands with a
@@ -829,7 +840,15 @@ Common commands: (see '--help-commands' for more)
raise DistutilsModuleError(f"invalid command '{command}'")
- def get_command_obj(self, command, create=True):
+ @overload
+ def get_command_obj(
+ self, command: str, create: Literal[True] = True
+ ) -> Command: ...
+ @overload
+ def get_command_obj(
+ self, command: str, create: Literal[False]
+ ) -> Command | None: ...
+ def get_command_obj(self, command: str, create: bool = True) -> Command | None:
"""Return the command object for 'command'. Normally this object
is cached on a previous call to 'get_command_obj()'; if no command
object for 'command' is in the cache, then we either create and
@@ -900,7 +919,17 @@ Common commands: (see '--help-commands' for more)
except ValueError as msg:
raise DistutilsOptionError(msg)
- def reinitialize_command(self, command, reinit_subcommands=False):
+ @overload
+ def reinitialize_command(
+ self, command: str, reinit_subcommands: bool = False
+ ) -> Command: ...
+ @overload
+ def reinitialize_command(
+ self, command: _CommandT, reinit_subcommands: bool = False
+ ) -> _CommandT: ...
+ def reinitialize_command(
+ self, command: str | Command, reinit_subcommands=False
+ ) -> Command:
"""Reinitializes a command to the state it was in when first
returned by 'get_command_obj()': ie., initialized but not yet
finalized. This provides the opportunity to sneak option
diff --git a/contrib/python/setuptools/py3/setuptools/_distutils/extension.py b/contrib/python/setuptools/py3/setuptools/_distutils/extension.py
index 33159079c1..e053273436 100644
--- a/contrib/python/setuptools/py3/setuptools/_distutils/extension.py
+++ b/contrib/python/setuptools/py3/setuptools/_distutils/extension.py
@@ -26,12 +26,14 @@ class Extension:
name : string
the full name of the extension, including any packages -- ie.
*not* a filename or pathname, but Python dotted name
- sources : [string | os.PathLike]
- list of source filenames, relative to the distribution root
- (where the setup script lives), in Unix form (slash-separated)
- for portability. Source files may be C, C++, SWIG (.i),
- platform-specific resource files, or whatever else is recognized
- by the "build_ext" command as source for a Python extension.
+ sources : Iterable[string | os.PathLike]
+ iterable of source filenames (except strings, which could be misinterpreted
+ as a single filename), relative to the distribution root (where the setup
+ script lives), in Unix form (slash-separated) for portability. Can be any
+ non-string iterable (list, tuple, set, etc.) containing strings or
+ PathLike objects. Source files may be C, C++, SWIG (.i), platform-specific
+ resource files, or whatever else is recognized by the "build_ext" command
+ as source for a Python extension.
include_dirs : [string]
list of directories to search for C/C++ header files (in Unix
form for portability)
@@ -105,17 +107,23 @@ class Extension:
**kw, # To catch unknown keywords
):
if not isinstance(name, str):
- raise AssertionError("'name' must be a string") # noqa: TRY004
- if not (
- isinstance(sources, list)
- and all(isinstance(v, (str, os.PathLike)) for v in sources)
- ):
- raise AssertionError(
- "'sources' must be a list of strings or PathLike objects."
+ raise TypeError("'name' must be a string")
+
+ # handle the string case first; since strings are iterable, disallow them
+ if isinstance(sources, str):
+ raise TypeError(
+ "'sources' must be an iterable of strings or PathLike objects, not a string"
+ )
+
+ # now we check if it's iterable and contains valid types
+ try:
+ self.sources = list(map(os.fspath, sources))
+ except TypeError:
+ raise TypeError(
+ "'sources' must be an iterable of strings or PathLike objects"
)
self.name = name
- self.sources = list(map(os.fspath, sources))
self.include_dirs = include_dirs or []
self.define_macros = define_macros or []
self.undef_macros = undef_macros or []
diff --git a/contrib/python/setuptools/py3/setuptools/_distutils/fancy_getopt.py b/contrib/python/setuptools/py3/setuptools/_distutils/fancy_getopt.py
index 907cc2b73c..1a1d3a05da 100644
--- a/contrib/python/setuptools/py3/setuptools/_distutils/fancy_getopt.py
+++ b/contrib/python/setuptools/py3/setuptools/_distutils/fancy_getopt.py
@@ -8,11 +8,14 @@ additional features:
* options set attributes of a passed-in object
"""
+from __future__ import annotations
+
import getopt
import re
import string
import sys
-from typing import Any, Sequence
+from collections.abc import Sequence
+from typing import Any
from .errors import DistutilsArgError, DistutilsGetoptError
@@ -167,8 +170,7 @@ class FancyGetopt:
if not ((short is None) or (isinstance(short, str) and len(short) == 1)):
raise DistutilsGetoptError(
- f"invalid short option '{short}': "
- "must a single character or None"
+ f"invalid short option '{short}': must a single character or None"
)
self.repeat[long] = repeat
@@ -219,7 +221,7 @@ class FancyGetopt:
self.short_opts.append(short)
self.short2long[short[0]] = long
- def getopt(self, args=None, object=None): # noqa: C901
+ def getopt(self, args: Sequence[str] | None = None, object=None): # noqa: C901
"""Parse command-line options in args. Store as attributes on object.
If 'args' is None or not supplied, uses 'sys.argv[1:]'. If
@@ -351,18 +353,18 @@ class FancyGetopt:
# Case 1: no short option at all (makes life easy)
if short is None:
if text:
- lines.append(" --%-*s %s" % (max_opt, long, text[0]))
+ lines.append(f" --{long:<{max_opt}} {text[0]}")
else:
- lines.append(" --%-*s " % (max_opt, long))
+ lines.append(f" --{long:<{max_opt}}")
# Case 2: we have a short option, so we have to include it
# just after the long option
else:
opt_names = f"{long} (-{short})"
if text:
- lines.append(" --%-*s %s" % (max_opt, opt_names, text[0]))
+ lines.append(f" --{opt_names:<{max_opt}} {text[0]}")
else:
- lines.append(" --%-*s" % opt_names)
+ lines.append(f" --{opt_names:<{max_opt}}")
for ell in text[1:]:
lines.append(big_indent + ell)
@@ -375,7 +377,7 @@ class FancyGetopt:
file.write(line + "\n")
-def fancy_getopt(options, negative_opt, object, args):
+def fancy_getopt(options, negative_opt, object, args: Sequence[str] | None):
parser = FancyGetopt(options)
parser.set_negative_aliases(negative_opt)
return parser.getopt(args, object)
@@ -464,6 +466,6 @@ How *do* you spell that odd word, anyways?
say, "How should I know?"].)"""
for w in (10, 20, 30, 40):
- print("width: %d" % w)
+ print(f"width: {w}")
print("\n".join(wrap_text(text, w)))
print()
diff --git a/contrib/python/setuptools/py3/setuptools/_distutils/file_util.py b/contrib/python/setuptools/py3/setuptools/_distutils/file_util.py
index 85ee4dafcb..0acc8cb84b 100644
--- a/contrib/python/setuptools/py3/setuptools/_distutils/file_util.py
+++ b/contrib/python/setuptools/py3/setuptools/_distutils/file_util.py
@@ -118,7 +118,7 @@ def copy_file( # noqa: C901
if update and not newer(src, dst):
if verbose >= 1:
log.debug("not copying %s (output up-to-date)", src)
- return (dst, 0)
+ return (dst, False)
try:
action = _copy_action[link]
@@ -132,7 +132,7 @@ def copy_file( # noqa: C901
log.info("%s %s -> %s", action, src, dst)
if dry_run:
- return (dst, 1)
+ return (dst, True)
# If linking (hard or symbolic), use the appropriate system call
# (Unix only, of course, but that's the caller's responsibility)
@@ -146,11 +146,11 @@ def copy_file( # noqa: C901
# even under Unix, see issue #8876).
pass
else:
- return (dst, 1)
+ return (dst, True)
elif link == 'sym':
if not (os.path.exists(dst) and os.path.samefile(src, dst)):
os.symlink(src, dst)
- return (dst, 1)
+ return (dst, True)
# Otherwise (non-Mac, not linking), copy the file contents and
# (optionally) copy the times and mode.
@@ -165,7 +165,7 @@ def copy_file( # noqa: C901
if preserve_mode:
os.chmod(dst, S_IMODE(st[ST_MODE]))
- return (dst, 1)
+ return (dst, True)
# XXX I suspect this is Unix-specific -- need porting help!
diff --git a/contrib/python/setuptools/py3/setuptools/_distutils/filelist.py b/contrib/python/setuptools/py3/setuptools/_distutils/filelist.py
index 44ae9e67ef..9857b19549 100644
--- a/contrib/python/setuptools/py3/setuptools/_distutils/filelist.py
+++ b/contrib/python/setuptools/py3/setuptools/_distutils/filelist.py
@@ -127,10 +127,7 @@ class FileList:
for pattern in patterns:
if not self.exclude_pattern(pattern, anchor=True):
log.warning(
- (
- "warning: no previously-included files "
- "found matching '%s'"
- ),
+ "warning: no previously-included files found matching '%s'",
pattern,
)
diff --git a/contrib/python/setuptools/py3/setuptools/_distutils/spawn.py b/contrib/python/setuptools/py3/setuptools/_distutils/spawn.py
index 107b011397..ba280334d1 100644
--- a/contrib/python/setuptools/py3/setuptools/_distutils/spawn.py
+++ b/contrib/python/setuptools/py3/setuptools/_distutils/spawn.py
@@ -12,7 +12,7 @@ import shutil
import subprocess
import sys
import warnings
-from typing import Mapping
+from collections.abc import Mapping
from ._log import log
from .debug import DEBUG
diff --git a/contrib/python/setuptools/py3/setuptools/_distutils/sysconfig.py b/contrib/python/setuptools/py3/setuptools/_distutils/sysconfig.py
index da1eecbe7e..ef3def83eb 100644
--- a/contrib/python/setuptools/py3/setuptools/_distutils/sysconfig.py
+++ b/contrib/python/setuptools/py3/setuptools/_distutils/sysconfig.py
@@ -107,7 +107,7 @@ def get_python_version():
leaving off the patchlevel. Sample return values could be '1.5'
or '2.2'.
"""
- return '%d.%d' % sys.version_info[:2]
+ return f'{sys.version_info.major}.{sys.version_info.minor}'
def get_python_inc(plat_specific=False, prefix=None):
@@ -340,7 +340,7 @@ def customize_compiler(compiler):
ldshared = _add_flags(ldshared, 'LD')
ldcxxshared = _add_flags(ldcxxshared, 'LD')
- cflags = _add_flags(cflags, 'C')
+ cflags = os.environ.get('CFLAGS', cflags)
ldshared = _add_flags(ldshared, 'C')
cxxflags = os.environ.get('CXXFLAGS', cxxflags)
ldcxxshared = _add_flags(ldcxxshared, 'CXX')
diff --git a/contrib/python/setuptools/py3/setuptools/_distutils/text_file.py b/contrib/python/setuptools/py3/setuptools/_distutils/text_file.py
index fec29c73b0..89d9048d59 100644
--- a/contrib/python/setuptools/py3/setuptools/_distutils/text_file.py
+++ b/contrib/python/setuptools/py3/setuptools/_distutils/text_file.py
@@ -133,9 +133,9 @@ class TextFile:
line = self.current_line
outmsg.append(self.filename + ", ")
if isinstance(line, (list, tuple)):
- outmsg.append("lines %d-%d: " % tuple(line))
+ outmsg.append("lines {}-{}: ".format(*line))
else:
- outmsg.append("line %d: " % line)
+ outmsg.append(f"line {int(line)}: ")
outmsg.append(str(msg))
return "".join(outmsg)
diff --git a/contrib/python/setuptools/py3/setuptools/_distutils/util.py b/contrib/python/setuptools/py3/setuptools/_distutils/util.py
index 609c1a50cd..83ad39e958 100644
--- a/contrib/python/setuptools/py3/setuptools/_distutils/util.py
+++ b/contrib/python/setuptools/py3/setuptools/_distutils/util.py
@@ -25,7 +25,7 @@ from .errors import DistutilsByteCompileError, DistutilsPlatformError
from .spawn import spawn
-def get_host_platform():
+def get_host_platform() -> str:
"""
Return a string that identifies the current platform. Use this
function to distinguish platform-specific build directories and
@@ -34,15 +34,7 @@ def get_host_platform():
# This function initially exposed platforms as defined in Python 3.9
# even with older Python versions when distutils was split out.
- # Now it delegates to stdlib sysconfig, but maintains compatibility.
-
- if sys.version_info < (3, 9):
- if os.name == "posix" and hasattr(os, 'uname'):
- osname, host, release, version, machine = os.uname()
- if osname[:3] == "aix":
- from .compat.py38 import aix_platform
-
- return aix_platform(osname, version, release)
+ # Now it delegates to stdlib sysconfig.
return sysconfig.get_platform()
@@ -288,7 +280,7 @@ def split_quoted(s):
elif s[end] == '"': # slurp doubly-quoted string
m = _dquote_re.match(s, end)
else:
- raise RuntimeError("this can't happen (bad char '%c')" % s[end])
+ raise RuntimeError(f"this can't happen (bad char '{s[end]}')")
if m is None:
raise ValueError(f"bad string (mismatched {s[end]} quotes?)")
@@ -503,3 +495,8 @@ def is_mingw():
get_platform() starts with 'mingw'.
"""
return sys.platform == 'win32' and get_platform().startswith('mingw')
+
+
+def is_freethreaded():
+ """Return True if the Python interpreter is built with free threading support."""
+ return bool(sysconfig.get_config_var('Py_GIL_DISABLED'))
diff --git a/contrib/python/setuptools/py3/setuptools/_distutils/version.py b/contrib/python/setuptools/py3/setuptools/_distutils/version.py
index 942b56bf94..2223ee9c8c 100644
--- a/contrib/python/setuptools/py3/setuptools/_distutils/version.py
+++ b/contrib/python/setuptools/py3/setuptools/_distutils/version.py
@@ -53,8 +53,7 @@ class Version:
if vstring:
self.parse(vstring)
warnings.warn(
- "distutils Version classes are deprecated. "
- "Use packaging.version instead.",
+ "distutils Version classes are deprecated. Use packaging.version instead.",
DeprecationWarning,
stacklevel=2,
)
diff --git a/contrib/python/setuptools/py3/setuptools/_imp.py b/contrib/python/setuptools/py3/setuptools/_imp.py
index bddbf6a683..f1d9f29218 100644
--- a/contrib/python/setuptools/py3/setuptools/_imp.py
+++ b/contrib/python/setuptools/py3/setuptools/_imp.py
@@ -29,7 +29,7 @@ def find_module(module, paths=None):
"""Just like 'imp.find_module()', but with package support"""
spec = find_spec(module, paths)
if spec is None:
- raise ImportError("Can't find %s" % module)
+ raise ImportError(f"Can't find {module}")
if not spec.has_location and hasattr(spec, 'submodule_search_locations'):
spec = importlib.util.spec_from_loader('__init__.py', spec.loader)
@@ -76,12 +76,12 @@ def find_module(module, paths=None):
def get_frozen_object(module, paths=None):
spec = find_spec(module, paths)
if not spec:
- raise ImportError("Can't find %s" % module)
+ raise ImportError(f"Can't find {module}")
return spec.loader.get_code(module)
def get_module(module, paths, info):
spec = find_spec(module, paths)
if not spec:
- raise ImportError("Can't find %s" % module)
+ raise ImportError(f"Can't find {module}")
return module_from_spec(spec)
diff --git a/contrib/python/setuptools/py3/setuptools/archive_util.py b/contrib/python/setuptools/py3/setuptools/archive_util.py
index cd9cf9c08f..1a02010bb2 100644
--- a/contrib/python/setuptools/py3/setuptools/archive_util.py
+++ b/contrib/python/setuptools/py3/setuptools/archive_util.py
@@ -62,7 +62,7 @@ def unpack_archive(
else:
return
else:
- raise UnrecognizedFormat("Not a recognized archive type: %s" % filename)
+ raise UnrecognizedFormat(f"Not a recognized archive type: {filename}")
def unpack_directory(filename, extract_dir, progress_filter=default_filter) -> None:
@@ -71,7 +71,7 @@ def unpack_directory(filename, extract_dir, progress_filter=default_filter) -> N
Raises ``UnrecognizedFormat`` if `filename` is not a directory
"""
if not os.path.isdir(filename):
- raise UnrecognizedFormat("%s is not a directory" % filename)
+ raise UnrecognizedFormat(f"{filename} is not a directory")
paths = {
filename: ('', extract_dir),
@@ -101,7 +101,7 @@ def unpack_zipfile(filename, extract_dir, progress_filter=default_filter) -> Non
"""
if not zipfile.is_zipfile(filename):
- raise UnrecognizedFormat("%s is not a zip file" % (filename,))
+ raise UnrecognizedFormat(f"{filename} is not a zip file")
with zipfile.ZipFile(filename) as z:
_unpack_zipfile_obj(z, extract_dir, progress_filter)
@@ -198,7 +198,7 @@ def unpack_tarfile(filename, extract_dir, progress_filter=default_filter) -> boo
tarobj = tarfile.open(filename)
except tarfile.TarError as e:
raise UnrecognizedFormat(
- "%s is not a compressed or uncompressed tar file" % (filename,)
+ f"{filename} is not a compressed or uncompressed tar file"
) from e
for member, final_dst in _iter_open_tar(
diff --git a/contrib/python/setuptools/py3/setuptools/command/_requirestxt.py b/contrib/python/setuptools/py3/setuptools/command/_requirestxt.py
index 171f41b87e..9029b12514 100644
--- a/contrib/python/setuptools/py3/setuptools/command/_requirestxt.py
+++ b/contrib/python/setuptools/py3/setuptools/command/_requirestxt.py
@@ -38,13 +38,13 @@ def _prepare(
def _convert_extras_requirements(
extras_require: Mapping[str, _StrOrIter],
-) -> Mapping[str, _Ordered[Requirement]]:
+) -> defaultdict[str, _Ordered[Requirement]]:
"""
Convert requirements in `extras_require` of the form
`"extra": ["barbazquux; {marker}"]` to
`"extra:{marker}": ["barbazquux"]`.
"""
- output: Mapping[str, _Ordered[Requirement]] = defaultdict(dict)
+ output = defaultdict[str, _Ordered[Requirement]](dict)
for section, v in extras_require.items():
# Do not strip empty sections.
output[section]
diff --git a/contrib/python/setuptools/py3/setuptools/command/alias.py b/contrib/python/setuptools/py3/setuptools/command/alias.py
index 388830d7a6..b8d74af71d 100644
--- a/contrib/python/setuptools/py3/setuptools/command/alias.py
+++ b/contrib/python/setuptools/py3/setuptools/command/alias.py
@@ -55,7 +55,7 @@ class alias(option_base):
print("setup.py alias", format_alias(alias, aliases))
return
else:
- print("No alias definition found for %r" % alias)
+ print(f"No alias definition found for {alias!r}")
return
else:
alias = self.args[0]
@@ -73,5 +73,5 @@ def format_alias(name, aliases):
elif source == config_file('local'):
source = ''
else:
- source = '--filename=%r' % source
+ source = f'--filename={source!r}'
return source + name + ' ' + command
diff --git a/contrib/python/setuptools/py3/setuptools/command/bdist_egg.py b/contrib/python/setuptools/py3/setuptools/command/bdist_egg.py
index ac3e6ef1f9..7f66c3ba6a 100644
--- a/contrib/python/setuptools/py3/setuptools/command/bdist_egg.py
+++ b/contrib/python/setuptools/py3/setuptools/command/bdist_egg.py
@@ -69,7 +69,7 @@ def write_stub(resource, pyfile) -> None:
class bdist_egg(Command):
- description = "create an \"egg\" distribution"
+ description = 'create an "egg" distribution'
user_options = [
('bdist-dir=', 'b', "temporary directory for creating the distribution"),
@@ -263,7 +263,7 @@ class bdist_egg(Command):
pattern = r'(?P<name>.+)\.(?P<magic>[^.]+)\.pyc'
m = re.match(pattern, name)
path_new = os.path.join(base, os.pardir, m.group('name') + '.pyc')
- log.info("Renaming file from [%s] to [%s]" % (path_old, path_new))
+ log.info(f"Renaming file from [{path_old}] to [{path_new}]")
try:
os.remove(path_new)
except OSError:
diff --git a/contrib/python/setuptools/py3/setuptools/command/bdist_wheel.py b/contrib/python/setuptools/py3/setuptools/command/bdist_wheel.py
index 234df2a7c7..d9e1eb974f 100644
--- a/contrib/python/setuptools/py3/setuptools/command/bdist_wheel.py
+++ b/contrib/python/setuptools/py3/setuptools/command/bdist_wheel.py
@@ -184,9 +184,7 @@ class bdist_wheel(Command):
(
"compression=",
None,
- "zipfile compression (one of: {}) [default: 'deflated']".format(
- ", ".join(supported_compressions)
- ),
+ f"zipfile compression (one of: {', '.join(supported_compressions)}) [default: 'deflated']",
),
(
"python-tag=",
@@ -500,7 +498,7 @@ class bdist_wheel(Command):
# Setuptools has resolved any patterns to actual file names
return self.distribution.metadata.license_files or ()
- files: set[str] = set()
+ files = set[str]()
metadata = self.distribution.get_option_dict("metadata")
if setuptools_major_version >= 42:
# Setuptools recognizes the license_files option but does not do globbing
diff --git a/contrib/python/setuptools/py3/setuptools/command/build_clib.py b/contrib/python/setuptools/py3/setuptools/command/build_clib.py
index bee3d58c03..f376f4ce4d 100644
--- a/contrib/python/setuptools/py3/setuptools/command/build_clib.py
+++ b/contrib/python/setuptools/py3/setuptools/command/build_clib.py
@@ -29,9 +29,9 @@ class build_clib(orig.build_clib):
sources = build_info.get('sources')
if sources is None or not isinstance(sources, (list, tuple)):
raise DistutilsSetupError(
- "in 'libraries' option (library '%s'), "
+ f"in 'libraries' option (library '{lib_name}'), "
"'sources' must be present and must be "
- "a list of source filenames" % lib_name
+ "a list of source filenames"
)
sources = sorted(list(sources))
@@ -43,9 +43,9 @@ class build_clib(orig.build_clib):
obj_deps = build_info.get('obj_deps', dict())
if not isinstance(obj_deps, dict):
raise DistutilsSetupError(
- "in 'libraries' option (library '%s'), "
+ f"in 'libraries' option (library '{lib_name}'), "
"'obj_deps' must be a dictionary of "
- "type 'source: list'" % lib_name
+ "type 'source: list'"
)
dependencies = []
@@ -54,9 +54,9 @@ class build_clib(orig.build_clib):
global_deps = obj_deps.get('', list())
if not isinstance(global_deps, (list, tuple)):
raise DistutilsSetupError(
- "in 'libraries' option (library '%s'), "
+ f"in 'libraries' option (library '{lib_name}'), "
"'obj_deps' must be a dictionary of "
- "type 'source: list'" % lib_name
+ "type 'source: list'"
)
# Build the list to be used by newer_pairwise_group
@@ -67,9 +67,9 @@ class build_clib(orig.build_clib):
extra_deps = obj_deps.get(source, list())
if not isinstance(extra_deps, (list, tuple)):
raise DistutilsSetupError(
- "in 'libraries' option (library '%s'), "
+ f"in 'libraries' option (library '{lib_name}'), "
"'obj_deps' must be a dictionary of "
- "type 'source: list'" % lib_name
+ "type 'source: list'"
)
src_deps.extend(extra_deps)
dependencies.append(src_deps)
diff --git a/contrib/python/setuptools/py3/setuptools/command/build_ext.py b/contrib/python/setuptools/py3/setuptools/command/build_ext.py
index e5c6b76b38..be833a379c 100644
--- a/contrib/python/setuptools/py3/setuptools/command/build_ext.py
+++ b/contrib/python/setuptools/py3/setuptools/command/build_ext.py
@@ -168,7 +168,7 @@ class build_ext(_build_ext):
if not isinstance(ext_suffix, str):
raise OSError(
"Configuration variable EXT_SUFFIX not found for this platform "
- + "and environment variable SETUPTOOLS_EXT_SUFFIX is missing"
+ "and environment variable SETUPTOOLS_EXT_SUFFIX is missing"
)
so_ext = ext_suffix
@@ -360,7 +360,7 @@ class build_ext(_build_ext):
" global __bootstrap__, __file__, __loader__",
" import sys, os, pkg_resources, importlib.util" + if_dl(", dl"),
" __file__ = pkg_resources.resource_filename"
- "(__name__,%r)" % os.path.basename(ext._file_name),
+ f"(__name__,{os.path.basename(ext._file_name)!r})",
" del __bootstrap__",
" if '__loader__' in globals():",
" del __loader__",
diff --git a/contrib/python/setuptools/py3/setuptools/command/build_py.py b/contrib/python/setuptools/py3/setuptools/command/build_py.py
index e7d60c6440..2f6fcb7cdc 100644
--- a/contrib/python/setuptools/py3/setuptools/command/build_py.py
+++ b/contrib/python/setuptools/py3/setuptools/command/build_py.py
@@ -259,10 +259,10 @@ class build_py(orig.build_py):
contents = f.read()
if b'declare_namespace' not in contents:
raise distutils.errors.DistutilsError(
- "Namespace package problem: %s is a namespace package, but "
+ f"Namespace package problem: {package} is a namespace package, but "
"its\n__init__.py does not call declare_namespace()! Please "
'fix it.\n(See the setuptools manual under '
- '"Namespace Packages" for details.)\n"' % (package,)
+ '"Namespace Packages" for details.)\n"'
)
return init_py
diff --git a/contrib/python/setuptools/py3/setuptools/command/dist_info.py b/contrib/python/setuptools/py3/setuptools/command/dist_info.py
index 0192ebb260..dca01ff0ce 100644
--- a/contrib/python/setuptools/py3/setuptools/command/dist_info.py
+++ b/contrib/python/setuptools/py3/setuptools/command/dist_info.py
@@ -95,7 +95,7 @@ class dist_info(Command):
egg_info_dir = self.egg_info.egg_info
assert os.path.isdir(egg_info_dir), ".egg-info dir should have been created"
- log.info("creating '{}'".format(os.path.abspath(self.dist_info_dir)))
+ log.info(f"creating '{os.path.abspath(self.dist_info_dir)}'")
bdist_wheel = self.get_finalized_command('bdist_wheel')
# TODO: if bdist_wheel if merged into setuptools, just add "keep_egg_info" there
diff --git a/contrib/python/setuptools/py3/setuptools/command/easy_install.py b/contrib/python/setuptools/py3/setuptools/command/easy_install.py
index 66fe68f7a9..eb1b4c1fcc 100644
--- a/contrib/python/setuptools/py3/setuptools/command/easy_install.py
+++ b/contrib/python/setuptools/py3/setuptools/command/easy_install.py
@@ -132,8 +132,8 @@ class easy_install(Command):
(
'optimize=',
'O',
- "also compile with optimization: -O1 for \"python -O\", "
- "-O2 for \"python -OO\", and -O0 to disable [default: -O0]",
+ 'also compile with optimization: -O1 for "python -O", '
+ '-O2 for "python -OO", and -O0 to disable [default: -O0]',
),
('record=', None, "filename in which to record list of installed files"),
('always-unzip', 'Z', "don't install as a zipfile, no matter what"),
@@ -148,7 +148,7 @@ class easy_install(Command):
None,
"Don't load find-links defined in packages being installed",
),
- ('user', None, "install in user site-package '%s'" % site.USER_SITE),
+ ('user', None, f"install in user site-package '{site.USER_SITE}'"),
]
boolean_options = [
'zip-ok',
@@ -446,7 +446,7 @@ class easy_install(Command):
self.execute(
file_util.write_file,
(self.record, outputs),
- "writing list of installed files to '%s'" % self.record,
+ f"writing list of installed files to '{self.record}'",
)
self.warn_deprecated_options()
finally:
@@ -461,7 +461,7 @@ class easy_install(Command):
pid = os.getpid()
except Exception:
pid = random.randint(0, sys.maxsize)
- return os.path.join(self.install_dir, "test-easy-install-%s" % pid)
+ return os.path.join(self.install_dir, f"test-easy-install-{pid}")
def warn_deprecated_options(self) -> None:
pass
@@ -649,8 +649,8 @@ class easy_install(Command):
def not_editable(self, spec) -> None:
if self.editable:
raise DistutilsArgError(
- "Invalid argument %r: you can't use filenames or URLs "
- "with --editable (except via the --find-links option)." % (spec,)
+ f"Invalid argument {spec!r}: you can't use filenames or URLs "
+ "with --editable (except via the --find-links option)."
)
def check_editable(self, spec) -> None:
@@ -659,8 +659,7 @@ class easy_install(Command):
if os.path.exists(os.path.join(self.build_directory, spec.key)):
raise DistutilsArgError(
- "%r already exists in %s; can't do a checkout there"
- % (spec.key, self.build_directory)
+ f"{spec.key!r} already exists in {self.build_directory}; can't do a checkout there"
)
@contextlib.contextmanager
@@ -698,7 +697,7 @@ class easy_install(Command):
self.local_index,
)
if dist is None:
- msg = "Could not find suitable distribution for %r" % spec
+ msg = f"Could not find suitable distribution for {spec!r}"
if self.always_copy:
msg += " (--always-copy skips system and development eggs)"
raise DistutilsError(msg)
@@ -917,12 +916,11 @@ class easy_install(Command):
setups = glob(os.path.join(setup_base, '*', 'setup.py'))
if not setups:
raise DistutilsError(
- "Couldn't find a setup script in %s"
- % os.path.abspath(dist_filename)
+ f"Couldn't find a setup script in {os.path.abspath(dist_filename)}"
)
if len(setups) > 1:
raise DistutilsError(
- "Multiple setup scripts in %s" % os.path.abspath(dist_filename)
+ f"Multiple setup scripts in {os.path.abspath(dist_filename)}"
)
setup_script = setups[0]
@@ -1000,7 +998,7 @@ class easy_install(Command):
cfg = extract_wininst_cfg(dist_filename)
if cfg is None:
raise DistutilsError(
- "%s is not a valid distutils Windows .exe" % dist_filename
+ f"{dist_filename} is not a valid distutils Windows .exe"
)
# Create a dummy distribution object until we build the real distro
dist = Distribution(
@@ -1026,7 +1024,8 @@ class easy_install(Command):
f.write('Metadata-Version: 1.0\n')
for k, v in cfg.items('metadata'):
if k != 'target_version':
- f.write('%s: %s\n' % (k.replace('_', '-').title(), v))
+ k = k.replace('_', '-').title()
+ f.write(f'{k}: {v}\n')
script_dir = os.path.join(_egg_info, 'scripts')
# delete entry-point scripts to avoid duping
self.delete_blockers([
@@ -1114,8 +1113,9 @@ class easy_install(Command):
self.execute(
wheel.install_as_egg,
(destination,),
- ("Installing %s to %s")
- % (os.path.basename(wheel_path), os.path.dirname(destination)),
+ (
+ f"Installing {os.path.basename(wheel_path)} to {os.path.dirname(destination)}"
+ ),
)
finally:
update_dist_caches(destination, fix_zipimporter_caches=False)
@@ -1191,7 +1191,7 @@ class easy_install(Command):
try:
run_setup(setup_script, args)
except SystemExit as v:
- raise DistutilsError("Setup script exited with %s" % (v.args[0],)) from v
+ raise DistutilsError(f"Setup script exited with {v.args[0]}") from v
def build_and_install(self, setup_script, setup_base):
args = ['bdist_egg', '--dist-dir']
@@ -1374,7 +1374,7 @@ class easy_install(Command):
home = convert_path(os.path.expanduser("~"))
for path in only_strs(self.config_vars.values()):
if path.startswith(home) and not os.path.isdir(path):
- self.debug_print("os.makedirs('%s', 0o700)" % path)
+ self.debug_print(f"os.makedirs('{path}', 0o700)")
os.makedirs(path, 0o700)
INSTALL_SCHEMES = dict(
@@ -1599,7 +1599,7 @@ def get_exe_prefixes(exe_filename):
for pth in yield_lines(contents):
pth = pth.strip().replace('\\', '/')
if not pth.startswith('import'):
- prefixes.append((('%s/%s/' % (parts[0], pth)), ''))
+ prefixes.append(((f'{parts[0]}/{pth}/'), ''))
finally:
z.close()
prefixes = [(x.lower(), y) for x, y in prefixes]
@@ -2305,7 +2305,7 @@ def get_win_launcher(type):
Returns the executable as a byte string.
"""
- launcher_fn = '%s.exe' % type
+ launcher_fn = f'{type}.exe'
if is_64bit():
if get_platform() == "win-arm64":
launcher_fn = launcher_fn.replace(".", "-arm64.")
diff --git a/contrib/python/setuptools/py3/setuptools/command/editable_wheel.py b/contrib/python/setuptools/py3/setuptools/command/editable_wheel.py
index 6d23d11fad..b03e677757 100644
--- a/contrib/python/setuptools/py3/setuptools/command/editable_wheel.py
+++ b/contrib/python/setuptools/py3/setuptools/command/editable_wheel.py
@@ -506,7 +506,7 @@ class _TopLevelFinder:
package_dir = self.dist.package_dir or {}
roots = _find_package_roots(top_level, package_dir, src_root)
- namespaces_: dict[str, list[str]] = dict(
+ namespaces_ = dict(
chain(
_find_namespaces(self.dist.packages or [], roots),
((ns, []) for ns in _find_virtual_namespaces(roots)),
diff --git a/contrib/python/setuptools/py3/setuptools/command/egg_info.py b/contrib/python/setuptools/py3/setuptools/command/egg_info.py
index a300356d33..f77631168f 100644
--- a/contrib/python/setuptools/py3/setuptools/command/egg_info.py
+++ b/contrib/python/setuptools/py3/setuptools/command/egg_info.py
@@ -48,7 +48,7 @@ def translate_pattern(glob): # noqa: C901 # is too complex (14) # FIXME
chunks = glob.split(os.path.sep)
sep = re.escape(os.sep)
- valid_char = '[^%s]' % (sep,)
+ valid_char = f'[^{sep}]'
for c, chunk in enumerate(chunks):
last_chunk = c == len(chunks) - 1
@@ -60,7 +60,7 @@ def translate_pattern(glob): # noqa: C901 # is too complex (14) # FIXME
pat += '.*'
else:
# Match '(name/)*'
- pat += '(?:%s+%s)*' % (valid_char, sep)
+ pat += f'(?:{valid_char}+{sep})*'
continue # Break here as the whole path component has been handled
# Find any special characters in the remainder
@@ -102,7 +102,7 @@ def translate_pattern(glob): # noqa: C901 # is too complex (14) # FIXME
inner = inner[1:]
char_class += re.escape(inner)
- pat += '[%s]' % (char_class,)
+ pat += f'[{char_class}]'
# Skip to the end ]
i = inner_i
@@ -231,8 +231,7 @@ class egg_info(InfoCommon, Command):
packaging.requirements.Requirement(spec % (self.egg_name, self.egg_version))
except ValueError as e:
raise distutils.errors.DistutilsOptionError(
- "Invalid distribution name or version syntax: %s-%s"
- % (self.egg_name, self.egg_version)
+ f"Invalid distribution name or version syntax: {self.egg_name}-{self.egg_version}"
) from e
if self.egg_base is None:
@@ -502,7 +501,7 @@ class FileList(_FileList):
# To avoid accidental trans-codings errors, first to unicode
u_path = unicode_utils.filesys_decode(path)
if u_path is None:
- log.warn("'%s' in unexpected encoding -- skipping" % path)
+ log.warn(f"'{path}' in unexpected encoding -- skipping")
return False
# Must ensure utf-8 encodability
@@ -564,7 +563,7 @@ class manifest_maker(sdist):
# Now _repairs should encodability, but not unicode
files = [self._manifest_normalize(f) for f in self.filelist.files]
- msg = "writing manifest file '%s'" % self.manifest
+ msg = f"writing manifest file '{self.manifest}'"
self.execute(write_file, (self.manifest, files), msg)
def warn(self, msg) -> None:
diff --git a/contrib/python/setuptools/py3/setuptools/command/install_egg_info.py b/contrib/python/setuptools/py3/setuptools/command/install_egg_info.py
index a6e6ec6446..44f22ccf51 100644
--- a/contrib/python/setuptools/py3/setuptools/command/install_egg_info.py
+++ b/contrib/python/setuptools/py3/setuptools/command/install_egg_info.py
@@ -36,7 +36,7 @@ class install_egg_info(namespaces.Installer, Command):
self.execute(os.unlink, (self.target,), "Removing " + self.target)
if not self.dry_run:
ensure_directory(self.target)
- self.execute(self.copytree, (), "Copying %s to %s" % (self.source, self.target))
+ self.execute(self.copytree, (), f"Copying {self.source} to {self.target}")
self.install_namespaces()
def get_outputs(self):
diff --git a/contrib/python/setuptools/py3/setuptools/command/sdist.py b/contrib/python/setuptools/py3/setuptools/command/sdist.py
index 64e866c96b..9631cf3114 100644
--- a/contrib/python/setuptools/py3/setuptools/command/sdist.py
+++ b/contrib/python/setuptools/py3/setuptools/command/sdist.py
@@ -53,7 +53,7 @@ class sdist(orig.sdist):
negative_opt: ClassVar[dict[str, str]] = {}
README_EXTENSIONS = ['', '.rst', '.txt', '.md']
- READMES = tuple('README{0}'.format(ext) for ext in README_EXTENSIONS)
+ READMES = tuple(f'README{ext}' for ext in README_EXTENSIONS)
def run(self) -> None:
self.run_command('egg_info')
@@ -207,7 +207,7 @@ class sdist(orig.sdist):
try:
line = bytes_line.decode('UTF-8')
except UnicodeDecodeError:
- log.warn("%r not UTF-8 decodable -- skipping" % line)
+ log.warn(f"{line!r} not UTF-8 decodable -- skipping")
continue
# ignore comments and blank lines
line = line.strip()
diff --git a/contrib/python/setuptools/py3/setuptools/command/setopt.py b/contrib/python/setuptools/py3/setuptools/command/setopt.py
index 200cdff0f7..678a0593d6 100644
--- a/contrib/python/setuptools/py3/setuptools/command/setopt.py
+++ b/contrib/python/setuptools/py3/setuptools/command/setopt.py
@@ -23,7 +23,7 @@ def config_file(kind="local"):
return os.path.join(os.path.dirname(distutils.__file__), 'distutils.cfg')
if kind == 'user':
dot = os.name == 'posix' and '.' or ''
- return os.path.expanduser(convert_path("~/%spydistutils.cfg" % dot))
+ return os.path.expanduser(convert_path(f"~/{dot}pydistutils.cfg"))
raise ValueError("config_file() type must be 'local', 'global', or 'user'", kind)
diff --git a/contrib/python/setuptools/py3/setuptools/config/expand.py b/contrib/python/setuptools/py3/setuptools/config/expand.py
index 54c68bed4f..ccb5d63cd2 100644
--- a/contrib/python/setuptools/py3/setuptools/config/expand.py
+++ b/contrib/python/setuptools/py3/setuptools/config/expand.py
@@ -329,7 +329,7 @@ def version(value: Callable | Iterable[str | int] | str) -> str:
return _value
if hasattr(_value, '__iter__'):
return '.'.join(map(str, _value))
- return '%s' % _value
+ return f'{_value}'
def canonic_package_data(package_data: dict) -> dict:
diff --git a/contrib/python/setuptools/py3/setuptools/config/pyprojecttoml.py b/contrib/python/setuptools/py3/setuptools/config/pyprojecttoml.py
index 15b0baa18e..fd6c5968c8 100644
--- a/contrib/python/setuptools/py3/setuptools/config/pyprojecttoml.py
+++ b/contrib/python/setuptools/py3/setuptools/config/pyprojecttoml.py
@@ -185,7 +185,7 @@ class _ConfigExpander:
self.dynamic_cfg = self.setuptools_cfg.get("dynamic", {})
self.ignore_option_errors = ignore_option_errors
self._dist = dist
- self._referenced_files: set[str] = set()
+ self._referenced_files = set[str]()
def _ensure_dist(self) -> Distribution:
from setuptools.dist import Distribution
diff --git a/contrib/python/setuptools/py3/setuptools/config/setupcfg.py b/contrib/python/setuptools/py3/setuptools/config/setupcfg.py
index b35d0b00cd..4615815b6b 100644
--- a/contrib/python/setuptools/py3/setuptools/config/setupcfg.py
+++ b/contrib/python/setuptools/py3/setuptools/config/setupcfg.py
@@ -253,7 +253,7 @@ class ConfigHandler(Generic[Target]):
self.sections = dict(self._section_options(options))
self.set_options: list[str] = []
self.ensure_discovered = ensure_discovered
- self._referenced_files: set[str] = set()
+ self._referenced_files = set[str]()
"""After parsing configurations, this property will enumerate
all files referenced by the "file:" directive. Private API for setuptools only.
"""
@@ -272,7 +272,7 @@ class ConfigHandler(Generic[Target]):
def parsers(self):
"""Metadata item name to parser function mapping."""
raise NotImplementedError(
- '%s must provide .parsers property' % self.__class__.__name__
+ f'{self.__class__.__name__} must provide .parsers property'
)
def __setitem__(self, option_name, value) -> None:
diff --git a/contrib/python/setuptools/py3/setuptools/depends.py b/contrib/python/setuptools/py3/setuptools/depends.py
index 1be71857a5..e5223b7956 100644
--- a/contrib/python/setuptools/py3/setuptools/depends.py
+++ b/contrib/python/setuptools/py3/setuptools/depends.py
@@ -43,7 +43,7 @@ class Require:
def full_name(self):
"""Return full package/distribution name, w/version"""
if self.requested_version is not None:
- return '%s-%s' % (self.name, self.requested_version)
+ return f'{self.name}-{self.requested_version}'
return self.name
def version_ok(self, version):
diff --git a/contrib/python/setuptools/py3/setuptools/dist.py b/contrib/python/setuptools/py3/setuptools/dist.py
index 5b3175fb5b..f878b2fa45 100644
--- a/contrib/python/setuptools/py3/setuptools/dist.py
+++ b/contrib/python/setuptools/py3/setuptools/dist.py
@@ -85,7 +85,7 @@ def check_importable(dist, attr, value):
assert not ep.extras
except (TypeError, ValueError, AttributeError, AssertionError) as e:
raise DistutilsSetupError(
- "%r must be importable 'module:attrs' string (got %r)" % (attr, value)
+ f"{attr!r} must be importable 'module:attrs' string (got {value!r})"
) from e
@@ -110,8 +110,7 @@ def check_nsp(dist, attr, value):
for nsp in ns_packages:
if not dist.has_contents_for(nsp):
raise DistutilsSetupError(
- "Distribution contains no modules or packages for "
- + "namespace package %r" % nsp
+ f"Distribution contains no modules or packages for namespace package {nsp!r}"
)
parent, _sep, _child = nsp.rpartition('.')
if parent and parent not in ns_packages:
@@ -210,15 +209,15 @@ def check_package_data(dist, attr, value):
"""Verify that value is a dictionary of package names to glob lists"""
if not isinstance(value, dict):
raise DistutilsSetupError(
- "{!r} must be a dictionary mapping package names to lists of "
- "string wildcard patterns".format(attr)
+ f"{attr!r} must be a dictionary mapping package names to lists of "
+ "string wildcard patterns"
)
for k, v in value.items():
if not isinstance(k, str):
raise DistutilsSetupError(
- "keys of {!r} dict must be strings (got {!r})".format(attr, k)
+ f"keys of {attr!r} dict must be strings (got {k!r})"
)
- assert_string_list(dist, 'values of {!r} dict'.format(attr), v)
+ assert_string_list(dist, f'values of {attr!r} dict', v)
def check_packages(dist, attr, value):
@@ -321,7 +320,7 @@ class Distribution(_Distribution):
# Private API (setuptools-use only, not restricted to Distribution)
# Stores files that are referenced by the configuration and need to be in the
# sdist (e.g. `version = file: VERSION.txt`)
- self._referenced_files: set[str] = set()
+ self._referenced_files = set[str]()
self.set_defaults = ConfigDiscovery(self)
@@ -400,7 +399,7 @@ class Distribution(_Distribution):
def _finalize_license_files(self) -> None:
"""Compute names of all license files which should be included."""
license_files: list[str] | None = self.metadata.license_files
- patterns: list[str] = license_files if license_files else []
+ patterns = license_files or []
license_file: str | None = self.metadata.license_file
if license_file and license_file not in patterns:
@@ -588,10 +587,10 @@ class Distribution(_Distribution):
option_dict = self.get_option_dict(command_name)
if DEBUG:
- self.announce(" setting options for '%s' command:" % command_name)
+ self.announce(f" setting options for '{command_name}' command:")
for option, (source, value) in option_dict.items():
if DEBUG:
- self.announce(" %s = %s (from %s)" % (option, value, source))
+ self.announce(f" {option} = {value} (from {source})")
try:
bool_opts = [translate_longopt(o) for o in command_obj.boolean_options]
except AttributeError:
@@ -611,8 +610,7 @@ class Distribution(_Distribution):
setattr(command_obj, option, value)
else:
raise DistutilsOptionError(
- "error in %s: command '%s' has no such option '%s'"
- % (source, command_name, option)
+ f"error in {source}: command '{command_name}' has no such option '{option}'"
)
except ValueError as e:
raise DistutilsOptionError(e) from e
@@ -818,7 +816,7 @@ class Distribution(_Distribution):
try:
old = getattr(self, name)
except AttributeError as e:
- raise DistutilsSetupError("%s: No such distribution setting" % name) from e
+ raise DistutilsSetupError(f"{name}: No such distribution setting") from e
if old is not None and not isinstance(old, _sequence):
raise DistutilsSetupError(
name + ": this setting cannot be changed via include/exclude"
@@ -836,7 +834,7 @@ class Distribution(_Distribution):
try:
old = getattr(self, name)
except AttributeError as e:
- raise DistutilsSetupError("%s: No such distribution setting" % name) from e
+ raise DistutilsSetupError(f"{name}: No such distribution setting") from e
if old is None:
setattr(self, name, value)
elif not isinstance(old, _sequence):
diff --git a/contrib/python/setuptools/py3/setuptools/monkey.py b/contrib/python/setuptools/py3/setuptools/monkey.py
index d8e30dbb80..6ad1abac29 100644
--- a/contrib/python/setuptools/py3/setuptools/monkey.py
+++ b/contrib/python/setuptools/py3/setuptools/monkey.py
@@ -64,7 +64,7 @@ def get_unpatched_class(cls: type[_T]) -> type[_T]:
)
base = next(external_bases)
if not base.__module__.startswith('distutils'):
- msg = "distutils has already been patched by %r" % cls
+ msg = f"distutils has already been patched by {cls!r}"
raise AssertionError(msg)
return base
diff --git a/contrib/python/setuptools/py3/setuptools/msvc.py b/contrib/python/setuptools/py3/setuptools/msvc.py
index 8d6d2cf084..9c9a63568e 100644
--- a/contrib/python/setuptools/py3/setuptools/msvc.py
+++ b/contrib/python/setuptools/py3/setuptools/msvc.py
@@ -108,7 +108,7 @@ class PlatformInfo:
if (self.current_cpu == 'x86' and hidex86)
else r'\x64'
if (self.current_cpu == 'amd64' and x64)
- else r'\%s' % self.current_cpu
+ else rf'\{self.current_cpu}'
)
def target_dir(self, hidex86=False, x64=False) -> str:
@@ -132,7 +132,7 @@ class PlatformInfo:
if (self.target_cpu == 'x86' and hidex86)
else r'\x64'
if (self.target_cpu == 'amd64' and x64)
- else r'\%s' % self.target_cpu
+ else rf'\{self.target_cpu}'
)
def cross_dir(self, forcex86=False):
@@ -155,7 +155,7 @@ class PlatformInfo:
return (
''
if self.target_cpu == current
- else self.target_dir().replace('\\', '\\%s_' % current)
+ else self.target_dir().replace('\\', f'\\{current}_')
)
@@ -497,11 +497,11 @@ class SystemInfo:
"""
# Default path
default = os.path.join(
- self.ProgramFilesx86, 'Microsoft Visual Studio %0.1f' % self.vs_ver
+ self.ProgramFilesx86, f'Microsoft Visual Studio {self.vs_ver:0.1f}'
)
# Try to get path from registry, if fail use default path
- return self.ri.lookup(self.ri.vs, '%0.1f' % self.vs_ver) or default
+ return self.ri.lookup(self.ri.vs, f'{self.vs_ver:0.1f}') or default
@property
def VCInstallDir(self):
@@ -561,16 +561,17 @@ class SystemInfo:
path
"""
default = os.path.join(
- self.ProgramFilesx86, r'Microsoft Visual Studio %0.1f\VC' % self.vs_ver
+ self.ProgramFilesx86,
+ rf'Microsoft Visual Studio {self.vs_ver:0.1f}\VC',
)
# Try to get "VC++ for Python" path from registry as default path
- reg_path = os.path.join(self.ri.vc_for_python, '%0.1f' % self.vs_ver)
+ reg_path = os.path.join(self.ri.vc_for_python, f'{self.vs_ver:0.1f}')
python_vc = self.ri.lookup(reg_path, 'installdir')
default_vc = os.path.join(python_vc, 'VC') if python_vc else default
# Try to get path from registry, if fail use default path
- return self.ri.lookup(self.ri.vc, '%0.1f' % self.vs_ver) or default_vc
+ return self.ri.lookup(self.ri.vc, f'{self.vs_ver:0.1f}') or default_vc
@property
def WindowsSdkVersion(self) -> tuple[LiteralString, ...]:
@@ -619,13 +620,13 @@ class SystemInfo:
sdkdir: str | None = ''
for ver in self.WindowsSdkVersion:
# Try to get it from registry
- loc = os.path.join(self.ri.windows_sdk, 'v%s' % ver)
+ loc = os.path.join(self.ri.windows_sdk, f'v{ver}')
sdkdir = self.ri.lookup(loc, 'installationfolder')
if sdkdir:
break
if not sdkdir or not os.path.isdir(sdkdir):
# Try to get "VC++ for Python" version from registry
- path = os.path.join(self.ri.vc_for_python, '%0.1f' % self.vc_ver)
+ path = os.path.join(self.ri.vc_for_python, f'{self.vc_ver:0.1f}')
install_base = self.ri.lookup(path, 'installdir')
if install_base:
sdkdir = os.path.join(install_base, 'WinSDK')
@@ -633,14 +634,14 @@ class SystemInfo:
# If fail, use default new path
for ver in self.WindowsSdkVersion:
intver = ver[: ver.rfind('.')]
- path = r'Microsoft SDKs\Windows Kits\%s' % intver
+ path = rf'Microsoft SDKs\Windows Kits\{intver}'
d = os.path.join(self.ProgramFiles, path)
if os.path.isdir(d):
sdkdir = d
if not sdkdir or not os.path.isdir(sdkdir):
# If fail, use default old path
for ver in self.WindowsSdkVersion:
- path = r'Microsoft SDKs\Windows\v%s' % ver
+ path = rf'Microsoft SDKs\Windows\v{ver}'
d = os.path.join(self.ProgramFiles, path)
if os.path.isdir(d):
sdkdir = d
@@ -666,8 +667,8 @@ class SystemInfo:
else:
netfxver = 40
hidex86 = True if self.vs_ver <= 12.0 else False
- arch = self.pi.current_dir(x64=True, hidex86=hidex86)
- fx = 'WinSDK-NetFx%dTools%s' % (netfxver, arch.replace('\\', '-'))
+ arch = self.pi.current_dir(x64=True, hidex86=hidex86).replace('\\', '-')
+ fx = f'WinSDK-NetFx{netfxver}Tools{arch}'
# list all possibles registry paths
regpaths = []
@@ -676,7 +677,7 @@ class SystemInfo:
regpaths += [os.path.join(self.ri.netfx_sdk, ver, fx)]
for ver in self.WindowsSdkVersion:
- regpaths += [os.path.join(self.ri.windows_sdk, 'v%sA' % ver, fx)]
+ regpaths += [os.path.join(self.ri.windows_sdk, f'v{ver}A', fx)]
# Return installation folder from the more recent path
for path in regpaths:
@@ -696,7 +697,7 @@ class SystemInfo:
str
path
"""
- path = os.path.join(self.ri.visualstudio, r'%0.1f\Setup\F#' % self.vs_ver)
+ path = os.path.join(self.ri.visualstudio, rf'{self.vs_ver:0.1f}\Setup\F#')
return self.ri.lookup(path, 'productdir') or ''
@property
@@ -714,7 +715,7 @@ class SystemInfo:
# Find path of the more recent Kit
for ver in vers:
- sdkdir = self.ri.lookup(self.ri.windows_kits_roots, 'kitsroot%s' % ver)
+ sdkdir = self.ri.lookup(self.ri.windows_kits_roots, f'kitsroot{ver}')
if sdkdir:
return sdkdir or ''
@@ -838,8 +839,8 @@ class SystemInfo:
versions
"""
# Find actual .NET version in registry
- reg_ver = self.ri.lookup(self.ri.vc, 'frameworkver%d' % bits)
- dot_net_dir = getattr(self, 'FrameworkDir%d' % bits)
+ reg_ver = self.ri.lookup(self.ri.vc, f'frameworkver{bits}')
+ dot_net_dir = getattr(self, f'FrameworkDir{bits}')
ver = reg_ver or self._use_last_dir_name(dot_net_dir, 'v') or ''
# Set .NET versions for specified MSVC++ version
@@ -960,7 +961,7 @@ class EnvironmentInfo:
arch_subdir = self.pi.current_dir(hidex86=True, x64=True)
paths += [r'Common7\IDE\CommonExtensions\Microsoft\TestWindow']
paths += [r'Team Tools\Performance Tools']
- paths += [r'Team Tools\Performance Tools%s' % arch_subdir]
+ paths += [rf'Team Tools\Performance Tools{arch_subdir}']
return [os.path.join(self.si.VSInstallDir, path) for path in paths]
@@ -993,10 +994,10 @@ class EnvironmentInfo:
arch_subdir = self.pi.target_dir(x64=True)
else:
arch_subdir = self.pi.target_dir(hidex86=True)
- paths = ['Lib%s' % arch_subdir, r'ATLMFC\Lib%s' % arch_subdir]
+ paths = [f'Lib{arch_subdir}', rf'ATLMFC\Lib{arch_subdir}']
if self.vs_ver >= 14.0:
- paths += [r'Lib\store%s' % arch_subdir]
+ paths += [rf'Lib\store{arch_subdir}']
return [os.path.join(self.si.VCInstallDir, path) for path in paths]
@@ -1030,10 +1031,10 @@ class EnvironmentInfo:
forcex86 = True if self.vs_ver <= 10.0 else False
arch_subdir = self.pi.cross_dir(forcex86)
if arch_subdir:
- tools += [os.path.join(si.VCInstallDir, 'Bin%s' % arch_subdir)]
+ tools += [os.path.join(si.VCInstallDir, f'Bin{arch_subdir}')]
if self.vs_ver == 14.0:
- path = 'Bin%s' % self.pi.current_dir(hidex86=True)
+ path = f'Bin{self.pi.current_dir(hidex86=True)}'
tools += [os.path.join(si.VCInstallDir, path)]
elif self.vs_ver >= 15.0:
@@ -1068,13 +1069,13 @@ class EnvironmentInfo:
"""
if self.vs_ver <= 10.0:
arch_subdir = self.pi.target_dir(hidex86=True, x64=True)
- return [os.path.join(self.si.WindowsSdkDir, 'Lib%s' % arch_subdir)]
+ return [os.path.join(self.si.WindowsSdkDir, f'Lib{arch_subdir}')]
else:
arch_subdir = self.pi.target_dir(x64=True)
lib = os.path.join(self.si.WindowsSdkDir, 'lib')
libver = self._sdk_subdir
- return [os.path.join(lib, '%sum%s' % (libver, arch_subdir))]
+ return [os.path.join(lib, f'{libver}um{arch_subdir}')]
@property
def OSIncludes(self):
@@ -1097,9 +1098,9 @@ class EnvironmentInfo:
else:
sdkver = ''
return [
- os.path.join(include, '%sshared' % sdkver),
- os.path.join(include, '%sum' % sdkver),
- os.path.join(include, '%swinrt' % sdkver),
+ os.path.join(include, f'{sdkver}shared'),
+ os.path.join(include, f'{sdkver}um'),
+ os.path.join(include, f'{sdkver}winrt'),
]
@property
@@ -1134,7 +1135,7 @@ class EnvironmentInfo:
self.si.WindowsSdkDir,
'ExtensionSDKs',
'Microsoft.VCLibs',
- '%0.1f' % self.vs_ver,
+ f'{self.vs_ver:0.1f}',
'References',
'CommonConfiguration',
'neutral',
@@ -1169,7 +1170,7 @@ class EnvironmentInfo:
if not self.pi.current_is_x86():
arch_subdir = self.pi.current_dir(x64=True)
- path = 'Bin%s' % arch_subdir
+ path = f'Bin{arch_subdir}'
yield os.path.join(self.si.WindowsSdkDir, path)
if self.vs_ver in (10.0, 11.0):
@@ -1177,14 +1178,14 @@ class EnvironmentInfo:
arch_subdir = ''
else:
arch_subdir = self.pi.current_dir(hidex86=True, x64=True)
- path = r'Bin\NETFX 4.0 Tools%s' % arch_subdir
+ path = rf'Bin\NETFX 4.0 Tools{arch_subdir}'
yield os.path.join(self.si.WindowsSdkDir, path)
elif self.vs_ver >= 15.0:
path = os.path.join(self.si.WindowsSdkDir, 'Bin')
arch_subdir = self.pi.current_dir(x64=True)
sdkver = self.si.WindowsSdkLastVersion
- yield os.path.join(path, '%s%s' % (sdkver, arch_subdir))
+ yield os.path.join(path, f'{sdkver}{arch_subdir}')
if self.si.WindowsSDKExecutablePath:
yield self.si.WindowsSDKExecutablePath
@@ -1200,7 +1201,7 @@ class EnvironmentInfo:
subdir
"""
ucrtver = self.si.WindowsSdkLastVersion
- return ('%s\\' % ucrtver) if ucrtver else ''
+ return (f'{ucrtver}\\') if ucrtver else ''
@property
def SdkSetup(self):
@@ -1262,7 +1263,7 @@ class EnvironmentInfo:
return []
arch_subdir = self.pi.target_dir(x64=True)
- return [os.path.join(self.si.NetFxSdkDir, r'lib\um%s' % arch_subdir)]
+ return [os.path.join(self.si.NetFxSdkDir, rf'lib\um{arch_subdir}')]
@property
def NetFxSDKIncludes(self):
@@ -1310,7 +1311,7 @@ class EnvironmentInfo:
base_path = self.si.VSInstallDir
arch_subdir = ''
- path = r'MSBuild\%0.1f\bin%s' % (self.vs_ver, arch_subdir)
+ path = rf'MSBuild\{self.vs_ver:0.1f}\bin{arch_subdir}'
build = [os.path.join(base_path, path)]
if self.vs_ver >= 15.0:
@@ -1350,7 +1351,7 @@ class EnvironmentInfo:
arch_subdir = self.pi.target_dir(x64=True)
lib = os.path.join(self.si.UniversalCRTSdkDir, 'lib')
ucrtver = self._ucrt_subdir
- return [os.path.join(lib, '%sucrt%s' % (ucrtver, arch_subdir))]
+ return [os.path.join(lib, f'{ucrtver}ucrt{arch_subdir}')]
@property
def UCRTIncludes(self):
@@ -1366,7 +1367,7 @@ class EnvironmentInfo:
return []
include = os.path.join(self.si.UniversalCRTSdkDir, 'include')
- return [os.path.join(include, '%sucrt' % self._ucrt_subdir)]
+ return [os.path.join(include, f'{self._ucrt_subdir}ucrt')]
@property
def _ucrt_subdir(self):
@@ -1379,7 +1380,7 @@ class EnvironmentInfo:
subdir
"""
ucrtver = self.si.UniversalCRTSdkLastVersion
- return ('%s\\' % ucrtver) if ucrtver else ''
+ return (f'{ucrtver}\\') if ucrtver else ''
@property
def FSharp(self):
@@ -1403,7 +1404,7 @@ class EnvironmentInfo:
Returns the first suitable path found or None.
"""
- vcruntime = 'vcruntime%d0.dll' % self.vc_ver
+ vcruntime = f'vcruntime{self.vc_ver}0.dll'
arch_subdir = self.pi.target_dir(x64=True).strip('\\')
# Installation prefixes candidates
@@ -1419,9 +1420,9 @@ class EnvironmentInfo:
# CRT directory
crt_dirs = (
- 'Microsoft.VC%d.CRT' % (self.vc_ver * 10),
+ f'Microsoft.VC{self.vc_ver * 10}.CRT',
# Sometime store in directory with VS version instead of VC
- 'Microsoft.VC%d.CRT' % (int(self.vs_ver) * 10),
+ f'Microsoft.VC{int(self.vs_ver) * 10}.CRT',
)
# vcruntime path
@@ -1520,7 +1521,7 @@ class EnvironmentInfo:
paths = itertools.chain(spec_paths, env_paths)
extant_paths = list(filter(os.path.isdir, paths)) if exists else paths
if not extant_paths:
- msg = "%s environment variable is empty" % name.upper()
+ msg = f"{name.upper()} environment variable is empty"
raise distutils.errors.DistutilsPlatformError(msg)
unique_paths = unique_everseen(extant_paths)
return os.pathsep.join(unique_paths)
diff --git a/contrib/python/setuptools/py3/setuptools/package_index.py b/contrib/python/setuptools/py3/setuptools/package_index.py
index 97806e8ff8..1a6abebcda 100644
--- a/contrib/python/setuptools/py3/setuptools/package_index.py
+++ b/contrib/python/setuptools/py3/setuptools/package_index.py
@@ -74,7 +74,7 @@ def parse_requirement_arg(spec):
return Requirement.parse(spec)
except ValueError as e:
raise DistutilsError(
- "Not a URL, existing file, or requirement spec: %r" % (spec,)
+ f"Not a URL, existing file, or requirement spec: {spec!r}"
) from e
@@ -357,7 +357,7 @@ class PackageIndex(Environment):
if f is None:
return
if isinstance(f, urllib.error.HTTPError) and f.code == 401:
- self.info("Authentication error: %s" % f.msg)
+ self.info(f"Authentication error: {f.msg}")
self.fetched_urls[f.url] = True
if 'html' not in f.headers.get('content-type', '').lower():
f.close() # not html, we can't process it
@@ -474,13 +474,13 @@ class PackageIndex(Environment):
base, frag = egg_info_for_url(new_url)
if base.endswith('.py') and not frag:
if ver:
- new_url += '#egg=%s-%s' % (pkg, ver)
+ new_url += f'#egg={pkg}-{ver}'
else:
self.need_version_info(url)
self.scan_url(new_url)
return PYPI_MD5.sub(
- lambda m: '<a href="%s#md5=%s">%s</a>' % m.group(1, 3, 2), page
+ lambda m: '<a href="{}#md5={}">{}</a>'.format(*m.group(1, 3, 2)), page
)
def need_version_info(self, url) -> None:
@@ -525,14 +525,13 @@ class PackageIndex(Environment):
"""
checker is a ContentChecker
"""
- checker.report(self.debug, "Validating %%s checksum for %s" % filename)
+ checker.report(self.debug, f"Validating %s checksum for {filename}")
if not checker.is_valid():
tfp.close()
os.unlink(filename)
raise DistutilsError(
- "%s validation failed for %s; "
+ f"{checker.hash.name} validation failed for {os.path.basename(filename)}; "
"possible download problem?"
- % (checker.hash.name, os.path.basename(filename))
)
def add_find_links(self, urls) -> None:
@@ -720,20 +719,15 @@ class PackageIndex(Environment):
with open(os.path.join(tmpdir, 'setup.py'), 'w', encoding="utf-8") as file:
file.write(
"from setuptools import setup\n"
- "setup(name=%r, version=%r, py_modules=[%r])\n"
- % (
- dists[0].project_name,
- dists[0].version,
- os.path.splitext(basename)[0],
- )
+ f"setup(name={dists[0].project_name!r}, version={dists[0].version!r}, py_modules=[{os.path.splitext(basename)[0]!r}])\n"
)
return filename
elif match:
raise DistutilsError(
- "Can't unambiguously interpret project/version identifier %r; "
+ f"Can't unambiguously interpret project/version identifier {fragment!r}; "
"any dashes in the name or version should be escaped using "
- "underscores. %r" % (fragment, dists)
+ f"underscores. {dists!r}"
)
else:
raise DistutilsError(
@@ -751,9 +745,7 @@ class PackageIndex(Environment):
checker = HashChecker.from_url(url)
fp = self.open_url(url)
if isinstance(fp, urllib.error.HTTPError):
- raise DistutilsError(
- "Can't download %s: %s %s" % (url, fp.code, fp.msg)
- )
+ raise DistutilsError(f"Can't download {url}: {fp.code} {fp.msg}")
headers = fp.info()
blocknum = 0
bs = self.dl_blocksize
@@ -793,29 +785,27 @@ class PackageIndex(Environment):
if warning:
self.warn(warning, msg)
else:
- raise DistutilsError('%s %s' % (url, msg)) from v
+ raise DistutilsError(f'{url} {msg}') from v
except urllib.error.HTTPError as v:
return v
except urllib.error.URLError as v:
if warning:
self.warn(warning, v.reason)
else:
- raise DistutilsError(
- "Download error for %s: %s" % (url, v.reason)
- ) from v
+ raise DistutilsError(f"Download error for {url}: {v.reason}") from v
except http.client.BadStatusLine as v:
if warning:
self.warn(warning, v.line)
else:
raise DistutilsError(
- '%s returned a bad status line. The server might be '
- 'down, %s' % (url, v.line)
+ f'{url} returned a bad status line. The server might be '
+ f'down, {v.line}'
) from v
except (http.client.HTTPException, OSError) as v:
if warning:
self.warn(warning, v)
else:
- raise DistutilsError("Download error for %s: %s" % (url, v)) from v
+ raise DistutilsError(f"Download error for {url}: {v}") from v
def _download_url(self, url, tmpdir):
# Determine download filename
@@ -1134,7 +1124,7 @@ def local_open(url):
break
elif os.path.isdir(filepath):
f += '/'
- files.append('<a href="{name}">{name}</a>'.format(name=f))
+ files.append(f'<a href="{f}">{f}</a>')
else:
tmpl = "<html><head><title>{url}</title></head><body>{files}</body></html>"
body = tmpl.format(url=url, files='\n'.join(files))
diff --git a/contrib/python/setuptools/py3/setuptools/wheel.py b/contrib/python/setuptools/py3/setuptools/wheel.py
index fb19f1a65a..c7ca43b5cf 100644
--- a/contrib/python/setuptools/py3/setuptools/wheel.py
+++ b/contrib/python/setuptools/py3/setuptools/wheel.py
@@ -79,7 +79,7 @@ class Wheel:
def __init__(self, filename) -> None:
match = WHEEL_NAME(os.path.basename(filename))
if match is None:
- raise ValueError('invalid wheel name: %r' % filename)
+ raise ValueError(f'invalid wheel name: {filename!r}')
self.filename = filename
for k, v in match.groupdict().items():
setattr(self, k, v)
@@ -122,9 +122,9 @@ class Wheel:
self._install_as_egg(destination_eggdir, zf)
def _install_as_egg(self, destination_eggdir, zf):
- dist_basename = '%s-%s' % (self.project_name, self.version)
+ dist_basename = f'{self.project_name}-{self.version}'
dist_info = self.get_dist_info(zf)
- dist_data = '%s.data' % dist_basename
+ dist_data = f'{dist_basename}.data'
egg_info = os.path.join(destination_eggdir, 'EGG-INFO')
self._convert_metadata(zf, destination_eggdir, dist_info, egg_info)
@@ -145,7 +145,7 @@ class Wheel:
wheel_version = parse_version(wheel_metadata.get('Wheel-Version'))
wheel_v1 = parse_version('1.0') <= wheel_version < parse_version('2.0dev0')
if not wheel_v1:
- raise ValueError('unsupported wheel format version: %s' % wheel_version)
+ raise ValueError(f'unsupported wheel format version: {wheel_version}')
# Extract to target directory.
_unpack_zipfile_obj(zf, destination_eggdir)
# Convert metadata.
diff --git a/contrib/python/setuptools/py3/ya.make b/contrib/python/setuptools/py3/ya.make
index a6375ff2b8..85aa187c37 100644
--- a/contrib/python/setuptools/py3/ya.make
+++ b/contrib/python/setuptools/py3/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(75.6.0)
+VERSION(75.7.0)
LICENSE(MIT)
@@ -64,7 +64,6 @@ PY_SRCS(
setuptools/_distutils/command/install_scripts.py
setuptools/_distutils/command/sdist.py
setuptools/_distutils/compat/__init__.py
- setuptools/_distutils/compat/py38.py
setuptools/_distutils/compat/py39.py
setuptools/_distutils/core.py
setuptools/_distutils/cygwinccompiler.py