Skip to content

Commit 32e27f9

Browse files
authored
Merge branch 'main' into gh-131178-fileinput-cli-tests
2 parents 0e8761b + 1994e3f commit 32e27f9

17 files changed

Lines changed: 482 additions & 52 deletions

‎Doc/whatsnew/3.16.rst‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,6 +1525,12 @@ Build changes
15251525

15261526
(Contributed by Stefano Rivera in :gh:`131372`.)
15271527

1528+
* The paths in the installed ``build-details.json`` file (:pep:`739`) are
1529+
now relative to the file's location instead of absolute, so the file stays
1530+
correct when the installation is moved.
1531+
1532+
(Contributed by Itamar Oren in :gh:`119696`.)
1533+
15281534
* Add the :option:`--with-curses` :program:`configure` option to select the
15291535
curses backend for the :mod:`curses` and :mod:`curses.panel` modules.
15301536
In addition to ``ncursesw`` and ``ncurses``, it can now build against the

‎Include/internal/pycore_global_objects_fini_generated.h‎

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Include/internal/pycore_global_strings.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ struct _Py_global_strings {
314314
STRUCT_FOR_ID(all_interpreters)
315315
STRUCT_FOR_ID(all_threads)
316316
STRUCT_FOR_ID(allow_code)
317+
STRUCT_FOR_ID(allow_nan)
317318
STRUCT_FOR_ID(alphabet)
318319
STRUCT_FOR_ID(any)
319320
STRUCT_FOR_ID(append)
@@ -461,6 +462,7 @@ struct _Py_global_strings {
461462
STRUCT_FOR_ID(element_factory)
462463
STRUCT_FOR_ID(emptyerror)
463464
STRUCT_FOR_ID(encode)
465+
STRUCT_FOR_ID(encoder)
464466
STRUCT_FOR_ID(encoding)
465467
STRUCT_FOR_ID(end)
466468
STRUCT_FOR_ID(end_col_offset)
@@ -564,6 +566,7 @@ struct _Py_global_strings {
564566
STRUCT_FOR_ID(in_fd)
565567
STRUCT_FOR_ID(include_aliases)
566568
STRUCT_FOR_ID(incoming)
569+
STRUCT_FOR_ID(indent)
567570
STRUCT_FOR_ID(index)
568571
STRUCT_FOR_ID(indexgroup)
569572
STRUCT_FOR_ID(inf)
@@ -597,6 +600,7 @@ struct _Py_global_strings {
597600
STRUCT_FOR_ID(isolation_level)
598601
STRUCT_FOR_ID(istext)
599602
STRUCT_FOR_ID(item)
603+
STRUCT_FOR_ID(item_separator)
600604
STRUCT_FOR_ID(items)
601605
STRUCT_FOR_ID(iter)
602606
STRUCT_FOR_ID(iterable)
@@ -606,6 +610,7 @@ struct _Py_global_strings {
606610
STRUCT_FOR_ID(jump)
607611
STRUCT_FOR_ID(keepends)
608612
STRUCT_FOR_ID(key)
613+
STRUCT_FOR_ID(key_separator)
609614
STRUCT_FOR_ID(keyfile)
610615
STRUCT_FOR_ID(keys)
611616
STRUCT_FOR_ID(kind)
@@ -639,6 +644,7 @@ struct _Py_global_strings {
639644
STRUCT_FOR_ID(loop)
640645
STRUCT_FOR_ID(manual_reset)
641646
STRUCT_FOR_ID(mapping)
647+
STRUCT_FOR_ID(markers)
642648
STRUCT_FOR_ID(mask)
643649
STRUCT_FOR_ID(match)
644650
STRUCT_FOR_ID(max_length)
@@ -828,9 +834,11 @@ struct _Py_global_strings {
828834
STRUCT_FOR_ID(sizehint)
829835
STRUCT_FOR_ID(skip_file_prefixes)
830836
STRUCT_FOR_ID(skip_non_matching_threads)
837+
STRUCT_FOR_ID(skipkeys)
831838
STRUCT_FOR_ID(sleep)
832839
STRUCT_FOR_ID(sock)
833840
STRUCT_FOR_ID(sort)
841+
STRUCT_FOR_ID(sort_keys)
834842
STRUCT_FOR_ID(source)
835843
STRUCT_FOR_ID(source_traceback)
836844
STRUCT_FOR_ID(spam)

‎Include/internal/pycore_runtime_init_generated.h‎

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Include/internal/pycore_unicodeobject_generated.h‎

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Lib/test/test_build_details.py‎

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,32 @@ def contents(self):
139139
with open(self.location, 'r', encoding='utf-8') as f:
140140
return f.read()
141141

142+
def resolve(self, value):
143+
"""Resolve a path from the file, as a PEP 739 consumer would."""
144+
base_prefix = os.path.join(os.path.dirname(self.location),
145+
self.key('base_prefix'))
146+
return os.path.normpath(os.path.join(base_prefix, value))
147+
142148
@needs_installed_python
143149
def test_location(self):
144150
self.assertTrue(os.path.isfile(self.location))
145151

152+
@needs_installed_python
153+
def test_paths_are_relative(self):
154+
self.assertFalse(os.path.isabs(self.key('base_prefix')))
155+
self.assertEqual(os.path.realpath(self.resolve('.')),
156+
os.path.realpath(sys.base_prefix))
157+
158+
for name in ('base_interpreter', 'libpython.dynamic',
159+
'libpython.dynamic_stableabi', 'libpython.static',
160+
'c_api.headers', 'c_api.pkgconfig_path'):
161+
with self.subTest(key=name):
162+
try:
163+
value = self.key(name)
164+
except KeyError:
165+
continue
166+
self.assertFalse(os.path.isabs(value))
167+
146168
def test_abi(self):
147169
self.assertEqual(self.key('abi.flags'), list(sys.abiflags))
148170
self.assertEqual(self.key('abi.extension_suffix'),
@@ -162,11 +184,7 @@ def test_extension_suffixes(self):
162184
'Android and iOS run tests via a custom testbed method that changes sys.executable'
163185
)
164186
def test_base_interpreter(self):
165-
value = self.key('base_interpreter')
166-
167-
# Skip check if installation is relocated
168-
if sysconfig._installation_is_relocated():
169-
self.skipTest("Installation is relocated")
187+
value = self.resolve(self.key('base_interpreter'))
170188

171189
self.assertEqual(os.path.realpath(value), os.path.realpath(sys.executable))
172190

@@ -178,13 +196,11 @@ def test_base_interpreter(self):
178196
def test_c_api(self):
179197
value = self.key('c_api')
180198

181-
# Skip check if installation is relocated
182-
if sysconfig._installation_is_relocated():
183-
self.skipTest("Installation is relocated")
184-
185-
self.assertTrue(os.path.exists(os.path.join(value['headers'], 'Python.h')))
199+
headers = self.resolve(value['headers'])
200+
self.assertTrue(os.path.exists(os.path.join(headers, 'Python.h')))
186201
version = sysconfig.get_config_var('VERSION')
187-
self.assertTrue(os.path.exists(os.path.join(value['pkgconfig_path'], f'python-{version}.pc')))
202+
pkgconfig_path = self.resolve(value['pkgconfig_path'])
203+
self.assertTrue(os.path.exists(os.path.join(pkgconfig_path, f'python-{version}.pc')))
188204

189205
@needs_installed_python
190206
@unittest.skipIf(
@@ -196,11 +212,8 @@ def test_libpython_static(self):
196212
if 'static' not in value:
197213
self.skipTest("No static libpython")
198214

199-
if sysconfig._installation_is_relocated():
200-
self.skipTest("Installation is relocated")
201-
202215
# The path must name an installed static library (an 'ar' archive).
203-
with open(value['static'], 'rb') as f:
216+
with open(self.resolve(value['static']), 'rb') as f:
204217
self.assertEqual(f.read(8), b'!<arch>\n')
205218

206219
@needs_installed_python
@@ -218,10 +231,7 @@ def test_libpython_dynamic(self):
218231
if 'dynamic' not in value:
219232
self.skipTest("No dynamic libpython")
220233

221-
if sysconfig._installation_is_relocated():
222-
self.skipTest("Installation is relocated")
223-
224-
self.assertTrue(os.path.isfile(value['dynamic']))
234+
self.assertTrue(os.path.isfile(self.resolve(value['dynamic'])))
225235

226236

227237
@unittest.skipIf(

‎Lib/test/test_sysconfig.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,28 @@ def test_makefile_overwrites_config_vars(self):
709709
self.assertNotEqual(data['prefix'], data['base_prefix'])
710710
self.assertNotEqual(data['exec_prefix'], data['base_exec_prefix'])
711711

712+
@unittest.skipIf(os.name != 'posix', 'pkg-config files are only installed on POSIX')
713+
@unittest.skipIf(is_wasi or is_android or is_apple_mobile,
714+
'no pkg-config files on this platform')
715+
@unittest.skipIf(get_config_var('RELOCATABLE') != 'yes',
716+
'requires --enable-relocatable')
717+
@unittest.skipIf(is_python_build(),
718+
'pkg-config files are only installed by make install')
719+
def test_pkgconfig_prefix(self):
720+
libpc = os.path.join(os.path.dirname(sys._stdlib_dir), 'pkgconfig')
721+
ldversion = get_config_var('LDVERSION')
722+
for name in (f'python-{ldversion}.pc', f'python-{ldversion}-embed.pc'):
723+
path = os.path.join(libpc, name)
724+
if not os.path.exists(path):
725+
self.skipTest(f'{path} not found')
726+
with self.subTest(file=name), open(path, encoding='utf-8') as f:
727+
prefix = next(line.removeprefix('prefix=').rstrip('\n')
728+
for line in f if line.startswith('prefix='))
729+
self.assertStartsWith(prefix, '${pcfiledir}/')
730+
resolved = prefix.replace('${pcfiledir}', libpc)
731+
self.assertEqual(os.path.realpath(resolved),
732+
os.path.realpath(sys.base_prefix))
733+
712734
@unittest.skipIf(os.name != 'posix', '_sysconfig-vars JSON file is only available on POSIX')
713735
@unittest.skipIf(is_wasi, "_sysconfig-vars JSON file currently isn't available on WASI")
714736
@unittest.skipIf(is_android or is_apple_mobile, 'Android and iOS change the prefix')

0 commit comments

Comments
 (0)