Skip to content

Commit ca89486

Browse files
Add support for Python 3.12 (#947)
The CI now runs the tests against Python 3.12 as well. The Dockerfile for arm64 was added to the repository to run the tests for python 3.12 in arm64.
2 parents 71a5bbf + 942dcd4 commit ca89486

File tree

5 files changed

+59
-16
lines changed

5 files changed

+59
-16
lines changed

.github/containers/nox-cross-arch/arm64-ubuntu-20.04-python-3.11.Dockerfile renamed to .github/containers/nox-cross-arch/arm64-ubuntu-20.04-python.Dockerfile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55

66
FROM docker.io/library/ubuntu:20.04
77

8+
ARG PYTHON_VERSION="3.11"
9+
810
ENV DEBIAN_FRONTEND=noninteractive
911

10-
# Install Python 3.11 and curl to install pip later
12+
# Install Python and curl to install pip later
1113
RUN apt-get update -y && \
1214
apt-get install --no-install-recommends -y \
1315
software-properties-common && \
@@ -16,16 +18,16 @@ RUN apt-get update -y && \
1618
ca-certificates \
1719
curl \
1820
git \
19-
python3.11 \
20-
python3.11-distutils && \
21+
python${PYTHON_VERSION} \
22+
python${PYTHON_VERSION}-distutils && \
2123
apt-get clean && \
2224
rm -rf /var/lib/apt/lists/*
2325

2426
# Install pip
25-
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11
27+
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python${PYTHON_VERSION}
2628

2729
RUN update-alternatives --install \
28-
/usr/local/bin/python python /usr/bin/python3.11 1 && \
30+
/usr/local/bin/python python /usr/bin/python${PYTHON_VERSION} 1 && \
2931
python -m pip install --upgrade --no-cache-dir pip
3032

3133
COPY entrypoint.bash /usr/bin/entrypoint.bash

.github/containers/test-installation/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
# This Dockerfile is used to test the installation of the python package in
44
# multiple platforms in the CI. It is not used to build the package itself.
55

6-
FROM --platform=${TARGETPLATFORM} python:3.11-slim
6+
ARG PYTHON_VERSION="3.11"
7+
8+
FROM --platform=${TARGETPLATFORM} python:${PYTHON_VERSION}-slim
79

810
RUN apt-get update -y && \
911
apt-get install --no-install-recommends -y \

.github/workflows/ci.yaml

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
- ubuntu-20.04
3434
python:
3535
- "3.11"
36+
- "3.12"
3637
nox-session:
3738
# To speed things up a bit we use the special ci_checks_max session
3839
# that uses the same venv to run multiple linting sessions
@@ -88,10 +89,14 @@ jobs:
8889
# The job name should match the name of the `nox` job.
8990
name: Test with nox
9091
needs: ["nox"]
92+
# We skip this job only if nox was also skipped
93+
if: always() && needs.nox.result != 'skipped'
9194
runs-on: ubuntu-20.04
95+
env:
96+
DEPS_RESULT: ${{ needs.nox.result }}
9297
steps:
93-
- name: Return true
94-
run: "true"
98+
- name: Check matrix job result
99+
run: test "$DEPS_RESULT" = "success"
95100

96101
nox-cross-arch:
97102
name: Cross-arch tests with nox
@@ -109,6 +114,7 @@ jobs:
109114
- ubuntu-20.04
110115
python:
111116
- "3.11"
117+
- "3.12"
112118
nox-session:
113119
- "pytest_min"
114120
- "pytest_max"
@@ -140,8 +146,10 @@ jobs:
140146
uses: docker/build-push-action@v5
141147
with:
142148
context: .github/containers/nox-cross-arch
143-
file: .github/containers/nox-cross-arch/${{ matrix.arch }}-${{ matrix.os }}-python-${{ matrix.python }}.Dockerfile
149+
file: .github/containers/nox-cross-arch/${{ matrix.arch }}-${{ matrix.os }}-python.Dockerfile
144150
platforms: linux/${{ matrix.arch }}
151+
build-args: |
152+
PYTHON_VERSION=${{ matrix.python }}
145153
tags: localhost/nox-cross-arch:latest
146154
push: false
147155
load: true
@@ -200,10 +208,14 @@ jobs:
200208
# The job name should match the name of the `nox-cross-arch` job.
201209
name: Cross-arch tests with nox
202210
needs: ["nox-cross-arch"]
211+
# We skip this job only if nox-cross-arch was also skipped
212+
if: always() && needs.nox-cross-arch.result != 'skipped'
203213
runs-on: ubuntu-20.04
214+
env:
215+
DEPS_RESULT: ${{ needs.nox-cross-arch.result }}
204216
steps:
205-
- name: Return true
206-
run: "true"
217+
- name: Check matrix job result
218+
run: test "$DEPS_RESULT" = "success"
207219

208220
build:
209221
name: Build distribution packages
@@ -239,7 +251,15 @@ jobs:
239251
test-installation:
240252
name: Test package installation in different architectures
241253
needs: ["build"]
242-
runs-on: ubuntu-20.04
254+
strategy:
255+
fail-fast: false
256+
matrix:
257+
os:
258+
- ubuntu-20.04
259+
python:
260+
- "3.11"
261+
- "3.12"
262+
runs-on: ${{ matrix.os }}
243263
steps:
244264
- name: Fetch sources
245265
uses: actions/checkout@v4
@@ -258,9 +278,28 @@ jobs:
258278
context: .
259279
file: .github/containers/test-installation/Dockerfile
260280
platforms: linux/amd64,linux/arm64
281+
build-args: |
282+
PYTHON_VERSION=${{ matrix.python }}
261283
tags: localhost/test-installation
262284
push: false
263285

286+
# This job runs if all the `test-installation` matrix jobs ran and succeeded.
287+
# It is only used to have a single job that we can require in branch
288+
# protection rules, so we don't have to update the protection rules each time
289+
# we add or remove a job from the matrix.
290+
test-installation-all:
291+
# The job name should match the name of the `test-installation` job.
292+
name: Test package installation in different architectures
293+
needs: ["test-installation"]
294+
# We skip this job only if test-installation was also skipped
295+
if: always() && needs.test-installation.result != 'skipped'
296+
runs-on: ubuntu-20.04
297+
env:
298+
DEPS_RESULT: ${{ needs.test-installation.result }}
299+
steps:
300+
- name: Check matrix job result
301+
run: test "$DEPS_RESULT" = "success"
302+
264303
test-docs:
265304
name: Test documentation website generation
266305
if: github.event_name != 'push'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ A development kit to interact with the Frequenz development platform.
1212

1313
The following platforms are officially supported (test):
1414

15-
- **Python:** 3.11
15+
- **Python:** 3.11, 3.12
1616
- **Operating System:** Ubuntu Linux 20.04
1717
- **Architectures:** amd64, arm64
1818

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ dependencies = [
3333
"frequenz-channels >= 1.0.0-rc1, < 2.0.0",
3434
"frequenz-client-microgrid >= 0.3.0, < 0.4.0",
3535
"google-api-python-client >= 2.71, < 3",
36-
"grpcio >= 1.54.2, < 2",
37-
"grpcio-tools >= 1.54.2, < 2",
36+
"grpcio >= 1.60.1, < 2",
37+
"grpcio-tools >= 1.60.1, < 2",
3838
"networkx >= 2.8, < 4",
39-
"numpy >= 1.24.2, < 2",
39+
"numpy >= 1.26.4, < 2",
4040
"protobuf >= 4.21.6, < 6",
4141
"pydantic >= 2.3, < 3",
4242
"timezonefinder >= 6.2.0, < 7",

0 commit comments

Comments
 (0)