Skip to content

Commit 1345552

Browse files
committed
Configurable build-details.json name
Linux distributions that co-install multiple Python versions in the same path (e.g. multiarch on Debian, debug builds, and free-threading) need a way to place multiple build-details.jsons side-by-side. PEP-739 is being updated [0] to recommend renaming in this situation. To ensure some standardization, this PR generates appropriate names for distributions that need to use this feature. [0]: python/peps#4889
1 parent 51a5715 commit 1345552

3 files changed

Lines changed: 93 additions & 5 deletions

File tree

Makefile.pre.in

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@
215215
# the build, and is only listed here so it will be included in sysconfigdata.
216216
IPHONEOS_DEPLOYMENT_TARGET=@IPHONEOS_DEPLOYMENT_TARGET@
217217

218+
BUILD_DETAILS=@BUILD_DETAILS@
219+
218220
# Option to install to strip binaries
219221
STRIPFLAG=-s
220222

@@ -774,11 +776,11 @@ list-targets:
774776

775777
.PHONY: build_all
776778
build_all: check-clean-src check-app-store-compliance $(BUILDPYTHON) platform sharedmods \
777-
gdbhooks Programs/_testembed scripts checksharedmods rundsymutil build-details.json
779+
gdbhooks Programs/_testembed scripts checksharedmods rundsymutil $(BUILD_DETAILS)
778780

779781
.PHONY: build_wasm
780782
build_wasm: check-clean-src $(BUILDPYTHON) platform sharedmods \
781-
python-config checksharedmods build-details.json
783+
python-config checksharedmods $(BUILD_DETAILS)
782784

783785
.PHONY: build_emscripten
784786
build_emscripten: build_wasm web_example web_example_pyrepl_jspi
@@ -979,8 +981,8 @@ pybuilddir.txt: $(PYTHON_FOR_BUILD_DEPS)
979981
exit 1 ; \
980982
fi
981983

982-
build-details.json: pybuilddir.txt
983-
$(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/Tools/build/generate-build-details.py `cat pybuilddir.txt`/build-details.json
984+
$(BUILD_DETAILS): pybuilddir.txt
985+
$(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/Tools/build/generate-build-details.py `cat pybuilddir.txt`/$(BUILD_DETAILS)
984986

985987
# Build static library
986988
$(LIBRARY): $(LIBRARY_OBJS)
@@ -2349,7 +2351,7 @@ multissltest: all
23492351
# Only the main install gets a build-details.json.
23502352
.PHONY: install
23512353
install: @FRAMEWORKINSTALLFIRST@ @INSTALLTARGETS@ @FRAMEWORKINSTALLLAST@
2352-
$(INSTALL_DATA) `cat pybuilddir.txt`/build-details.json $(DESTDIR)$(LIBDEST); \
2354+
$(INSTALL_DATA) `cat pybuilddir.txt`/$(BUILD_DETAILS) $(DESTDIR)$(LIBDEST); \
23532355
if test "x$(ENSUREPIP)" != "xno" ; then \
23542356
case $(ENSUREPIP) in \
23552357
upgrade) ensurepip="--upgrade" ;; \

configure

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

configure.ac

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7775,6 +7775,41 @@ AC_ARG_ENABLE([test-modules],
77757775
AC_MSG_RESULT([$TEST_MODULES])
77767776
AC_SUBST([TEST_MODULES])
77777777

7778+
# Check for --with-build-details-suffix
7779+
BUILD_DETAILS=build-details.json
7780+
AC_ARG_WITH([build-details-suffix],
7781+
[AS_HELP_STRING(
7782+
[--with-build-details-suffix=],
7783+
[rename build-details.json to permit multiple colocated Python installs; optionally specify a custom suffix (default: no)]
7784+
)],
7785+
[
7786+
AC_MSG_CHECKING([for --with-build-details-suffix])
7787+
7788+
AS_VAR_IF(
7789+
[with_build_detials_suffix], [no],
7790+
[AC_MSG_ERROR([invalid --with-build-details-suffix option: expected path or "yes", not "no"])]
7791+
)
7792+
AS_VAR_IF(
7793+
[with_build_details_suffix], [yes], [
7794+
colocated_install=yes
7795+
threading_suffix=""
7796+
if [[ "$ABI_THREAD" = "t" ]]; then
7797+
threading_suffix=-free-threading
7798+
fi
7799+
debug_suffix=""
7800+
if [[ "$Py_DEBUG" = "true" ]]; then
7801+
debug_suffix=-debug
7802+
fi
7803+
BUILD_DETAILS=build-details.$MULTIARCH$threading_suffix$debug_suffix.json
7804+
], [
7805+
BUILD_DETAILS=build-details.$with_build_details_suffix.json
7806+
]
7807+
)
7808+
]
7809+
)
7810+
AC_MSG_RESULT([$with_build_details_suffix])
7811+
AC_SUBST([BUILD_DETAILS], [$BUILD_DETAILS])
7812+
77787813
# gh-109054: Check if -latomic is needed to get <pyatomic.h> atomic functions.
77797814
# On Linux aarch64, GCC may require programs and libraries to be linked
77807815
# explicitly to libatomic. Call _Py_atomic_or_uint64() which may require

0 commit comments

Comments
 (0)