Skip to content

Commit 69cffd9

Browse files
Kyle-Nealealopezziliakur
authored
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>
1 parent fcfc8f1 commit 69cffd9

602 files changed

Lines changed: 696 additions & 459 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
@@ -53,11 +53,11 @@ RUN yum install -y perl-IPC-Cmd && \
5353
ldconfig
5454

5555
# Compile and install Python 3
56-
ENV PYTHON3_VERSION=3.11.8
56+
ENV PYTHON3_VERSION=3.12.6
5757
RUN yum install -y libffi-devel && \
5858
DOWNLOAD_URL="https://python.org/ftp/python/{{version}}/Python-{{version}}.tgz" \
5959
VERSION="${PYTHON3_VERSION}" \
60-
SHA256="d3019a613b9e8761d260d9ebe3bd4df63976de30464e5c0189566e1ae3f61889" \
60+
SHA256="85a4c1be906d20e5c5a69f2466b00da769c221d6a684acfd3a514dbf5bf10a66" \
6161
RELATIVE_PATH="Python-{{version}}" \
6262
bash install-from-source.sh \
6363
--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
@@ -51,11 +51,11 @@ RUN yum install -y perl-IPC-Cmd && \
5151
ldconfig
5252

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

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

.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:

.github/workflows/build-deps.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ defaults:
2929

3030
env:
3131
PYTHONUNBUFFERED: "1"
32-
PYTHON_VERSION: "3.11"
32+
PYTHON_VERSION: "3.12"
3333
DIRECT_DEPENDENCY_FILE: agent_requirements.in
3434
# https://reproducible-builds.org/specs/source-date-epoch/
3535
SOURCE_DATE_EPOCH: "1580601600"
@@ -109,7 +109,7 @@ jobs:
109109
if: matrix.job.image == 'linux-aarch64'
110110
run: |
111111
mkdir -p ~/miniconda3
112-
wget https://repo.anaconda.com/miniconda/Miniconda3-py311_24.1.2-0-Linux-aarch64.sh -O ~/miniconda3/miniconda.sh
112+
wget https://repo.anaconda.com/miniconda/Miniconda3-py312_24.5.0-0-Linux-aarch64.sh -O ~/miniconda3/miniconda.sh
113113
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
114114
rm -rf ~/miniconda3/miniconda.sh
115115
~/miniconda3/bin/conda init bash
@@ -201,7 +201,7 @@ jobs:
201201
env:
202202
TARGET_NAME: macos-x86_64
203203
OUT_DIR: output/macos-x86_64
204-
DD_PYTHON3: "/Library/Frameworks/Python.framework/Versions/3.11/bin/python"
204+
DD_PYTHON3: "/Library/Frameworks/Python.framework/Versions/3.12/bin/python"
205205

206206
steps:
207207
- name: Set up environment
@@ -214,7 +214,7 @@ jobs:
214214
- name: Set up Python
215215
env:
216216
# Despite the name, this is built for the macOS 11 SDK on arm64 and 10.9+ on intel
217-
PYTHON3_DOWNLOAD_URL: "https://www.python.org/ftp/python/3.11.5/python-3.11.5-macos11.pkg"
217+
PYTHON3_DOWNLOAD_URL: "https://www.python.org/ftp/python/3.12.6/python-3.12.6-macos11.pkg"
218218
run: |-
219219
curl "$PYTHON3_DOWNLOAD_URL" -o python3.pkg
220220
sudo installer -pkg python3.pkg -target /

0 commit comments

Comments
 (0)