Eliminate conflicts between build variants installed to a common prefix #122402
Labels
3.13
bugs and security fixes
3.14
new features, bugs and security fixes
build
The build process and cross-build
needs backport to 3.13
bugs and security fixes
topic-ensurepip
topic-free-threading
When using
configure
-based (i.e. non-Windows) Python installations, if more than one build variant is installed to the same prefix, some files in thebin
andlib/pkgconfig
directories currently are installed with the same name by each variant, with potentially unpredictable and undesired results.As of Python 3.13, there are currently four build variants of interest:
d
suffix)t
suffix)td
suffix)Issue #121103 and associated PRs implemented a separation of the installed
lib/python3.x
directory into separate directories when installing to a common installation prefix:lib/python3.x
(for the default and debug variants) andlib/python3.xt
(for the free-threaded and free-threaded debug variants). The rationale was primarily to avoid confusion when installing a third-party package that only supports one variant but is on the import path of any variant due to the common directories onsys.path
.However, there still remain conflicts elsewhere within the common install prefix, namely, in the
bin
andlib/pkgconfig
directories.When more than one variant shares a
bin
directory, there are two kinds of conflicts: (1) files installed by the cpython build system with the same name but variant-specific content; and (2)script
files (or any other file) installed by a third-party package to thebin
directory.For the second category, the main issue is that, if the user wishes to install a third-party package to more than one variant, its scripts will only be associated with one instance (through its shebang line). There are straight-forward workarounds for this, like installing in separate venvs, if the user is aware of them, but those solutions might not always be desirable. Perhaps the best we can do for this at the moment is to try to document best practices. This is not further addresses here.
The first category of conflicts are centered around the cpython Makefile. For python
unix
(configure / Makefile) installs, there are two types of installs:make altinstall
which installs bin files with a3.x
suffix, i.e.python3.13
; andmake install
which also installs unversioned links as well as those installed byaltinstall
, i.e.python3
along withpython3.13
. There are also similarly-versioned.pc
files installed inlib/pkgconfig
for use by third-partypkg-config
utilities.Since free-threading as introduced in Python 3.13 is considered an experimental feature, it was decided to keep free-threaded and default (traditional GIL-enabled) builds independent initially, in particular, by using different names to invoke the different interpreters,
python3.13
vspython3.13t
, without doing anything to preclude moving to a single build in a future feature release. While the safest way to keep them independent would be to install each to a separateprefix
, like/opt/python3.14
vs/opt/python3.14t
, there are advantages to and expectations by users and distributors to using a common install prefix for each variant, say/usr/local/bin/python3.13
and/usr/local/bin/python3.13t
and possibly/usr/local/bin/python3.13td
.As it stands now, though, there are a number of conflicting file names that are getting installed by each variant. Here is an exhaustive list of conflicts:
by
make altinstall
by
make install
(in addition to those ofaltinstall
)To resolve this, I recommend the following changes:
default
build install/altinstall.make altinstall
ford
,t
, andtd
variantsmake install
ford
,t
, andtd
variantsThe associated PR implements these changes.
As an example,
./configure && make && make install
produces the following (both before and after this PR with
->
indicating a symlink):while
./configure --disable-gil && make && make install
produces this currently:
and with the PR applied produces this:
Note that the only overlapping files names with the PR applied are those of
pip
. Thepip
install itself creates those files, rather than the PythonMakefile
. Without delving intopip
itself, I did not see an obvious fix. Perhaps a combination ofpip
and/orensurepip
changes may be needed.Additional documentation for the above aimed at users and distributors is probably also warranted.
Also, it should be noted that framework builds (
--enable-framework
) on macOS and iOS have additional common prefix compatibility issues that are not addressed above. Fortunately, there is a straightforward workaround: use separate framework names for each variant (--with-framework-name=...
). (The python.org macOS installers for 3.13 are usingPython
andPythonT
for the default and the free-threading builds.) Further work on improvingframework
commonality may be the subject of a future issue and PR.Linked PRs
The text was updated successfully, but these errors were encountered: