Skip to content

Commit c45ba0a

Browse files
dirraopotiuk
authored andcommitted
Add Python 3.12 support
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.
1 parent ec30c60 commit c45ba0a

106 files changed

Lines changed: 1049 additions & 797 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.

Dockerfile

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

13721372
# By changing the epoch we can force reinstalling Airflow and pip all dependencies
13731373
# It can also be overwritten manually by setting the AIRFLOW_CI_BUILD_EPOCH environment variable.
1374-
ARG AIRFLOW_CI_BUILD_EPOCH="10"
1374+
ARG AIRFLOW_CI_BUILD_EPOCH="11"
13751375
ENV AIRFLOW_CI_BUILD_EPOCH=${AIRFLOW_CI_BUILD_EPOCH}
13761376

13771377
# In case of Production build image segment we want to pre-install main version of airflow

Dockerfile.ci

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,17 @@ function check_download_pendulum() {
954954
pip check
955955
}
956956

957+
function uninstall_cassandra_for_python_3_12() {
958+
if [[ ${PYTHON_MAJOR_MINOR_VERSION} != "3.12" ]]; then
959+
return
960+
fi
961+
echo
962+
echo "${COLOR_BLUE}Uninstalling cassandra in case it was installed via cache${COLOR_RESET}"
963+
echo
964+
pip uninstall --root-user-action ignore -y "cassandra-driver" || true
965+
pip check
966+
}
967+
957968
function check_run_tests() {
958969
if [[ ${RUN_TESTS=} != "true" ]]; then
959970
return
@@ -985,6 +996,7 @@ check_boto_upgrade
985996
check_pydantic
986997
check_download_sqlalchemy
987998
check_download_pendulum
999+
uninstall_cassandra_for_python_3_12
9881000
check_run_tests "${@}"
9891001

9901002
exec /bin/bash "${@}"
@@ -1012,7 +1024,7 @@ ARG PYTHON_BASE_IMAGE
10121024
ARG AIRFLOW_IMAGE_REPOSITORY="https://github.com/apache/airflow"
10131025

10141026
# By increasing this number we can do force build of all dependencies
1015-
ARG DEPENDENCIES_EPOCH_NUMBER="10"
1027+
ARG DEPENDENCIES_EPOCH_NUMBER="11"
10161028

10171029
# Make sure noninteractive debian install is used and language variables set
10181030
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.1) |
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: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,18 @@
3939
# configuration is therefore initted early here, simply by importing it.
4040
from airflow import configuration, settings
4141

42-
__all__ = ["__version__", "DAG", "PY36", "PY37", "PY38", "PY39", "PY310", "PY311", "XComArg"]
42+
__all__ = [
43+
"__version__",
44+
"DAG",
45+
"PY36",
46+
"PY37",
47+
"PY38",
48+
"PY39",
49+
"PY310",
50+
"PY311",
51+
"PY312",
52+
"XComArg",
53+
]
4354

4455
# Make `airflow` a namespace package, supporting installing
4556
# airflow.providers.* in different locations (i.e. one in site, and one in user
@@ -61,6 +72,7 @@
6172
PY39 = sys.version_info >= (3, 9)
6273
PY310 = sys.version_info >= (3, 10)
6374
PY311 = sys.version_info >= (3, 11)
75+
PY312 = sys.version_info >= (3, 12)
6476

6577
# Things to lazy import in form {local_name: ('target_module', 'target_name', 'deprecated')}
6678
__lazy_imports: dict[str, tuple[str, str, bool]] = {

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
@@ -819,7 +819,7 @@ the older branches, you should set the "skip" field to true.
819819
## Verify production images
820820
821821
```shell script
822-
for PYTHON in 3.8 3.9 3.10 3.11
822+
for PYTHON in 3.8 3.9 3.10 3.11 3.12
823823
do
824824
docker pull apache/airflow:${VERSION}-python${PYTHON}
825825
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: 9fb8d5c48b1bb2376ac01daf20896fe6a4d7d187cae6db7f629ac65c62e540f7be1dd3c4af17f9b871dc1b163304da38640494267b0b37da278a574ba3274783
7070

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

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

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

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

dev/breeze/doc/images/output-commands.svg

Lines changed: 1 addition & 1 deletion
Loading

0 commit comments

Comments
 (0)