Skip to content

Commit 9c23f34

Browse files
authored
gh-131372: Configurable build-details.json name (#150098)
* 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 * NEWS entry * Document configure option and add to whatsnew
1 parent 07ae6f1 commit 9c23f34

6 files changed

Lines changed: 109 additions & 5 deletions

File tree

Doc/using/configure.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,15 @@ General Options
473473

474474
.. versionadded:: 3.15
475475

476+
.. option:: --with-build-details-suffix=[yes|SUFFIX]
477+
478+
Rename ``build-details.json`` to permit multiple co-located Python
479+
installs. If a custom ``SUFFIX`` is supplied it is used verbatim,
480+
otherwise one will be generated from the ``MULTIARCH`` tag with
481+
``-free-threading`` and ``-debug``, as appropriate.
482+
483+
.. versionadded:: 3.16
484+
476485

477486
C compiler options
478487
------------------

Doc/whatsnew/3.16.rst

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

228228
.. _libmpdec: https://www.bytereef.org/mpdecimal/
229229

230+
* Add a :option:`--with-build-details-suffix` configure flag to allow
231+
Linux distributions that co-install multiple versions of Python in the
232+
same tree to avoid ``build-details.json`` clashes.
233+
234+
(Contributed by Stefano Rivera in :gh:`131372`.)
235+
230236

231237
C API changes
232238
=============

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" ;; \
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Add a :option:`--with-build-details-suffix` configure flag to allow Linux
2+
distributions that co-install multiple versions of Python in the same tree
3+
to avoid ``build-details.json`` clashes.

configure

Lines changed: 50 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: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7840,6 +7840,40 @@ AC_ARG_ENABLE([test-modules],
78407840
AC_MSG_RESULT([$TEST_MODULES])
78417841
AC_SUBST([TEST_MODULES])
78427842

7843+
# Check for --with-build-details-suffix
7844+
BUILD_DETAILS=build-details.json
7845+
AC_ARG_WITH([build-details-suffix],
7846+
[AS_HELP_STRING(
7847+
[--with-build-details-suffix=],
7848+
[rename build-details.json to permit multiple colocated Python installs; optionally specify a custom suffix (default: no)]
7849+
)],
7850+
[
7851+
AC_MSG_CHECKING([for --with-build-details-suffix])
7852+
AS_VAR_IF(
7853+
[with_build_detials_suffix], [no],
7854+
[AC_MSG_ERROR([invalid --with-build-details-suffix option: expected custom suffix or "yes", not "no"])]
7855+
)
7856+
AS_VAR_IF(
7857+
[with_build_details_suffix], [yes], [
7858+
colocated_install=yes
7859+
threading_suffix=""
7860+
if [[ "$ABI_THREAD" = "t" ]]; then
7861+
threading_suffix=-free-threading
7862+
fi
7863+
debug_suffix=""
7864+
if [[ "$Py_DEBUG" = "true" ]]; then
7865+
debug_suffix=-debug
7866+
fi
7867+
BUILD_DETAILS=build-details.$MULTIARCH$threading_suffix$debug_suffix.json
7868+
], [
7869+
BUILD_DETAILS=build-details.$with_build_details_suffix.json
7870+
]
7871+
)
7872+
]
7873+
)
7874+
AC_MSG_RESULT([$with_build_details_suffix])
7875+
AC_SUBST([BUILD_DETAILS], [$BUILD_DETAILS])
7876+
78437877
# gh-109054: Check if -latomic is needed to get <pyatomic.h> atomic functions.
78447878
# On Linux aarch64, GCC may require programs and libraries to be linked
78457879
# explicitly to libatomic. Call _Py_atomic_or_uint64() which may require

0 commit comments

Comments
 (0)