https://github.com/python/cpython/commit/ef1cf22e0d4746b02e1e559b0b9b3a46cb086f95
commit: ef1cf22e0d4746b02e1e559b0b9b3a46cb086f95
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: itamaro <[email protected]>
date: 2026-10-21T17:27:48-07:00
summary:

[3.15] gh-160004: Fix build-details.json paths with `--config-file-path` 
(GH-160007) (#160143)

gh-160004: Fix build-details.json paths with `--config-file-path` (GH-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.
(cherry picked from commit fc1a634099fdcc03b4e92b048d7f9ff87a3f134c)

Co-authored-by: Itamar Oren <[email protected]>

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 3d5e4685efe871..12b7664d83aae1 100644
--- a/Lib/test/test_build_details.py
+++ b/Lib/test/test_build_details.py
@@ -237,6 +237,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 c03321dab64e86..4fb49bf139b225 100644
--- a/Tools/build/generate-build-details.py
+++ b/Tools/build/generate-build-details.py
@@ -150,11 +150,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]

Reply via email to