[Packaging] When installed with RPM, run python3.6 if available #19110
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix #18222, #15668, #13892, #13612, #13017, #11819
Symptom
When run on
fedora:34, Azure CLI fails with:Cause
The build pipeline uses
centos:centos7azure-cli/scripts/release/rpm/Dockerfile.centos
Line 1 in f2855b8
to build the RPM package, which has Python 3.6 preinstalled.
Even though
azure-cli.speconly specifiespython3(notpython3.6):azure-cli/scripts/release/rpm/azure-cli.spec
Line 13 in 753a11c
azure-cli/scripts/release/rpm/azure-cli.spec
Line 28 in 753a11c
due to the preinstalled Python 3.6 on
centos:centos7,libpython3.6m.so.1.0()(64bit)is added to the RPM package's requirement:Therefore, when installing Azure CLI with
Python 3.6 will be installed.
However, on new Linux distributions like
fedora:34,python3by default points topython3.9.The generated entry script
/usr/bin/azin the RPM package isWhen run on
fedora:34,python3.9is executed withpython3.6-compatiblesofiles, leading to failure.Change
The availability of
python3.6varies on different distributions:fedora:34: allpython3.6,python3.9andpython3(links topython3.9) are availablecentos:centos7: onlypython3(which is 3.6) is availableThis PR dynamically decides which Python to run (
python_cmd) by checking ifpython3.6is available, which is the same version of Python used to build the RPM. Ifpython3.6exists, use it, otherwise usepython3.The entry script
/usr/bin/azbecomesNotes
As Python 3.6 will be deprecated by 2021-12-23 (https://www.python.org/downloads/), we need to bump the build image to newer versions so that the RPM is build with newer versions of Python.