Skip to content

Commit 63ff22f

Browse files
authored
Drop python3.8 support core and providers (apache#42766)
* Drop Python 3.8 support in core Add newsfragment * Drop Python 3.8 support in provider packages
1 parent 000d2da commit 63ff22f

File tree

193 files changed

+998
-1215
lines changed

Some content is hidden

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

193 files changed

+998
-1215
lines changed

.github/actions/breeze/action.yml

-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ description: 'Sets up Python and Breeze'
2121
inputs:
2222
python-version:
2323
description: 'Python version to use'
24-
# Version of Python used for reproducibility of the packages built
25-
# Python 3.8 tarfile produces different tarballs than Python 3.9+ tarfile that's why we are forcing
26-
# Python 3.9 for all release preparation commands to make sure that the tarballs are reproducible
2724
default: "3.9"
2825
outputs:
2926
host-python-version:

.github/workflows/build-images.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# under the License.
1717
#
1818
---
19-
name: "Build Images"
19+
name: Build Images
2020
run-name: >
2121
Build images for ${{ github.event.pull_request.title }} ${{ github.event.pull_request._links.html.href }}
2222
on: # yamllint disable-line rule:truthy
@@ -54,7 +54,7 @@ concurrency:
5454
jobs:
5555
build-info:
5656
timeout-minutes: 10
57-
name: "Build Info"
57+
name: Build Info
5858
# At build-info stage we do not yet have outputs so we need to hard-code the runs-on to public runners
5959
runs-on: ["ubuntu-22.04"]
6060
env:
@@ -89,7 +89,7 @@ jobs:
8989
}}"
9090
if: github.repository == 'apache/airflow'
9191
steps:
92-
- name: "Cleanup repo"
92+
- name: Cleanup repo
9393
shell: bash
9494
run: docker run -v "${GITHUB_WORKSPACE}:/workspace" -u 0:0 bash -c "rm -rf /workspace/*"
9595
- name: Discover PR merge commit
@@ -154,13 +154,13 @@ jobs:
154154
# COMPOSITE ACTIONS. WE CAN RUN ANYTHING THAT IS IN THE TARGET BRANCH AND THERE IS NO RISK THAT
155155
# CODE WILL BE RUN FROM THE PR.
156156
####################################################################################################
157-
- name: "Cleanup docker"
157+
- name: Cleanup docker
158158
run: ./scripts/ci/cleanup_docker.sh
159-
- name: "Setup python"
159+
- name: Setup python
160160
uses: actions/setup-python@v5
161161
with:
162-
python-version: 3.8
163-
- name: "Install Breeze"
162+
python-version: "3.9"
163+
- name: Install Breeze
164164
uses: ./.github/actions/breeze
165165
####################################################################################################
166166
# WE RUN SELECTIVE CHECKS HERE USING THE TARGET COMMIT AND ITS PARENT TO BE ABLE TO COMPARE THEM
@@ -212,7 +212,7 @@ jobs:
212212
docker-cache: ${{ needs.build-info.outputs.docker-cache }}
213213

214214
generate-constraints:
215-
name: "Generate constraints"
215+
name: Generate constraints
216216
needs: [build-info, build-ci-images]
217217
uses: ./.github/workflows/generate-constraints.yml
218218
with:
@@ -247,7 +247,7 @@ jobs:
247247
push-image: "true"
248248
use-uv: "true"
249249
image-tag: ${{ needs.build-info.outputs.image-tag }}
250-
platform: "linux/amd64"
250+
platform: linux/amd64
251251
python-versions: ${{ needs.build-info.outputs.python-versions }}
252252
default-python-version: ${{ needs.build-info.outputs.default-python-version }}
253253
branch: ${{ needs.build-info.outputs.default-branch }}

.github/workflows/check-providers.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,9 @@ jobs:
108108
run: >
109109
breeze release-management generate-issue-content-providers
110110
--only-available-in-dist --disable-progress
111-
- name: >
112-
Remove incompatible Python ${{ matrix.python-version }} provider packages
111+
- name: Remove Python 3.9-incompatible provider packages
113112
run: |
114-
echo "Removing Python 3.8-incompatible provider: cloudant"
113+
echo "Removing Python 3.9-incompatible provider: cloudant"
115114
rm -vf dist/apache_airflow_providers_cloudant*
116115
- name: "Generate source constraints from CI image"
117116
shell: bash

.pre-commit-config.yaml

-7
Original file line numberDiff line numberDiff line change
@@ -1066,13 +1066,6 @@ repos:
10661066
files: \.py$
10671067
exclude: ^.*/.*_vendor/
10681068
additional_dependencies: ['rich>=12.4.4']
1069-
- id: check-compat-cache-on-methods
1070-
name: Check that compat cache do not use on class methods
1071-
entry: ./scripts/ci/pre_commit/compat_cache_on_methods.py
1072-
language: python
1073-
pass_filenames: true
1074-
files: ^airflow/.*\.py$
1075-
exclude: ^.*/.*_vendor/
10761069
- id: check-code-deprecations
10771070
name: Check deprecations categories in decorators
10781071
entry: ./scripts/ci/pre_commit/check_deprecations.py

.readthedocs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ formats: []
2020
sphinx:
2121
configuration: docs/rtd-deprecation/conf.py
2222
python:
23-
version: "3.8"
23+
version: "3.9"
2424
install:
2525
- method: pip
2626
path: .

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ ARG AIRFLOW_USER_HOME_DIR=/home/airflow
4747
# latest released version here
4848
ARG AIRFLOW_VERSION="2.10.2"
4949

50-
ARG PYTHON_BASE_IMAGE="python:3.8-slim-bookworm"
50+
ARG PYTHON_BASE_IMAGE="python:3.9-slim-bookworm"
5151

5252
ARG AIRFLOW_PIP_VERSION=24.2
5353
ARG AIRFLOW_UV_VERSION=0.4.17

Dockerfile.ci

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#
1717
# WARNING: THIS DOCKERFILE IS NOT INTENDED FOR PRODUCTION USE OR DEPLOYMENT.
1818
#
19-
ARG PYTHON_BASE_IMAGE="python:3.8-slim-bookworm"
19+
ARG PYTHON_BASE_IMAGE="python:3.9-slim-bookworm"
2020

2121
##############################################################################################
2222
# This is the script image where we keep all inlined bash scripts needed in other segments
@@ -810,7 +810,7 @@ chmod 1777 /tmp
810810

811811
AIRFLOW_SOURCES=$(cd "${IN_CONTAINER_DIR}/../.." || exit 1; pwd)
812812

813-
PYTHON_MAJOR_MINOR_VERSION=${PYTHON_MAJOR_MINOR_VERSION:=3.8}
813+
PYTHON_MAJOR_MINOR_VERSION=${PYTHON_MAJOR_MINOR_VERSION:=3.9}
814814

815815
export AIRFLOW_HOME=${AIRFLOW_HOME:=${HOME}}
816816

INSTALL

+5-7
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,7 @@ This is what it shows currently:
141141
┏━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
142142
┃ Name ┃ Type ┃ Description ┃
143143
┡━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
144-
│ default │ virtual │ Default environment with Python 3.8 for maximum compatibility │
145-
├─────────────┼─────────┼───────────────────────────────────────────────────────────────┤
146-
│ airflow-38 │ virtual │ Environment with Python 3.8. No devel installed. │
144+
│ default │ virtual │ Default environment with Python 3.9 for maximum compatibility │
147145
├─────────────┼─────────┼───────────────────────────────────────────────────────────────┤
148146
│ airflow-39 │ virtual │ Environment with Python 3.9. No devel installed. │
149147
├─────────────┼─────────┼───────────────────────────────────────────────────────────────┤
@@ -154,7 +152,7 @@ This is what it shows currently:
154152
│ airflow-312 │ virtual │ Environment with Python 3.12. No devel installed │
155153
└─────────────┴─────────┴───────────────────────────────────────────────────────────────┘
156154

157-
The default env (if you have not used one explicitly) is `default` and it is a Python 3.8
155+
The default env (if you have not used one explicitly) is `default` and it is a Python 3.9
158156
virtualenv for maximum compatibility with `devel` extra installed - this devel extra contains the minimum set
159157
of dependencies and tools that should be used during unit testing of core Airflow and running all `airflow`
160158
CLI commands - without support for providers or databases.
@@ -228,15 +226,15 @@ to avoid "works-for-me" syndrome, where you use different versions of dependenci
228226
that are used in main CI tests and by other contributors.
229227

230228
There are different constraint files for different Python versions. For example, this command will install
231-
all basic devel requirements and requirements of Google provider as last successfully tested for Python 3.8:
229+
all basic devel requirements and requirements of Google provider as last successfully tested for Python 3.9:
232230

233231
pip install -e ".[devel,google]"" \
234-
--constraint "https://raw.githubusercontent.com/apache/airflow/constraints-main/constraints-3.8.txt"
232+
--constraint "https://raw.githubusercontent.com/apache/airflow/constraints-main/constraints-3.9.txt"
235233

236234
Using the 'constraints-no-providers' constraint files, you can upgrade Airflow without paying attention to the provider's dependencies. This allows you to keep installed provider dependencies and install the latest supported ones using pure Airflow core.
237235

238236
pip install -e ".[devel]" \
239-
--constraint "https://raw.githubusercontent.com/apache/airflow/constraints-main/constraints-no-providers-3.8.txt"
237+
--constraint "https://raw.githubusercontent.com/apache/airflow/constraints-main/constraints-no-providers-3.9.txt"
240238

241239
Airflow extras
242240
==============

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Apache Airflow is tested with:
9999

100100
| | Main version (dev) | Stable version (2.10.2) |
101101
|------------|----------------------------|----------------------------|
102-
| Python | 3.8, 3.9, 3.10, 3.11, 3.12 | 3.8, 3.9, 3.10, 3.11, 3.12 |
102+
| Python | 3.9, 3.10, 3.11, 3.12 | 3.8, 3.9, 3.10, 3.11, 3.12 |
103103
| Platform | AMD64/ARM64(\*) | AMD64/ARM64(\*) |
104104
| Kubernetes | 1.28, 1.29, 1.30, 1.31 | 1.27, 1.28, 1.29, 1.30 |
105105
| PostgreSQL | 12, 13, 14, 15, 16, 17 | 12, 13, 14, 15, 16 |
@@ -178,14 +178,14 @@ them to the appropriate format and workflow that your tool requires.
178178

179179
```bash
180180
pip install 'apache-airflow==2.10.2' \
181-
--constraint "https://raw.githubusercontent.com/apache/airflow/constraints-2.10.2/constraints-3.8.txt"
181+
--constraint "https://raw.githubusercontent.com/apache/airflow/constraints-2.10.2/constraints-3.9.txt"
182182
```
183183

184184
2. Installing with extras (i.e., postgres, google)
185185

186186
```bash
187187
pip install 'apache-airflow[postgres,google]==2.10.2' \
188-
--constraint "https://raw.githubusercontent.com/apache/airflow/constraints-2.10.2/constraints-3.8.txt"
188+
--constraint "https://raw.githubusercontent.com/apache/airflow/constraints-2.10.2/constraints-3.9.txt"
189189
```
190190

191191
For information on installing provider packages, check
@@ -313,7 +313,7 @@ They are based on the official release schedule of Python and Kubernetes, nicely
313313
1. We drop support for Python and Kubernetes versions when they reach EOL. Except for Kubernetes, a
314314
version stays supported by Airflow if two major cloud providers still provide support for it. We drop
315315
support for those EOL versions in main right after EOL date, and it is effectively removed when we release
316-
the first new MINOR (Or MAJOR if there is no new MINOR version) of Airflow. For example, for Python 3.8 it
316+
the first new MINOR (Or MAJOR if there is no new MINOR version) of Airflow. For example, for Python 3.9 it
317317
means that we will drop support in main right after 27.06.2023, and the first MAJOR or MINOR version of
318318
Airflow released after will not have it.
319319

airflow/cli/commands/connection_command.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import json
2222
import os
2323
import warnings
24+
from functools import cache
2425
from pathlib import Path
2526
from typing import Any
2627
from urllib.parse import urlsplit, urlunsplit
@@ -30,7 +31,6 @@
3031

3132
from airflow.cli.simple_table import AirflowConsole
3233
from airflow.cli.utils import is_stdout, print_export_output
33-
from airflow.compat.functools import cache
3434
from airflow.configuration import conf
3535
from airflow.exceptions import AirflowNotFoundException
3636
from airflow.hooks.base import BaseHook

airflow/compat/functools.py

-33
This file was deleted.

airflow/configuration.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1790,9 +1790,7 @@ def load_providers_configuration(self):
17901790
)
17911791
self._default_values = create_default_config_parser(self.configuration_description)
17921792
# sensitive_config_values needs to be refreshed here. This is a cached_property, so we can delete
1793-
# the cached values, and it will be refreshed on next access. This has been an implementation
1794-
# detail in Python 3.8 but as of Python 3.9 it is documented behaviour.
1795-
# See https://docs.python.org/3/library/functools.html#functools.cached_property
1793+
# the cached values, and it will be refreshed on next access.
17961794
try:
17971795
del self.sensitive_config_values
17981796
except AttributeError:

airflow/io/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import inspect
2020
import logging
21+
from functools import cache
2122
from typing import (
2223
TYPE_CHECKING,
2324
Callable,
@@ -26,7 +27,6 @@
2627

2728
from fsspec.implementations.local import LocalFileSystem
2829

29-
from airflow.compat.functools import cache
3030
from airflow.providers_manager import ProvidersManager
3131
from airflow.stats import Stats
3232
from airflow.utils.module_loading import import_string

airflow/models/taskinstance.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from contextlib import nullcontext
3232
from datetime import timedelta
3333
from enum import Enum
34+
from functools import cache
3435
from typing import TYPE_CHECKING, Any, Callable, Collection, Generator, Iterable, Mapping, Tuple
3536
from urllib.parse import quote
3637

@@ -69,7 +70,6 @@
6970
from airflow.api_internal.internal_api_call import InternalApiConfig, internal_api_call
7071
from airflow.assets import Asset, AssetAlias
7172
from airflow.assets.manager import asset_manager
72-
from airflow.compat.functools import cache
7373
from airflow.configuration import conf
7474
from airflow.exceptions import (
7575
AirflowException,

airflow/operators/python.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
import warnings
3131
from abc import ABCMeta, abstractmethod
3232
from collections.abc import Container
33+
from functools import cache
3334
from pathlib import Path
3435
from tempfile import TemporaryDirectory
3536
from typing import TYPE_CHECKING, Any, Callable, Collection, Iterable, Mapping, NamedTuple, Sequence
3637

3738
import lazy_object_proxy
3839

39-
from airflow.compat.functools import cache
4040
from airflow.exceptions import (
4141
AirflowConfigException,
4242
AirflowException,

airflow/providers/MANAGING_PROVIDERS_LIFECYCLE.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ If you have pre-commit installed, pre-commit will be run automatically on commit
454454
manually after commit, you can run it via ``breeze static-checks --last-commit`` some of the tests might fail
455455
because suspension of the provider might cause changes in the dependencies, so if you see errors about
456456
missing dependencies imports, non-usable classes etc., you will need to build the CI image locally
457-
via ``breeze build-image --python 3.8 --upgrade-to-newer-dependencies`` after the first pre-commit run
457+
via ``breeze build-image --python 3.9 --upgrade-to-newer-dependencies`` after the first pre-commit run
458458
and then run the static checks again.
459459

460460
If you want to be absolutely sure to run all static checks you can always do this via

airflow/providers/amazon/aws/transfers/sql_to_s3.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,9 @@ def _partition_dataframe(self, df: pd.DataFrame) -> Iterable[tuple[str, pd.DataF
223223
for group_label in (grouped_df := df.groupby(**self.groupby_kwargs)).groups:
224224
yield (
225225
cast(str, group_label),
226-
cast(
227-
"pd.DataFrame",
228-
grouped_df.get_group(group_label)
229-
.drop(random_column_name, axis=1, errors="ignore")
230-
.reset_index(drop=True),
231-
),
226+
grouped_df.get_group(group_label)
227+
.drop(random_column_name, axis=1, errors="ignore")
228+
.reset_index(drop=True),
232229
)
233230

234231
def _get_hook(self) -> DbApiHook:

airflow/providers/amazon/aws/utils/mixins.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@
2727

2828
from __future__ import annotations
2929

30-
from functools import cached_property
30+
from functools import cache, cached_property
3131
from typing import Any, Generic, NamedTuple, TypeVar
3232

3333
from typing_extensions import final
3434

35-
from airflow.compat.functools import cache
3635
from airflow.providers.amazon.aws.hooks.base_aws import AwsGenericHook
3736

3837
AwsHookType = TypeVar("AwsHookType", bound=AwsGenericHook)

airflow/providers/cloudant/provider.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@ dependencies:
5151

5252
excluded-python-versions:
5353
# ibmcloudant transitively brings in urllib3 2.x, but the snowflake provider has a dependency that pins
54-
# urllib3 to 1.x on Python 3.8 and 3.9; thus we exclude those Python versions from taking the update
54+
# urllib3 to 1.x on Python 3.9; thus we exclude those Python versions from taking the update
5555
# to ibmcloudant.
5656
# See #21004, #41555, and https://github.com/snowflakedb/snowflake-connector-python/issues/2016
57-
- "3.8"
5857
- "3.9"
5958

6059
integrations:

airflow/providers/cncf/kubernetes/kubernetes_helper_functions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
import logging
2020
import secrets
2121
import string
22+
from functools import cache
2223
from typing import TYPE_CHECKING
2324

2425
import pendulum
2526
from deprecated import deprecated
2627
from kubernetes.client.rest import ApiException
2728
from slugify import slugify
2829

29-
from airflow.compat.functools import cache
3030
from airflow.configuration import conf
3131
from airflow.exceptions import AirflowProviderDeprecationWarning
3232

0 commit comments

Comments
 (0)