Skip to content

Commit 76dee0b

Browse files
potiukdirrao
andauthored
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]>
1 parent 6ac50c9 commit 76dee0b

File tree

114 files changed

+1106
-834
lines changed

Some content is hidden

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

114 files changed

+1106
-834
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2298,13 +2298,15 @@ jobs:
22982298
- name: >
22992299
Build CI ARM images ${{ needs.build-info.outputs.image-tag }}
23002300
${{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"
2301+
run: |
2302+
# Do not run parallel builds here as they often fail due to github token expiry issues similar to
2303+
# those described in https://github.com/moby/buildkit/issues/2367
2304+
for python in ${{needs.build-info.outputs.python-versions-list-as-string}}; do
2305+
breeze ci-image build --builder airflow_cache --platform "linux/arm64" --python ${python}
2306+
done
23032307
env:
23042308
UPGRADE_TO_NEWER_DEPENDENCIES: ${{ needs.build-info.outputs.upgrade-to-newer-dependencies }}
23052309
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}}
23082310
COMMIT_SHA: ${{ github.sha }}
23092311
- name: "Stop ARM instance"
23102312
run: ./scripts/ci/images/ci_stop_arm_instance.sh

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

airflow/providers/apache/cassandra/hooks/cassandra.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,22 @@
1919
from __future__ import annotations
2020

2121
import re
22+
import sys
2223
from typing import Any, Union
2324

25+
import cassandra
2426
from cassandra.auth import PlainTextAuthProvider
25-
from cassandra.cluster import Cluster, Session
27+
28+
from airflow.exceptions import AirflowOptionalProviderFeatureException
29+
30+
try:
31+
from cassandra.cluster import Cluster, Session
32+
except cassandra.DependencyException:
33+
if sys.version_info >= (3, 12):
34+
raise AirflowOptionalProviderFeatureException(
35+
"You need to have cassandra driver compiled with libev to get it working."
36+
)
37+
raise
2638
from cassandra.policies import (
2739
DCAwareRoundRobinPolicy,
2840
RoundRobinPolicy,

airflow/providers/apache/cassandra/provider.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,26 @@ dependencies:
4646
- apache-airflow>=2.6.0
4747
- cassandra-driver>=3.13.0
4848

49+
# Cassandra provider is not yet compatible with Python 3.12
50+
# The main issue is that python cassandra driver by default uses asyncore which has been deprecated since
51+
# Python 3.6 and removed in Python 3.12 (https://docs.python.org/3.11/library/asyncore.html)
52+
#
53+
# Currently the "wheel" package 3.29.0 distributed for manylinux platform is build without libev support (
54+
# which could be a viable asyncore replacement), and cassandra driver works in Python 3.12 if it is built
55+
# with libev support (using sdist, having gcc, libev4 and libev-dev installed). But it would be too much to
56+
# expect our users to build the driver from sources to use it with Python 3.12, so we are waiting for the
57+
# next release of cassandra-driver which will have libev support in the wheel package.
58+
# The issue is tracked here https://datastax-oss.atlassian.net/browse/PYTHON-1378
59+
#
60+
# Another option to get cassandra drive back is to have asyncio support in the driver instead of asyncore:
61+
# The issue is tracked here: https://datastax-oss.atlassian.net/browse/PYTHON-1375 and is scheduled
62+
# to be fixed in cassandra-driver 3.30.0.
63+
#
64+
# All Cassandra tests are automatically skipped if cassandra package is not present, so once you remove the
65+
# exclusion, they will start running for Python 3.12.
66+
#
67+
excluded-python-versions: ['3.12']
68+
4969
integrations:
5070
- integration-name: Apache Cassandra
5171
external-doc-url: https://cassandra.apache.org/

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

0 commit comments

Comments
 (0)