Skip to content

Commit 8d46b87

Browse files
authored
Use relative paths in build-details.json (#811)
Fixes #712.
1 parent 145dc8d commit 8d46b87

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

cpython-unix/build-cpython.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,12 @@ if [ "${PYTHON_MAJMIN_VERSION}" = 3.14 ]; then
326326
patch -p1 -i ${ROOT}/patch-python-3.14-asyncio-static.patch
327327
fi
328328

329+
# Ensure the new build-details.json file reports relocatable paths.
330+
# There is not yet a flag in ./configure for this, sadly.
331+
if [ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_14}" ]; then
332+
patch -p1 -i ${ROOT}/patch-python-relative-build-details.patch
333+
fi
334+
329335
# Most bits look at CFLAGS. But setup.py only looks at CPPFLAGS.
330336
# So we need to set both.
331337
CFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC -I${TOOLS_PATH}/deps/include -I${TOOLS_PATH}/deps/include/ncursesw"
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
From 5bb9be38eae4afe6246691a7affe0c7681f45ca2 Mon Sep 17 00:00:00 2001
2+
From: Geoffrey Thomas <[email protected]>
3+
Date: Mon, 6 Oct 2025 18:07:47 -0400
4+
Subject: [PATCH 1/1] Makefile: Generate relative paths for build-details.json
5+
6+
---
7+
Makefile.pre.in | 2 +-
8+
Tools/build/generate-build-details.py | 5 ++++-
9+
2 files changed, 5 insertions(+), 2 deletions(-)
10+
11+
diff --git a/Makefile.pre.in b/Makefile.pre.in
12+
index 764eef5be3e..4dbbf8ad8bc 100644
13+
--- a/Makefile.pre.in
14+
+++ b/Makefile.pre.in
15+
@@ -1004,7 +1004,7 @@ pybuilddir.txt: $(PYTHON_FOR_BUILD_DEPS)
16+
fi
17+
18+
build-details.json: pybuilddir.txt
19+
- $(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/Tools/build/generate-build-details.py `cat pybuilddir.txt`/build-details.json
20+
+ $(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/Tools/build/generate-build-details.py --relative-paths --config-file-path $(LIBDEST)/build-details.json `cat pybuilddir.txt`/build-details.json
21+
22+
# Build static library
23+
$(LIBRARY): $(LIBRARY_OBJS)
24+
diff --git a/Tools/build/generate-build-details.py b/Tools/build/generate-build-details.py
25+
index ed9ab2844d2..8d086ce3b32 100644
26+
--- a/Tools/build/generate-build-details.py
27+
+++ b/Tools/build/generate-build-details.py
28+
@@ -131,11 +131,12 @@ def generate_data(schema_version: str) -> collections.defaultdict[str, Any]:
29+
30+
31+
def make_paths_relative(data: dict[str, Any], config_path: str | None = None) -> None:
32+
+ base_prefix = data['base_prefix']
33+
+
34+
# Make base_prefix relative to the config_path directory
35+
if config_path:
36+
data['base_prefix'] = relative_path(data['base_prefix'],
37+
os.path.dirname(config_path))
38+
- base_prefix = data['base_prefix']
39+
40+
# Update path values to make them relative to base_prefix
41+
PATH_KEYS = (
42+
@@ -203,6 +204,8 @@ def main() -> None:
43+
if args.relative_paths:
44+
make_paths_relative(data, args.config_file_path)
45+
46+
+ print(f"generate-build-details debug: {sysconfig=} {sysconfig.get_platform()=}", file=sys.stderr)
47+
+
48+
json_output = json.dumps(data, indent=2)
49+
with open(args.location, 'w', encoding='utf-8') as f:
50+
f.write(json_output)
51+
--
52+
2.39.5 (Apple Git-154)
53+

0 commit comments

Comments
 (0)