Skip to content

Commit 4796d58

Browse files
Kyle-Nealealopezz
andauthored
[Backport 7.58.x] Bump Python 3 to 3.12 (#18212) (#18706)
* Bump Python 3 to 3.12 (#18212) * bump py version to 3.12 * update dbm dev container * update builders and build deps * fix python string * Build lxml dependencies for linux x64 (#18467) * fix rmq version * fix gunicorn tests * Fix lock file generation * comment out if clause to force dep resolution * bump python to 3.12.6 * fix python on Windows sha * remove DD_PYTHON2 unbound variable * fix hatch errors * remove setup.py files * fix CI * revert datadog_checks_test_helper --------- Co-authored-by: Alex Lopez <alex.lopez.zorzano@gmail.com> Co-authored-by: Ilia Kurenkov <ilia.kurenkov@datadoghq.com> Co-authored-by: Alex Lopez <alex.lopez@datadoghq.com> (cherry picked from commit 69cffd9) * fix build-deps.yaml * Fix dependency build for macOS (#18581) * Add workflow file to cache key on macos job * Remove reference to DD_PYTHON2 which is no longer set * Trigger the build in master when the workflow file changes * remove changelog entries --------- Co-authored-by: Alex Lopez <alex.lopez.zorzano@gmail.com>
1 parent 57f418f commit 4796d58

414 files changed

Lines changed: 695 additions & 611 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.builders/images/linux-aarch64/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ RUN yum install -y perl-IPC-Cmd perl-CPANPLUS && \
5454
ldconfig
5555

5656
# Compile and install Python 3
57-
ENV PYTHON3_VERSION=3.11.8
57+
ENV PYTHON3_VERSION=3.12.6
5858
RUN yum install -y libffi-devel && \
5959
DOWNLOAD_URL="https://python.org/ftp/python/{{version}}/Python-{{version}}.tgz" \
6060
VERSION="${PYTHON3_VERSION}" \
61-
SHA256="d3019a613b9e8761d260d9ebe3bd4df63976de30464e5c0189566e1ae3f61889" \
61+
SHA256="85a4c1be906d20e5c5a69f2466b00da769c221d6a684acfd3a514dbf5bf10a66" \
6262
RELATIVE_PATH="Python-{{version}}" \
6363
bash install-from-source.sh \
6464
--prefix=/opt/python/${PYTHON_VERSION} \

.builders/images/linux-x86_64/Dockerfile

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ RUN yum install -y perl-IPC-Cmd perl-CPANPLUS && \
5252
ldconfig
5353

5454
# Compile and install Python 3
55-
ENV PYTHON3_VERSION=3.11.8
55+
ENV PYTHON3_VERSION=3.12.6
5656
RUN yum install -y libffi-devel && \
5757
DOWNLOAD_URL="https://python.org/ftp/python/{{version}}/Python-{{version}}.tgz" \
5858
VERSION="${PYTHON3_VERSION}" \
59-
SHA256="d3019a613b9e8761d260d9ebe3bd4df63976de30464e5c0189566e1ae3f61889" \
59+
SHA256="85a4c1be906d20e5c5a69f2466b00da769c221d6a684acfd3a514dbf5bf10a66" \
6060
RELATIVE_PATH="Python-{{version}}" \
6161
bash install-from-source.sh --prefix=/opt/python/${PYTHON_VERSION} --with-ensurepip=yes --enable-ipv6 --with-dbmliborder=
6262
ENV PATH="/opt/python/${PYTHON_VERSION}/bin:${PATH}"
@@ -82,6 +82,36 @@ RUN \
8282
RELATIVE_PATH="krb5-{{version}}/src" \
8383
bash install-from-source.sh --without-keyutils --without-system-verto --without-libedit --disable-static
8484

85+
# libxml & libxslt for lxml
86+
RUN \
87+
DOWNLOAD_URL="https://download.gnome.org/sources/libxml2/2.12/libxml2-{{version}}.tar.xz" \
88+
VERSION="2.12.6" \
89+
SHA256="889c593a881a3db5fdd96cc9318c87df34eb648edfc458272ad46fd607353fbb" \
90+
RELATIVE_PATH="libxml2-{{version}}" \
91+
bash install-from-source.sh \
92+
--without-iconv \
93+
--without-python \
94+
--without-icu \
95+
--without-debug \
96+
--without-mem-debug \
97+
--without-run-debug \
98+
--without-legacy \
99+
--without-catalog \
100+
--without-docbook \
101+
--disable-static
102+
103+
RUN \
104+
DOWNLOAD_URL="https://download.gnome.org/sources/libxslt/1.1/libxslt-{{version}}.tar.xz" \
105+
VERSION="1.1.39" \
106+
SHA256="2a20ad621148339b0759c4d4e96719362dee64c9a096dbba625ba053846349f0" \
107+
RELATIVE_PATH="libxslt-{{version}}" \
108+
bash install-from-source.sh \
109+
--without-python \
110+
--without-crypto \
111+
--without-profiler \
112+
--without-debugger \
113+
--disable-static
114+
85115
# libpq and pg_config as needed by psycopg2
86116
RUN \
87117
DOWNLOAD_URL="https://ftp.postgresql.org/pub/source/v{{version}}/postgresql-{{version}}.tar.bz2" \

.builders/images/macos-x86_64/builder_setup.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ set -euxo pipefail
66
"${DD_PYTHON3}" -m pip install --no-warn-script-location virtualenv
77
"${DD_PYTHON3}" -m virtualenv py3
88

9-
"${DD_PYTHON2}" -m pip install --no-warn-script-location --upgrade pip
10-
"${DD_PYTHON2}" -m pip install --no-warn-script-location virtualenv
11-
"${DD_PYTHON2}" -m virtualenv py2
12-
139
# Install always with our own prefix path
1410
mkdir -p "${DD_PREFIX_PATH}"
1511
cp "${DD_MOUNT_DIR}/build_context/install-from-source.sh" .

.builders/images/windows-x86_64/Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,17 @@ RUN Get-RemoteFile `
7373
Approve-File -Path $($Env:USERPROFILE + '\.cargo\bin\rustc.exe') -Hash $Env:RUSTC_HASH
7474

7575
# Install Python 3
76-
ENV PYTHON_VERSION="3.11.7"
76+
ENV PYTHON_VERSION="3.12.6"
7777
RUN Get-RemoteFile `
7878
-Uri https://www.python.org/ftp/python/$Env:PYTHON_VERSION/python-$Env:PYTHON_VERSION-amd64.exe `
7979
-Path python-$Env:PYTHON_VERSION-amd64.exe `
80-
-Hash 'c117c6444494bbe4cc937e8a5a61899d53f7f5c5bc573c5d130304e457d54024'; `
80+
-Hash '5914748e6580e70bedeb7c537a0832b3071de9e09a2e4e7e3d28060616045e0a'; `
8181
Start-Process -Wait python-$Env:PYTHON_VERSION-amd64.exe -ArgumentList '/quiet', 'InstallAllUsers=1'; `
8282
Remove-Item python-$Env:PYTHON_VERSION-amd64.exe; `
83-
& 'C:\Program Files\Python311\python.exe' -m pip install --no-warn-script-location --upgrade pip; `
84-
& 'C:\Program Files\Python311\python.exe' -m pip install --no-warn-script-location virtualenv; `
85-
& 'C:\Program Files\Python311\python.exe' -m virtualenv 'C:\py3'; `
86-
Add-ToPath -Append 'C:\Program Files\Python311'
83+
& 'C:\Program Files\Python312\python.exe' -m pip install --no-warn-script-location --upgrade pip; `
84+
& 'C:\Program Files\Python312\python.exe' -m pip install --no-warn-script-location virtualenv; `
85+
& 'C:\Program Files\Python312\python.exe' -m virtualenv 'C:\py3'; `
86+
Add-ToPath -Append 'C:\Program Files\Python312'
8787

8888
# Install Python 2
8989
ENV PYTHON_VERSION="2.7.18"

.builders/lock.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ def default_python_version() -> str:
3636
return match.group(1)
3737

3838

39+
@cache
40+
def target_python_for_major(python_major: str):
41+
return '2.7' if python_major == '2' else default_python_version()
42+
43+
3944
def is_compatible_wheel(
4045
target_name: str,
4146
target_python_major: str,
@@ -44,7 +49,7 @@ def is_compatible_wheel(
4449
platform: str,
4550
) -> bool:
4651
if interpreter.startswith('cp'):
47-
target_python = '2.7' if target_python_major == '2' else default_python_version()
52+
target_python = target_python_for_major(target_python_major)
4853
expected_tag = f'cp{target_python_major}' if abi == 'abi3' else f'cp{target_python}'.replace('.', '')
4954
if expected_tag not in interpreter:
5055
return False
@@ -59,8 +64,17 @@ def is_compatible_wheel(
5964
return True
6065

6166

62-
def generate_lock_file(requirements_file: Path, lock_file: Path) -> None:
63-
target, _, python_version = lock_file.stem.rpartition('_')
67+
def generate_lock_file(
68+
requirements_file: Path,
69+
lock_file_folder: Path,
70+
target: str,
71+
python_version: str,
72+
) -> None:
73+
python_target = target_python_for_major(python_version)
74+
# The lockfiles contain the major.minor Python version
75+
# so that the Agent can transition safely
76+
lock_file = lock_file_folder / f'{target}_{python_target}.txt'
77+
6478
python_major = python_version[-1]
6579

6680
dependencies: dict[str, str] = {}
@@ -135,7 +149,10 @@ def main():
135149
for python_version in target.iterdir():
136150
if python_version.name.startswith('py'):
137151
generate_lock_file(
138-
python_version / 'frozen.txt', LOCK_FILE_DIR / f'{target.name}_{python_version.name}.txt'
152+
python_version / 'frozen.txt',
153+
LOCK_FILE_DIR,
154+
target.name,
155+
python_version.name.strip('py'),
139156
)
140157

141158
if (image_digest_file := target / 'image_digest').is_file():

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This dockerfile is used to build the devcontainer environment.
22
# more info about vscode devcontainer: https://code.visualstudio.com/docs/devcontainers/containers
3-
FROM mcr.microsoft.com/devcontainers/python:1-3.11-bullseye
3+
FROM mcr.microsoft.com/devcontainers/python:1-3.12-bullseye
44
RUN apt update && DEBIAN_FRONTEND=noninteractive apt install -y liblz4-dev libunwind-dev ca-certificates curl gnupg
55
# Docker and docker-compose installation
66
RUN install -m 0755 -d /etc/apt/keyrings

.devcontainer/dbm/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This dockerfile is used to build the devcontainer environment.
22
# more info about vscode devcontainer: https://code.visualstudio.com/docs/devcontainers/containers
3-
FROM mcr.microsoft.com/devcontainers/python:1-3.11-bullseye
3+
FROM mcr.microsoft.com/devcontainers/python:1-3.12-bullseye
44
RUN apt update && DEBIAN_FRONTEND=noninteractive apt install -y liblz4-dev libunwind-dev ca-certificates curl gnupg
55
# Docker and docker-compose installation
66
RUN install -m 0755 -d /etc/apt/keyrings

.devcontainer/dbm/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"privileged": true,
99
"features": {
1010
"ghcr.io/devcontainers/features/python:1": {
11-
"version": "3.11"
11+
"version": "3.12"
1212
}
1313
},
1414
"customizations": {

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// When updating it, modify both the base Dockerfile and the devcontainer.json reference.
1717
// Ref: https://github.com/devcontainers/features/blob/562305d37b97d47331d96306ffc2a0a3cce55e64/src/python/install.sh#L10
1818
"ghcr.io/devcontainers/features/python:1": {
19-
"version": "3.11"
19+
"version": "3.12"
2020
}
2121
},
2222

.github/workflows/build-ddev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ defaults:
2424

2525
env:
2626
APP_NAME: ddev
27-
PYTHON_VERSION: "3.11"
27+
PYTHON_VERSION: "3.12"
2828
PYOXIDIZER_VERSION: "0.24.0"
2929

3030
jobs:

0 commit comments

Comments
 (0)