Upgrade python 3.14.0rc1 and install python 3.14-nogil in linux docker images

PiperOrigin-RevId: 789527645
This commit is contained in:
Kanglan Tang
2025-07-31 17:24:19 -07:00
committed by TensorFlower Gardener
parent ffbc76ccd0
commit f459343d24
4 changed files with 9 additions and 37 deletions

View File

@@ -29,6 +29,7 @@ RUN /setup.python.sh python3.11 /builder.requirements.txt
RUN /setup.python.sh python3.13 /builder.requirements.txt
RUN /setup.python.sh python3.13-nogil /builder.requirements.txt
RUN /setup.python.sh python3.14 /builder.requirements.txt
RUN /setup.python.sh python3.14-nogil /builder.requirements.txt
# Since we are using python3.12 as the default python version, we need to
# install python3.12 last for now.

View File

@@ -24,7 +24,7 @@ VERSION=$1
REQUIREMENTS=$2
# Install Python packages for this container's version
if [[ ${VERSION} == "python3.13-nogil" ]]; then
if [[ ${VERSION} == "python3.13-nogil" || ${VERSION} == "python3.14-nogil" ]]; then
cat >pythons.txt <<EOF
$VERSION
EOF
@@ -43,24 +43,7 @@ $VERSION-distutils
EOF
fi
if [[ ${VERSION} == "python3.14" ]]; then
# Build python 3.14.0b1 from source now. This is a temporary solution until
# the apt-get install python3.14 installation is stable to use.
# TODO(kanglan): Remove this once official python 3.14 is available in astral
# python standalone build repo and the rules_python patch is updated.
apt update && apt install -y libssl-dev zlib1g-dev libbz2-dev libreadline-dev libncurses5-dev libffi-dev liblzma-dev
wget https://www.python.org/ftp/python/3.14.0/Python-3.14.0b1.tar.xz
tar -xf Python-3.14.0b1.tar.xz
pushd Python-3.14.0b1
mkdir -p /python314-0b1
CC=clang-18 CXX=clang++-18 ./configure --prefix /python314-0b1 --with-ensurepip=install
make -j$(nproc)
make install -j$(nproc)
ln -s /python314-0b1/bin/python3 /usr/bin/python3.14
popd
else
/setup.packages.sh pythons.txt
fi
/setup.packages.sh pythons.txt
# Re-link pyconfig.h from x86_64-linux-gnu into the devtoolset directory
# for any Python version present
@@ -89,8 +72,8 @@ wget --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 --tries=5
# For Python 3.13t, do not install twine as it does not have pre-built wheels
# for this Python version and building it from source fails. We only need twine
# to be present on the system Python which in this case is 3.12.
# Same reason for Python 3.140a7.
if [[ ${VERSION} == "python3.13-nogil" || ${VERSION} == "python3.14" ]]; then
# Same reason for Python 3.14.
if [[ ${VERSION} == "python3.13-nogil" || ${VERSION} == "python3.14" || ${VERSION} == "python3.14-nogil" ]]; then
grep -v "twine" $REQUIREMENTS > requirements_without_twine.txt
REQUIREMENTS=requirements_without_twine.txt
fi

View File

@@ -67,6 +67,7 @@ RUN /setup.python.sh python3.13 requirements.txt
# python3.13-nogil is a free-threaded build of python3.13.
RUN /setup.python.sh python3.13-nogil requirements.txt
RUN /setup.python.sh python3.14 requirements.txt
RUN /setup.python.sh python3.14-nogil requirements.txt
# Python commands by default run under 3.11
RUN ln -sf /usr/bin/python3.11 /usr/bin/python3

View File

@@ -25,7 +25,7 @@ REQUIREMENTS=$2
add-apt-repository ppa:deadsnakes/ppa
# Install Python packages for this container's version
if [[ ${VERSION} == "python3.13-nogil" ]]; then
if [[ ${VERSION} == "python3.13-nogil" || ${VERSION} == "python3.14-nogil" ]]; then
cat >pythons.txt <<EOF
$VERSION
EOF
@@ -43,20 +43,7 @@ $VERSION-venv
EOF
fi
if [[ ${VERSION} == "python3.14" ]]; then
apt update && apt install -y libssl-dev zlib1g-dev libbz2-dev libreadline-dev libncurses5-dev libffi-dev liblzma-dev
wget https://www.python.org/ftp/python/3.14.0/Python-3.14.0b1.tar.xz
tar -xf Python-3.14.0b1.tar.xz
pushd Python-3.14.0b1
mkdir -p /python314-0b1
CC=clang-18 CXX=clang++-18 ./configure --prefix /python314-0b1 --with-ensurepip=install
make -j$(nproc)
make install -j$(nproc)
ln -s /python314-0b1/bin/python3 /usr/bin/python3.14
popd
else
/setup.packages.sh pythons.txt
fi
/setup.packages.sh pythons.txt
# Re-link pyconfig.h from aarch64-linux-gnu into the devtoolset directory
# for any Python version present
@@ -84,7 +71,7 @@ wget --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 --tries=5
# For Python 3.13t, do not install twine as it does not have pre-built wheels
# for this Python version and building it from source fails. We only need twine
# to be present on the system Python which in this case is 3.12.
if [[ ${VERSION} == "python3.13-nogil" || ${VERSION} == "python3.14" ]]; then
if [[ ${VERSION} == "python3.13-nogil" || ${VERSION} == "python3.14" || ${VERSION} == "python3.14-nogil" ]]; then
grep -v "twine" $REQUIREMENTS > requirements_without_twine.txt
REQUIREMENTS=requirements_without_twine.txt
fi