Skip to content

Commit b9bcd5a

Browse files
potiukdirrao
andcommitted
Add Python 3.12 support (#36755)
Finally after a number of dependency upgrades we seem to be able to upgrade to Python 3.12 (pending universal_pathlib 0.2.0 conversion) Several providers are excluded from being installed and wait for Python 3.12, but it should not block Airlfow's general 3.12 support. Co-authored-by: dirrao <[email protected]> (cherry picked from commit 76dee0b)
1 parent c0b849a commit b9bcd5a

File tree

119 files changed

+1342
-942
lines changed

Some content is hidden

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

119 files changed

+1342
-942
lines changed

.github/workflows/ci.yml

Lines changed: 59 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ jobs:
129129
is-arm-runner: ${{ steps.selective-checks.outputs.is-arm-runner }}
130130
is-vm-runner: ${{ steps.selective-checks.outputs.is-vm-runner }}
131131
is-k8s-runner: ${{ steps.selective-checks.outputs.is-k8s-runner }}
132+
latest-versions-only: ${{ steps.selective-checks.outputs.latest-versions-only }}
132133
chicken-egg-providers: ${{ steps.selective-checks.outputs.chicken-egg-providers }}
133134
has-migrations: ${{ steps.selective-checks.outputs.has-migrations }}
134135
source-head-repo: ${{ steps.source-run-info.outputs.source-head-repo }}
@@ -208,22 +209,22 @@ jobs:
208209
matrix.platform == 'linux/arm64' && needs.build-info.outputs.canary-run == 'true'
209210
&& needs.build-info.outputs.default-branch == 'main'
210211
- name: "Push CI cache ${{ matrix.platform }}"
211-
run: >
212-
breeze ci-image build
213-
--builder airflow_cache
214-
--prepare-buildx-cache
215-
--run-in-parallel
216-
--platform ${{ matrix.platform }}
212+
run: |
213+
for PYTHON in ${{needs.build-info.outputs.python-versions-list-as-string}}; do
214+
breeze ci-image build --builder airflow_cache --prepare-buildx-cache \
215+
--python ${PYTHON} --platform ${{ matrix.platform }}
216+
done
217217
env:
218-
DEBUG_RESOURCES: ${{needs.build-info.outputs.debug-resources}}
219218
COMMIT_SHA: ${{ github.sha }}
219+
PYTHON_VERSIONS: ${{needs.build-info.outputs.all-python-versions-list-as-string}}
220220
if: needs.build-info.outputs.canary-run == 'true' && needs.build-info.outputs.default-branch == 'main'
221221
- name: "Push CI latest image ${{ matrix.platform }}"
222-
run: >
223-
breeze ci-image build
224-
--tag-as-latest --push --run-in-parallel --platform ${{ matrix.platform }}
222+
run: |
223+
for PYTHON in ${{needs.build-info.outputs.python-versions-list-as-string}}; do
224+
breeze ci-image build --tag-as-latest --push --run-in-parallel \
225+
--python ${PYTHON} --platform ${{ matrix.platform }}
226+
done
225227
env:
226-
DEBUG_RESOURCES: ${{needs.build-info.outputs.debug-resources}}
227228
COMMIT_SHA: ${{ github.sha }}
228229
# We only push "amd" image as it is really only needed for any kind of automated builds in CI
229230
# and currently there is not an easy way to make multi-platform image from two separate builds
@@ -252,6 +253,8 @@ jobs:
252253
RUNS_ON: "${{needs.build-info.outputs.runs-on}}"
253254
UPGRADE_TO_NEWER_DEPENDENCIES: false
254255
PLATFORM: "linux/amd64"
256+
PYTHON_MAJOR_MINOR_VERSION: "${{needs.build-info.outputs.default-python-version}}"
257+
PYTHON_VERSION: ${{needs.build-info.outputs.default-python-version}}
255258
if: >
256259
needs.build-info.outputs.canary-run == 'true'
257260
&& needs.build-info.outputs.default-branch == 'main'
@@ -267,6 +270,7 @@ jobs:
267270
- name: "Check that image builds quickly"
268271
run: breeze shell --max-time 120
269272

273+
270274
build-ci-images:
271275
strategy:
272276
fail-fast: true
@@ -566,7 +570,9 @@ jobs:
566570
RUNS_ON: "${{needs.build-info.outputs.runs-on}}"
567571
PYTHON_MAJOR_MINOR_VERSION: "${{needs.build-info.outputs.default-python-version}}"
568572
UPGRADE_TO_NEWER_DEPENDENCIES: "${{ needs.build-info.outputs.upgrade-to-newer-dependencies }}"
569-
if: needs.build-info.outputs.basic-checks-only == 'false'
573+
if: >
574+
needs.build-info.outputs.basic-checks-only == 'false' &&
575+
needs.build-info.outputs.latest-versions-only != 'true'
570576
steps:
571577
- name: Cleanup repo
572578
run: docker run -v "${GITHUB_WORKSPACE}:/workspace" -u 0:0 bash -c "rm -rf /workspace/*"
@@ -604,7 +610,9 @@ jobs:
604610
env:
605611
RUNS_ON: "${{needs.build-info.outputs.runs-on}}"
606612
PYTHON_MAJOR_MINOR_VERSION: "${{needs.build-info.outputs.default-python-version}}"
607-
if: needs.build-info.outputs.canary-run == 'true'
613+
if: >
614+
needs.build-info.outputs.canary-run == 'true' &&
615+
needs.build-info.outputs.latest-versions-only != 'true'
608616
steps:
609617
- name: Cleanup repo
610618
run: docker run -v "${GITHUB_WORKSPACE}:/workspace" -u 0:0 bash -c "rm -rf /workspace/*"
@@ -666,6 +674,7 @@ jobs:
666674
RUNS_ON: "${{needs.build-info.outputs.runs-on}}"
667675
PYTHON_MAJOR_MINOR_VERSION: "${{needs.build-info.outputs.default-python-version}}"
668676
UPGRADE_TO_NEWER_DEPENDENCIES: "${{ needs.build-info.outputs.upgrade-to-newer-dependencies }}"
677+
if: needs.build-info.outputs.latest-versions-only != 'true'
669678
steps:
670679
- name: Cleanup repo
671680
run: docker run -v "${GITHUB_WORKSPACE}:/workspace" -u 0:0 bash -c "rm -rf /workspace/*"
@@ -760,7 +769,9 @@ jobs:
760769
name: "Build docs"
761770
runs-on: ${{fromJSON(needs.build-info.outputs.runs-on)}}
762771
needs: [build-info, wait-for-ci-images]
763-
if: needs.build-info.outputs.docs-build == 'true'
772+
if: >
773+
needs.build-info.outputs.docs-build == 'true' &&
774+
needs.build-info.outputs.latest-versions-only != 'true'
764775
env:
765776
RUNS_ON: "${{needs.build-info.outputs.runs-on}}"
766777
PYTHON_MAJOR_MINOR_VERSION: "${{needs.build-info.outputs.default-python-version}}"
@@ -824,7 +835,9 @@ jobs:
824835
name: "Spellcheck docs"
825836
runs-on: ${{fromJSON(needs.build-info.outputs.runs-on)}}
826837
needs: [build-info, wait-for-ci-images]
827-
if: needs.build-info.outputs.docs-build == 'true'
838+
if: >
839+
needs.build-info.outputs.docs-build == 'true' &&
840+
needs.build-info.outputs.latest-versions-only != 'true'
828841
env:
829842
RUNS_ON: "${{needs.build-info.outputs.runs-on}}"
830843
PYTHON_MAJOR_MINOR_VERSION: "${{needs.build-info.outputs.default-python-version}}"
@@ -858,7 +871,9 @@ jobs:
858871
env:
859872
RUNS_ON: "${{needs.build-info.outputs.runs-on}}"
860873
PYTHON_MAJOR_MINOR_VERSION: "${{needs.build-info.outputs.default-python-version}}"
861-
if: needs.build-info.outputs.skip-provider-tests != 'true'
874+
if: >
875+
needs.build-info.outputs.skip-provider-tests != 'true' &&
876+
needs.build-info.outputs.latest-versions-only != 'true'
862877
steps:
863878
- name: Cleanup repo
864879
run: docker run -v "${GITHUB_WORKSPACE}:/workspace" -u 0:0 bash -c "rm -rf /workspace/*"
@@ -1085,7 +1100,9 @@ jobs:
10851100
JOB_ID: "helm-tests"
10861101
USE_XDIST: "true"
10871102
if: >
1088-
needs.build-info.outputs.needs-helm-tests == 'true' && needs.build-info.outputs.default-branch == 'main'
1103+
needs.build-info.outputs.needs-helm-tests == 'true' &&
1104+
needs.build-info.outputs.default-branch == 'main' &&
1105+
needs.build-info.outputs.latest-versions-only != 'true'
10891106
steps:
10901107
- name: Cleanup repo
10911108
run: docker run -v "${GITHUB_WORKSPACE}:/workspace" -u 0:0 bash -c "rm -rf /workspace/*"
@@ -1385,7 +1402,9 @@ jobs:
13851402
JOB_ID: >
13861403
pendulum-2-${{needs.build-info.outputs.default-python-version}}-
13871404
${{needs.build-info.outputs.default-postgres-version}}
1388-
if: needs.build-info.outputs.run-tests == 'true'
1405+
if: >
1406+
needs.build-info.outputs.run-tests == 'true' &&
1407+
needs.build-info.outputs.latest-versions-only != 'true'
13891408
steps:
13901409
- name: Cleanup repo
13911410
shell: bash
@@ -1796,7 +1815,9 @@ jobs:
17961815
JOB_ID: "no-db-pendulum-2-${{needs.build-info.outputs.default-python-version}}"
17971816
ENABLE_COVERAGE: "${{needs.build-info.outputs.run-coverage}}"
17981817
DOWNGRADE_PENDULUM: "true"
1799-
if: needs.build-info.outputs.run-tests == 'true'
1818+
if: >
1819+
needs.build-info.outputs.run-tests == 'true' &&
1820+
needs.build-info.outputs.latest-versions-only != 'true'
18001821
steps:
18011822
- name: Cleanup repo
18021823
shell: bash
@@ -2210,19 +2231,19 @@ jobs:
22102231
run: ./scripts/ci/images/ci_start_arm_instance_and_connect_to_docker.sh
22112232
if: matrix.platform == 'linux/arm64'
22122233
- name: "Push CI cache ${{ matrix.platform }}"
2213-
run: >
2214-
breeze ci-image build
2215-
--builder airflow_cache
2216-
--prepare-buildx-cache
2217-
--run-in-parallel
2218-
--platform ${{ matrix.platform }}
2234+
run: |
2235+
for PYTHON in ${{needs.build-info.outputs.python-versions-list-as-string}}; do
2236+
breeze ci-image build --builder airflow_cache --prepare-buildx-cache \
2237+
--python ${PYTHON} --platform ${{ matrix.platform }}
2238+
done
22192239
env:
2220-
DEBUG_RESOURCES: ${{needs.build-info.outputs.debug-resources}}
22212240
COMMIT_SHA: ${{ github.sha }}
22222241
- name: "Push CI latest image ${{ matrix.platform }}"
2223-
run: >
2224-
breeze ci-image build
2225-
--tag-as-latest --push --run-in-parallel --platform ${{ matrix.platform }}
2242+
run: |
2243+
for PYTHON in ${{needs.build-info.outputs.python-versions-list-as-string}}; do
2244+
breeze ci-image build --tag-as-latest --push \
2245+
--python ${PYTHON} --platform ${{ matrix.platform }}
2246+
done
22262247
env:
22272248
DEBUG_RESOURCES: ${{needs.build-info.outputs.debug-resources}}
22282249
COMMIT_SHA: ${{ github.sha }}
@@ -2231,8 +2252,6 @@ jobs:
22312252
run: cp -v --no-preserve=mode,ownership ./dist/*.whl ./docker-context-files
22322253
- name: "Push PROD cache ${{ matrix.python-version }} ${{ matrix.platform }}"
22332254
run: |
2234-
# Do not run parallel builds here as they often fail due to github token expiry issues similar to
2235-
# those described in https://github.com/moby/buildkit/issues/2367
22362255
for python in ${{needs.build-info.outputs.python-versions-list-as-string}}; do
22372256
breeze prod-image build --builder airflow_cache --install-packages-from-context \
22382257
--airflow-constraints-mode constraints-source-providers --prepare-buildx-cache \
@@ -2241,9 +2260,11 @@ jobs:
22412260
env:
22422261
COMMIT_SHA: ${{ github.sha }}
22432262
- name: "Push PROD latest image ${{ matrix.platform }}"
2244-
run: >
2245-
breeze prod-image build --tag-as-latest --install-packages-from-context
2246-
--push --run-in-parallel --platform ${{ matrix.platform }}
2263+
run: |
2264+
for python in ${{needs.build-info.outputs.python-versions-list-as-string}}; do
2265+
breeze prod-image build --tag-as-latest --install-packages-from-context \
2266+
--push --run-in-parallel --python ${PYTHON} --platform ${{ matrix.platform }}
2267+
done
22472268
env:
22482269
DEBUG_RESOURCES: ${{needs.build-info.outputs.debug-resources}}
22492270
COMMIT_SHA: ${{ github.sha }}
@@ -2298,13 +2319,13 @@ jobs:
22982319
- name: >
22992320
Build CI ARM images ${{ needs.build-info.outputs.image-tag }}
23002321
${{needs.build-info.outputs.all-python-versions-list-as-string}}:${{env.IMAGE_TAG}}
2301-
run: >
2302-
breeze ci-image build --run-in-parallel --builder airflow_cache --platform "linux/arm64"
2322+
run: |
2323+
for python in ${{needs.build-info.outputs.python-versions-list-as-string}}; do
2324+
breeze ci-image build --builder airflow_cache --platform "linux/arm64" --python ${python}
2325+
done
23032326
env:
23042327
UPGRADE_TO_NEWER_DEPENDENCIES: ${{ needs.build-info.outputs.upgrade-to-newer-dependencies }}
23052328
DOCKER_CACHE: ${{ needs.build-info.outputs.cache-directive }}
2306-
PYTHON_VERSIONS: ${{needs.build-info.outputs.all-python-versions-list-as-string}}
2307-
DEBUG_RESOURCES: ${{needs.build-info.outputs.debug-resources}}
23082329
COMMIT_SHA: ${{ github.sha }}
23092330
- name: "Stop ARM instance"
23102331
run: ./scripts/ci/images/ci_stop_arm_instance.sh

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ repos:
704704
name: Verify usage of Airflow deprecation classes in core
705705
entry: category=DeprecationWarning|category=PendingDeprecationWarning
706706
files: \.py$
707-
exclude: ^airflow/configuration\.py$|^airflow/providers|^scripts/in_container/verify_providers\.py$
707+
exclude: ^airflow/configuration\.py$|^airflow/providers|^scripts/in_container/verify_providers\.py$|^tests/.*$
708708
pass_filenames: true
709709
- id: check-provide-create-sessions-imports
710710
language: pygrep

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,7 @@ ARG USE_CONSTRAINTS_FOR_CONTEXT_PACKAGES="false"
15281528

15291529
# By changing the epoch we can force reinstalling Airflow and pip all dependencies
15301530
# It can also be overwritten manually by setting the AIRFLOW_CI_BUILD_EPOCH environment variable.
1531-
ARG AIRFLOW_CI_BUILD_EPOCH="10"
1531+
ARG AIRFLOW_CI_BUILD_EPOCH="11"
15321532
ENV AIRFLOW_CI_BUILD_EPOCH=${AIRFLOW_CI_BUILD_EPOCH}
15331533

15341534

Dockerfile.ci

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ ARG PYTHON_BASE_IMAGE
11081108
ARG AIRFLOW_IMAGE_REPOSITORY="https://github.com/apache/airflow"
11091109

11101110
# By increasing this number we can do force build of all dependencies
1111-
ARG DEPENDENCIES_EPOCH_NUMBER="10"
1111+
ARG DEPENDENCIES_EPOCH_NUMBER="11"
11121112

11131113
# Make sure noninteractive debian install is used and language variables set
11141114
ENV PYTHON_BASE_IMAGE=${PYTHON_BASE_IMAGE} \

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Apache Airflow is tested with:
100100

101101
| | Main version (dev) | Stable version (2.8.2) |
102102
|-------------|------------------------------|------------------------|
103-
| Python | 3.8, 3.9, 3.10, 3.11 | 3.8, 3.9, 3.10, 3.11 |
103+
| Python | 3.8, 3.9, 3.10, 3.11, 3.12 | 3.8, 3.9, 3.10, 3.11 |
104104
| Platform | AMD64/ARM64(\*) | AMD64/ARM64(\*) |
105105
| Kubernetes | 1.25, 1.26, 1.27, 1.28, 1.29 | 1.25, 1.26, 1.27, 1.28 |
106106
| PostgreSQL | 12, 13, 14, 15, 16 | 12, 13, 14, 15, 16 |

airflow/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@
3939
# configuration is therefore initted early here, simply by importing it.
4040
from airflow import configuration, settings
4141

42-
__all__ = ["__version__", "DAG", "Dataset", "XComArg"]
42+
__all__ = [
43+
"__version__",
44+
"DAG",
45+
"Dataset",
46+
"XComArg",
47+
]
4348

4449
# Make `airflow` a namespace package, supporting installing
4550
# airflow.providers.* in different locations (i.e. one in site, and one in user

contributing-docs/07_local_virtualenv.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Required Software Packages
3737
Use system-level package managers like yum, apt-get for Linux, or
3838
Homebrew for macOS to install required software packages:
3939

40-
* Python (One of: 3.8, 3.9, 3.10, 3.11)
40+
* Python (One of: 3.8, 3.9, 3.10, 3.11, 3.12)
4141
* MySQL 5.7+
4242
* libxml
4343
* helm (only for helm chart tests)
@@ -186,6 +186,8 @@ This is what it shows currently:
186186
+-------------+---------+----------+---------------------------------------------------------------+
187187
| airflow-311 | virtual | devel | Environment with Python 3.11 |
188188
+-------------+---------+----------+---------------------------------------------------------------+
189+
| airflow-312 | virtual | devel | Environment with Python 3.12 |
190+
+-------------+---------+----------+---------------------------------------------------------------+
189191

190192
The default env (if you have not used one explicitly) is ``default`` and it is a Python 3.8
191193
virtualenv for maximum compatibility with ``devel`` extra installed - this devel extra contains the minimum set

dev/README_RELEASE_AIRFLOW.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ the older branches, you should set the "skip" field to true.
822822
## Verify production images
823823
824824
```shell script
825-
for PYTHON in 3.8 3.9 3.10 3.11
825+
for PYTHON in 3.8 3.9 3.10 3.11 3.12
826826
do
827827
docker pull apache/airflow:${VERSION}-python${PYTHON}
828828
breeze prod-image verify --image-name apache/airflow:${VERSION}-python${PYTHON}

dev/breeze/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ PLEASE DO NOT MODIFY THE HASH BELOW! IT IS AUTOMATICALLY UPDATED BY PRE-COMMIT.
6666

6767
---------------------------------------------------------------------------------------------------------
6868

69-
Package config hash: e2db123fd25e40b515520fb9f6ed32a601fe85e6a22b9845343bc5c81e5785b472527ed3bf6d07521c512d2222f99877a1ce1911ac504a3a6af7b7866aa674cc
69+
Package config hash: 0c6255210f3c20a29aa24405412399cf3f6ff897658f13a0fb7628b4888d6bfe99f49bdb2aa68d9045e14179d4be33a02543c12e394395931024522431bf5dec
7070

7171
---------------------------------------------------------------------------------------------------------

dev/breeze/doc/ci/02_images.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ percent-encoded when you access them via UI (/ = %2F)
574574

575575
- \<BRANCH\> might be either "main" or "v2-\*-test"
576576
- \<X.Y\> - Python version (Major + Minor).Should be one of \["3.8",
577-
"3.9", "3.10", "3.11"\].
577+
"3.9", "3.10", "3.11", "3.12" \].
578578
- \<COMMIT_SHA\> - full-length SHA of commit either from the tip of the
579579
branch (for pushes/schedule) or commit from the tip of the branch used
580580
for the PR.

0 commit comments

Comments
 (0)