2

Is there a compile option for Python that will prevent the creation of the python3 symlink to the newly created binary?

I'm attempting to build and install multiple versions of python on a single system for usage with a CI system to run tests using multiple python versions. Specifically Python-3.6.6, Python-3.7.4, and Python-3.8.0.

The process for building and installing is below (assuming the source has already been downloaded and unpacked into /usr/src/python):

cd /usr/src/python
./configure \
  --prefix=/usr/ \
  --build=x86_64-linux-gnu \
  --enable-loadable-sqlite-extensions \
  --enable-shared \
  --with-system-expat \
  --with-system-ffi \
  --without-ensurepip
make -j "$(nproc)"
make install

When the above process is completed, I end up with the built binary (for example, /usr/bin/python3.7 for Python-3.7.8) but also a symlink from /usr/bin/python3 to that binary. Whichever version of python I install last overwrites the symlink to link to itself, regardless of what it linked to before:

My question is: is there a flag I can pass to either the configure script or make that will disable creating this symlink entirely? I can create the symlink to the binary I want to be the "default" python3 version as part of my own setup process as I'd rather not rely on the install order to determine my default version.

I've looked through the python developer documentation but haven't been able to find a comprehensive list of the build arguments and documentation about what they do. This also isn't my area of expertise so I wasn't able to find what I was looking for in the source (but if someone could point me to it that would be much appreciated).

2
  • Are you looking for make altinstall? Commented Sep 14, 2020 at 15:54
  • Yep, that's exactly what I'm looking for @DeepSpace. If you leave an answer with that I'll verify it. Thank you so much! Commented Sep 14, 2020 at 16:19

1 Answer 1

4

make altinstall is made exactly for that:

make install can overwrite or masquerade the python3 binary. make altinstall is therefore recommended instead of make install since it only installs exec_prefix/bin/pythonversion.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.