Skip to content

Conversation

@bebound
Copy link
Contributor

@bebound bebound commented Apr 14, 2025

Description
Close #30505

This PR bumps the Python dependency to 3.12. Some extensions may need to be reinstalled if they become non-functional: az extension remove -n xxx && az extension add -n xxx

After this PR, Mariner 2.0 is the only one relies on Python 3.9, the rest of the distros use 3.12.

@azure-client-tools-bot-prd
Copy link

azure-client-tools-bot-prd bot commented Apr 14, 2025

️✔️AzureCLI-FullTest
️✔️acr
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️acs
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.9
️✔️ams
️✔️latest
️✔️3.12
️✔️3.9
️✔️apim
️✔️latest
️✔️3.12
️✔️3.9
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.9
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.9
️✔️aro
️✔️latest
️✔️3.12
️✔️3.9
️✔️backup
️✔️latest
️✔️3.12
️✔️3.9
️✔️batch
️✔️latest
️✔️3.12
️✔️3.9
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.9
️✔️billing
️✔️latest
️✔️3.12
️✔️3.9
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.9
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.9
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.9
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.9
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.9
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.9
️✔️config
️✔️latest
️✔️3.12
️✔️3.9
️✔️configure
️✔️latest
️✔️3.12
️✔️3.9
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.9
️✔️container
️✔️latest
️✔️3.12
️✔️3.9
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.9
️✔️core
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.9
️✔️databoxedge
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️dls
️✔️latest
️✔️3.12
️✔️3.9
️✔️dms
️✔️latest
️✔️3.12
️✔️3.9
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.9
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.9
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.9
️✔️find
️✔️latest
️✔️3.12
️✔️3.9
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.9
️✔️identity
️✔️latest
️✔️3.12
️✔️3.9
️✔️iot
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️keyvault
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️lab
️✔️latest
️✔️3.12
️✔️3.9
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.9
️✔️maps
️✔️latest
️✔️3.12
️✔️3.9
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.9
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.9
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.9
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.9
️✔️network
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.9
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.9
️✔️profile
️✔️latest
️✔️3.12
️✔️3.9
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.9
️✔️redis
️✔️latest
️✔️3.12
️✔️3.9
️✔️relay
️✔️latest
️✔️3.12
️✔️3.9
️✔️resource
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️role
️✔️latest
️✔️3.12
️✔️3.9
️✔️search
️✔️latest
️✔️3.12
️✔️3.9
️✔️security
️✔️latest
️✔️3.12
️✔️3.9
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.9
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.9
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.9
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.9
️✔️sql
️✔️latest
️✔️3.12
️✔️3.9
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.9
️✔️storage
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.9
️✔️telemetry
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️util
️✔️latest
️✔️3.12
️✔️3.9
️✔️vm
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9

@azure-client-tools-bot-prd
Copy link

Hi @bebound,
Since the current milestone time is less than 7 days, this pr will be reviewed in the next milestone.

@azure-client-tools-bot-prd
Copy link

azure-client-tools-bot-prd bot commented Apr 14, 2025

️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

@yonzhan
Copy link
Collaborator

yonzhan commented Apr 14, 2025

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>


# Fix up %{buildroot} appearing in some files...
for d in %{buildroot}%{cli_lib_dir}/bin/*; do perl -p -i -e "s#%{buildroot}##g" $d; done;
rm %{buildroot}%{cli_lib_dir}/pyvenv.cfg
Copy link
Contributor Author

@bebound bebound Apr 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/root/rpmbuild/BUILDROOT/azure-cli-2.71.0-1.el9.x86_64/usr/lib64/az/pyvenv.cfg content is

home = /usr/bin
include-system-site-packages = false
version = 3.12.5
executable = /usr/bin/python3.12
command = /usr/bin/python3.12 -m venv /root/rpmbuild/BUILDROOT/azure-cli-2.71.0-1.el9.x86_64/usr/lib64/az

It raises this error during build.

#10 83.39 RPM build errors:
#10 83.39 error: Bad exit status from /var/tmp/rpm-tmp.ZBlRUB (%install)
#10 83.39     Bad exit status from /var/tmp/rpm-tmp.ZBlRUB (%install)
#10 ERROR: process "/bin/sh -c export PIP_INDEX_URL=$(cat /run/secrets/PIP_INDEX_URL) &&     dos2unix ./scripts/release/rpm/azure-cli.spec &&     REPO_PATH=$(pwd) CLI_VERSION=$cli_version PYTHON_PACKAGE=$python_package PYTHON_CMD=$python_package     rpmbuild -v -bb --clean scripts/release/rpm/azure-cli.spec &&     cp /root/rpmbuild/RPMS/*/azure-cli-${cli_version}-1.*.rpm /azure-cli-dev.rpm &&     mkdir /out && cp /root/rpmbuild/RPMS/*/azure-cli-${cli_version}-1.*.rpm /out/" did not complete successfully: exit code: 1
------
 > [build-env 6/6] RUN --mount=type=secret,id=PIP_INDEX_URL export PIP_INDEX_URL=$(cat /run/secrets/PIP_INDEX_URL) &&     dos2unix ./scripts/release/rpm/azure-cli.spec &&     REPO_PATH=$(pwd) CLI_VERSION=2.71.0 PYTHON_PACKAGE=python3.12 PYTHON_CMD=python3.12     rpmbuild -v -bb --clean scripts/release/rpm/azure-cli.spec &&     cp /root/rpmbuild/RPMS/*/azure-cli-2.71.0-1.*.rpm /azure-cli-dev.rpm &&     mkdir /out && cp /root/rpmbuild/RPMS/*/azure-cli-2.71.0-1.*.rpm /out/:
82.82 + mkdir -p /root/rpmbuild/BUILDROOT/azure-cli-2.71.0-1.el8.x86_64/etc/bash_completion.d/
82.82 + cat /azure-cli/az.completion
82.82 + /usr/lib/rpm/check-buildroot
83.38 /root/rpmbuild/BUILDROOT/azure-cli-2.71.0-1.el8.x86_64/usr/lib64/az/pyvenv.cfg:command = /usr/bin/python3.12 -m venv /root/rpmbuild/BUILDROOT/azure-cli-2.71.0-1.el8.x86_64/usr/lib64/az
83.38 Found '/root/rpmbuild/BUILDROOT/azure-cli-2.71.0-1.el8.x86_64' in installed files; aborting
83.39 
83.39 
83.39 RPM build errors:
83.39 error: Bad exit status from /var/tmp/rpm-tmp.ZBlRUB (%install)
83.39     Bad exit status from /var/tmp/rpm-tmp.ZBlRUB (%install)

In 3.9, pyvenv.cfg does not include rpmbuild root:

home = /usr/bin
include-system-site-packages = false
version = 3.9.20

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/usr/lib/rpm/check-buildroot wants to make sure the RPM build path /root/rpmbuild/BUILDROOT/azure-cli-2.71.0-1.el9.x86_64 does not exist in any of the installed file, but pyvenv.cfg contains command = /usr/bin/python3.12 -m venv /root/rpmbuild/BUILDROOT/azure-cli-2.71.0-1.el9.x86_64/usr/lib64/az which makes /usr/lib/rpm/check-buildroot fail.

  1. Will deleting pyvenv.cfg cause any side effect?
  2. Can we use sed or perl (L60) to only remove command = /usr/bin/python3.12 -m venv /root/rpmbuild/BUILDROOT/azure-cli-2.71.0-1.el9.x86_64/usr/lib64/az?

Copy link
Contributor Author

@bebound bebound Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pyvenv.cfg contains some metadata of the venv. We only need the site-pacakges folder in the venv.
This is the RPM entry script:

AZ_INSTALLER=RPM PYTHONPATH=\"\$bin_dir/../lib64/az/lib/${python_version}/site-packages\" \$python_cmd -sm azure.cli \"\$@\"

I thinks it's fine to remove it. As a proof, we have explicitly excluded the bin folder created by venv:

%exclude %{cli_lib_dir}/bin/

PS: Although {cli_lib_dir}/bin/ is excluded in RPM, it still checks whether this path contains hard-coded buildroot during the build. Line 60 is still necessary.

dnf --nogpgcheck install /mnt/rpm/$RPM_NAME -y

dnf install git gcc $PYTHON_PACKAGE-devel findutils -y
dnf install git gcc $PYTHON_PACKAGE-devel findutils $PYTHON_PACKAGE-pip -y
Copy link
Contributor Author

@bebound bebound Apr 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python3.12-devel installs python3.12-pip-wheel, which is only a pip wheel used in venv and does not install pip module in python3.12.

I need to install python3.12-pip explicitly as it's used in line 18

PS: In 3.9, python39-devel installs python39-pip.

Ref: https://centos.pkgs.org/9-stream/centos-appstream-aarch64/python3.12-pip-wheel-23.2.1-4.el9.noarch.rpm.html

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the content of https://mirror.stream.centos.org/9-stream/AppStream/aarch64/os/Packages/python3.12-pip-wheel-23.2.1-4.el9.noarch.rpm and it contains python3.12-pip-wheel-23.2.1-4.el9.noarch.cpio\.\usr\share\python3.12-wheels\pip-23.2.1-py3-none-any.whl.

https://docs.redhat.com/de/documentation/red_hat_enterprise_linux/9/html-single/installing_and_using_dynamic_programming_languages/index#proc_installing-additional-python-3-packages_assembly_installing-and-using-python contains instruction for installing python3.12-pip:

dnf install python3.12-pip

Actually I am wondering if we really need python3.12-devel at all:

https://centos.pkgs.org/9-stream/centos-appstream-aarch64/python3.12-devel-3.12.9-1.el9.aarch64.rpm.html

This package contains the header files and configuration needed to compile
Python extension modules (typically written in C or C++), to embed Python
into other programs, and to make binary distributions for Python libraries.
It also contains the necessary macros to build RPM packages with Python modules
and 2to3 tool, an automatic source converter from Python 2.X.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gcc and python3-devel is introduced in #14806.
It seems fine to remove them.

@bebound bebound marked this pull request as ready for review April 23, 2025 03:20
RUN --mount=type=secret,id=PIP_INDEX_URL export PIP_INDEX_URL=$(cat /run/secrets/PIP_INDEX_URL) && \
dos2unix ./scripts/release/rpm/azure-cli.spec && \
REPO_PATH=$(pwd) CLI_VERSION=$cli_version PYTHON_PACKAGE=$python_package PYTHON_CMD=python3.9 \
REPO_PATH=$(pwd) CLI_VERSION=$cli_version PYTHON_PACKAGE=$python_package PYTHON_CMD=$python_package \
Copy link
Contributor Author

@bebound bebound Apr 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In RHEL8, the PYTHON_PACKAGE is python39, PYTHON_CMD is python3.9.
In RHEL9, both are unified as python3.9. Ref: https://github.com/Azure/azure-cli/pull/23556/files#r952101959

In python3.12, both distros use python3.12.

I'm unsure if these values will differ in the future; keep these variables for now.

@bebound bebound changed the title [Packaging] Bump Python to 3.12 on RHEL and CentOS [Packaging] Bump Python to 3.12 on RHEL and CentOS Stream Apr 24, 2025
@bebound bebound merged commit 1840bc3 into Azure:dev Apr 24, 2025
104 checks passed
@Klaas-
Copy link

Klaas- commented May 19, 2025

Hi, I don't think you can do this if you actually want to support all rhel8 versions that are currently supported by Red Hat.
#31509

@bebound bebound deleted the bump-3.12 branch July 15, 2025 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Auto-Assign Auto assign by bot Packaging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change python for rhel8 packaging

4 participants