https://github.com/python/cpython/commit/fc1a634099fdcc03b4e92b048d7f9ff87a3f134c
commit: fc1a634099fdcc03b4e92b048d7f9ff87a3f134c
branch: main
author: Itamar Oren <[email protected]>
committer: itamaro <[email protected]>
date: 2026-10-21T23:05:50Z
summary:
gh-160004: Fix build-details.json paths with `--config-file-path` (#160007)
`make_paths_relative()` now keeps the absolute `base_prefix` for computing the
other paths, and only the stored `base_prefix` is made relative to the config
file's directory. This is the same fix python-build-standalone carries in
`patch-python-relative-build-details.patch` (by @geofft). That patch also
changes the Makefile to generate relative paths by default; this PR leaves the
Makefile alone.
files:
A Misc/NEWS.d/next/Build/2026-10-20-23-30-00.gh-issue-160004.CfgPth.rst
M Lib/test/test_build_details.py
M Tools/build/generate-build-details.py
diff --git a/Lib/test/test_build_details.py b/Lib/test/test_build_details.py
index b6f4b6fe26379b..7ee73614462e51 100644
--- a/Lib/test/test_build_details.py
+++ b/Lib/test/test_build_details.py
@@ -217,6 +217,24 @@ def test_round_trip(self):
self.assertEqual(data_abs_path['base_prefix'],
data_rel_path['base_prefix'])
+ self.check_relative_paths(data_abs_path, data_rel_path)
+
+ def test_round_trip_with_config_file_path(self):
+ data_abs_path = self.build_details_absolute_paths
+ base_prefix = data_abs_path['base_prefix']
+ config_dir = os.path.join(base_prefix, 'lib', 'python3.X')
+ data_rel_path = self.build_details_absolute_paths
+ generate_build_details.make_paths_relative(
+ data_rel_path,
+ config_path=os.path.join(config_dir, 'build-details.json'),
+ )
+
+ # base_prefix is relative to the config file's directory...
+ self.assertEqual(data_rel_path['base_prefix'], os.path.join('..',
'..'))
+ # ...while the other paths are still relative to base_prefix.
+ self.check_relative_paths(data_abs_path, data_rel_path)
+
+ def check_relative_paths(self, data_abs_path, data_rel_path):
base_prefix = data_abs_path['base_prefix']
top_level_keys = ('base_interpreter',)
diff --git
a/Misc/NEWS.d/next/Build/2026-10-20-23-30-00.gh-issue-160004.CfgPth.rst
b/Misc/NEWS.d/next/Build/2026-10-20-23-30-00.gh-issue-160004.CfgPth.rst
new file mode 100644
index 00000000000000..247f4677fc27c6
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2026-10-20-23-30-00.gh-issue-160004.CfgPth.rst
@@ -0,0 +1,4 @@
+Fix the paths in the :pep:`739` ``build-details.json`` file generated by
+:file:`Tools/build/generate-build-details.py` with both ``--relative-paths``
+and ``--config-file-path``. Previously, every path except ``base_prefix`` was
+wrong and depended on the directory the script was run from.
diff --git a/Tools/build/generate-build-details.py
b/Tools/build/generate-build-details.py
index 738c51026b77cc..d3ccc9f5f76c84 100644
--- a/Tools/build/generate-build-details.py
+++ b/Tools/build/generate-build-details.py
@@ -142,11 +142,12 @@ def generate_data(schema_version: str) ->
collections.defaultdict[str, Any]:
def make_paths_relative(data: dict[str, Any], config_path: str | None = None)
-> None:
- # Make base_prefix relative to the config_path directory
+ base_prefix = data['base_prefix']
+ # Make base_prefix relative to the config_path directory. The other paths
+ # are still made relative to the absolute base_prefix below.
if config_path:
- data['base_prefix'] = relative_path(data['base_prefix'],
+ data['base_prefix'] = relative_path(base_prefix,
os.path.dirname(config_path))
- base_prefix = data['base_prefix']
# Update path values to make them relative to base_prefix
PATH_KEYS = (
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]