Skip to content

Commit d46727f

Browse files
committed
Merge tag 'v69.4.2' into main.
2 parents 5d9e57f + 5de8e14 commit d46727f

File tree

8 files changed

+69
-23
lines changed

8 files changed

+69
-23
lines changed

NEWS.rst

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
v69.4.2
2+
=======
3+
4+
Bugfixes
5+
--------
6+
7+
- Merged bugfix for pypa/distutils#246 (#27489545)
8+
9+
110
v69.5.0
211
=======
312

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from __future__ import annotations
2+
3+
from .py38 import removeprefix
4+
5+
6+
def consolidate_linker_args(args: list[str]) -> str:
7+
"""
8+
Ensure the return value is a string for backward compatibility.
9+
10+
Retain until at least 2024-04-31. See pypa/distutils#246
11+
"""
12+
13+
if not all(arg.startswith('-Wl,') for arg in args):
14+
return args
15+
return '-Wl,' + ','.join(removeprefix(arg, '-Wl,') for arg in args)

setuptools/_distutils/compat/py38.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import sys
2+
3+
if sys.version_info < (3, 9):
4+
5+
def removesuffix(self, suffix):
6+
# suffix='' should not call self[:-0].
7+
if suffix and self.endswith(suffix):
8+
return self[: -len(suffix)]
9+
else:
10+
return self[:]
11+
12+
def removeprefix(self, prefix):
13+
if self.startswith(prefix):
14+
return self[len(prefix) :]
15+
else:
16+
return self[:]
17+
else:
18+
19+
def removesuffix(self, suffix):
20+
return self.removesuffix(suffix)
21+
22+
def removeprefix(self, prefix):
23+
return self.removeprefix(prefix)

setuptools/_distutils/dir_util.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ def create_tree(base_dir, files, mode=0o777, verbose=1, dry_run=0):
9494
'dry_run' flags are as for 'mkpath()'.
9595
"""
9696
# First get the list of directories to create
97-
need_dir = set()
98-
for file in files:
99-
need_dir.add(os.path.join(base_dir, os.path.dirname(file)))
97+
need_dir = set(os.path.join(base_dir, os.path.dirname(file)) for file in files)
10098

10199
# Now create them
102100
for dir in sorted(need_dir):

setuptools/_distutils/dist.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -647,15 +647,15 @@ def _show_help(
647647
options = self.global_options
648648
parser.set_option_table(options)
649649
parser.print_help(self.common_usage + "\nGlobal options:")
650-
print('')
650+
print()
651651

652652
if display_options:
653653
parser.set_option_table(self.display_options)
654654
parser.print_help(
655655
"Information display options (just display "
656656
+ "information, ignore any commands)"
657657
)
658-
print('')
658+
print()
659659

660660
for command in self.commands:
661661
if isinstance(command, type) and issubclass(command, Command):
@@ -669,7 +669,7 @@ def _show_help(
669669
else:
670670
parser.set_option_table(klass.user_options)
671671
parser.print_help("Options for '%s' command:" % klass.__name__)
672-
print('')
672+
print()
673673

674674
print(gen_usage(self.script_name))
675675

@@ -686,7 +686,7 @@ def handle_display_options(self, option_order):
686686
# we ignore "foo bar").
687687
if self.help_commands:
688688
self.print_commands()
689-
print('')
689+
print()
690690
print(gen_usage(self.script_name))
691691
return 1
692692

setuptools/_distutils/tests/test_msvc9compiler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def test_remove_visual_c_ref(self):
161161
f = open(manifest)
162162
try:
163163
# removing trailing spaces
164-
content = '\n'.join([line.rstrip() for line in f.readlines()])
164+
content = '\n'.join([line.rstrip() for line in f])
165165
finally:
166166
f.close()
167167

setuptools/_distutils/tests/test_unixccompiler.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import sys
55
import unittest.mock as mock
66
from distutils import sysconfig
7+
from distutils.compat import consolidate_linker_args
78
from distutils.errors import DistutilsPlatformError
89
from distutils.unixccompiler import UnixCCompiler
910
from distutils.util import _clear_cached_macosx_ver
@@ -149,10 +150,10 @@ def gcv(v):
149150
return 'yes'
150151

151152
sysconfig.get_config_var = gcv
152-
assert self.cc.rpath_foo() == [
153+
assert self.cc.rpath_foo() == consolidate_linker_args([
153154
'-Wl,--enable-new-dtags',
154155
'-Wl,-rpath,/foo',
155-
]
156+
])
156157

157158
def gcv(v):
158159
if v == 'CC':
@@ -161,10 +162,10 @@ def gcv(v):
161162
return 'yes'
162163

163164
sysconfig.get_config_var = gcv
164-
assert self.cc.rpath_foo() == [
165+
assert self.cc.rpath_foo() == consolidate_linker_args([
165166
'-Wl,--enable-new-dtags',
166167
'-Wl,-rpath,/foo',
167-
]
168+
])
168169

169170
# GCC non-GNULD
170171
sys.platform = 'bar'
@@ -189,10 +190,10 @@ def gcv(v):
189190
return 'yes'
190191

191192
sysconfig.get_config_var = gcv
192-
assert self.cc.rpath_foo() == [
193+
assert self.cc.rpath_foo() == consolidate_linker_args([
193194
'-Wl,--enable-new-dtags',
194195
'-Wl,-rpath,/foo',
195-
]
196+
])
196197

197198
# non-GCC GNULD
198199
sys.platform = 'bar'
@@ -204,10 +205,10 @@ def gcv(v):
204205
return 'yes'
205206

206207
sysconfig.get_config_var = gcv
207-
assert self.cc.rpath_foo() == [
208+
assert self.cc.rpath_foo() == consolidate_linker_args([
208209
'-Wl,--enable-new-dtags',
209210
'-Wl,-rpath,/foo',
210-
]
211+
])
211212

212213
# non-GCC non-GNULD
213214
sys.platform = 'bar'

setuptools/_distutils/unixccompiler.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@
1313
* link shared library handled by 'cc -shared'
1414
"""
1515

16+
from __future__ import annotations
17+
1618
import itertools
1719
import os
1820
import re
1921
import shlex
2022
import sys
2123

2224
from . import sysconfig
25+
from .compat import consolidate_linker_args
2326
from ._log import log
2427
from ._macos_compat import compiler_fixup
2528
from ._modified import newer
@@ -281,7 +284,7 @@ def _is_gcc(self):
281284
compiler = os.path.basename(shlex.split(cc_var)[0])
282285
return "gcc" in compiler or "g++" in compiler
283286

284-
def runtime_library_dir_option(self, dir):
287+
def runtime_library_dir_option(self, dir: str) -> str | list[str]:
285288
# XXX Hackish, at the very least. See Python bug #445902:
286289
# https://bugs.python.org/issue445902
287290
# Linkers on different platforms need different options to
@@ -313,11 +316,11 @@ def runtime_library_dir_option(self, dir):
313316
# For all compilers, `-Wl` is the presumed way to pass a
314317
# compiler option to the linker
315318
if sysconfig.get_config_var("GNULD") == "yes":
316-
return [
319+
return consolidate_linker_args([
317320
# Force RUNPATH instead of RPATH
318321
"-Wl,--enable-new-dtags",
319322
"-Wl,-rpath," + dir,
320-
]
323+
])
321324
else:
322325
return "-Wl,-R" + dir
323326

@@ -389,10 +392,7 @@ def find_library_file(self, dirs, lib, debug=0):
389392

390393
roots = map(self._library_root, dirs)
391394

392-
searched = (
393-
os.path.join(root, lib_name)
394-
for root, lib_name in itertools.product(roots, lib_names)
395-
)
395+
searched = itertools.starmap(os.path.join, itertools.product(roots, lib_names))
396396

397397
found = filter(os.path.exists, searched)
398398

0 commit comments

Comments
 (0)