Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions distutils/command/build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,7 @@ def find_swig(self):
fn = os.path.join(f"c:\\swig{vers}", "swig.exe")
if os.path.isfile(fn):
return fn
else:
return "swig.exe"
return "swig.exe"
else:
raise DistutilsPlatformError(
f"I don't know how to find (much less run) SWIG on platform '{os.name}'"
Expand Down
29 changes: 14 additions & 15 deletions distutils/command/build_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,22 +167,21 @@ def get_package_dir(self, package):
else:
tail.insert(0, pdir)
return os.path.join(*tail)
# Oops, got all the way through 'path' without finding a
# match in package_dir. If package_dir defines a directory
# for the root (nameless) package, then fallback on it;
# otherwise, we might as well have not consulted
# package_dir at all, as we just use the directory implied
# by 'tail' (which should be the same as the original value
# of 'path' at this point).
pdir = self.package_dir.get('')
if pdir is not None:
tail.insert(0, pdir)

if tail:
return os.path.join(*tail)
else:
# Oops, got all the way through 'path' without finding a
# match in package_dir. If package_dir defines a directory
# for the root (nameless) package, then fallback on it;
# otherwise, we might as well have not consulted
# package_dir at all, as we just use the directory implied
# by 'tail' (which should be the same as the original value
# of 'path' at this point).
pdir = self.package_dir.get('')
if pdir is not None:
tail.insert(0, pdir)

if tail:
return os.path.join(*tail)
else:
return ''
return ''

def check_package(self, package, package_dir):
# Empty dir name means current directory, which we can probably
Expand Down
3 changes: 1 addition & 2 deletions distutils/command/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ def _gen_temp_sourcefile(self, body, headers, lang):
filename = "_configtest" + LANG_EXT[lang]
with open(filename, "w", encoding='utf-8') as file:
if headers:
for header in headers:
file.write(f"#include <{header}>\n")
file.writelines(f"#include <{header}>\n" for header in headers)
file.write("\n")
file.write(body)
if body[-1] != "\n":
Expand Down
5 changes: 2 additions & 3 deletions distutils/command/sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def checking_metadata(self) -> bool:
(
'keep-temp',
'k',
"keep the distribution tree around after creating " + "archive file(s)",
"keep the distribution tree around after creating archive file(s)",
),
(
'dist-dir=',
Expand Down Expand Up @@ -206,8 +206,7 @@ def get_file_list(self) -> None:

if not template_exists:
self.warn(
("manifest template '%s' does not exist " + "(using default file list)")
% self.template
f"manifest template '{self.template}' does not exist (using default file list)"
)
self.filelist.findall()

Expand Down
12 changes: 5 additions & 7 deletions distutils/compilers/C/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,12 @@ class (via the 'executables' class attribute), but most will have:
# discovered at run-time, since there are many different ways to do
# basically the same things with Unix C compilers.

for key in kwargs:
for key, value in kwargs.items():
if key not in self.executables:
raise ValueError(
f"unknown executable '{key}' for class {self.__class__.__name__}"
)
self.set_executable(key, kwargs[key])
self.set_executable(key, value)

def set_executable(self, key, value):
if isinstance(value, str):
Expand All @@ -205,11 +205,9 @@ def set_executable(self, key, value):
setattr(self, key, value)

def _find_macro(self, name):
i = 0
for defn in self.macros:
for i, defn in enumerate(self.macros):
if defn[0] == name:
return i
i += 1
return None

def _check_macro_definitions(self, definitions):
Expand Down Expand Up @@ -1013,10 +1011,10 @@ def object_filenames(
) -> list[str]:
if output_dir is None:
output_dir = ''
return list(
return [
self._make_out_path(output_dir, strip_dir, src_name)
for src_name in source_filenames
)
]

@property
def out_extensions(self):
Expand Down
5 changes: 2 additions & 3 deletions distutils/compilers/C/msvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,5 @@ def find_library_file(self, dirs, lib, debug=False):
libfile = os.path.join(dir, self.library_filename(name))
if os.path.isfile(libfile):
return libfile
else:
# Oops, didn't find it in *any* of 'dirs'
return None
# Oops, didn't find it in *any* of 'dirs'
return None
2 changes: 1 addition & 1 deletion distutils/compilers/C/unix.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def find_library_file(self, dirs, lib, debug=False):
"""
lib_names = (
self.library_filename(lib, lib_type=type)
for type in 'dylib xcode_stub shared static'.split()
for type in ('dylib', 'xcode_stub', 'shared', 'static')
)

roots = map(self._library_root, dirs)
Expand Down
2 changes: 1 addition & 1 deletion distutils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def run_commands(dist):
if DEBUG:
raise
else:
raise SystemExit("error: " + str(msg))
raise SystemExit(f"error: {msg}")

return dist

Expand Down
2 changes: 1 addition & 1 deletion distutils/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ def parse_command_line(self):
parser.set_aliases({'licence': 'license'})
args = parser.getopt(args=self.script_args, object=self)
option_order = parser.get_option_order()
logging.getLogger().setLevel(logging.WARN - 10 * self.verbose)
logging.getLogger().setLevel(logging.WARNING - 10 * self.verbose)

# for display options we return immediately
if self.handle_display_options(option_order):
Expand Down
4 changes: 2 additions & 2 deletions distutils/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

DEBUG = logging.DEBUG
INFO = logging.INFO
WARN = logging.WARN
WARN = logging.WARNING
ERROR = logging.ERROR
FATAL = logging.FATAL

Expand All @@ -31,7 +31,7 @@ def set_threshold(level):

def set_verbosity(v):
if v <= 0:
set_threshold(logging.WARN)
set_threshold(logging.WARNING)
elif v == 1:
set_threshold(logging.INFO)
elif v >= 2:
Expand Down
3 changes: 1 addition & 2 deletions distutils/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ def test_run_setup_uses_current_dir(self, tmp_path):
distutils.core.run_setup(setup_py)

output = sys.stdout.getvalue()
if output.endswith("\n"):
output = output[:-1]
output = output.removesuffix("\n")
assert cwd == output

def test_run_setup_within_if_main(self, temp_file):
Expand Down
2 changes: 1 addition & 1 deletion distutils/versionpredicate.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def __init__(self, versionPredicateStr):

def __str__(self):
if self.pred:
seq = [cond + " " + str(ver) for cond, ver in self.pred]
seq = [f"{cond} {ver}" for cond, ver in self.pred]
return self.name + " (" + ", ".join(seq) + ")"
else:
return self.name
Expand Down
Loading