diff --git a/dev/breeze/src/airflow_breeze/commands/release_management_commands.py b/dev/breeze/src/airflow_breeze/commands/release_management_commands.py index cad99a3b27129..6ad403667790d 100644 --- a/dev/breeze/src/airflow_breeze/commands/release_management_commands.py +++ b/dev/breeze/src/airflow_breeze/commands/release_management_commands.py @@ -98,6 +98,7 @@ DEFAULT_PYTHON_MAJOR_MINOR_VERSION, DESTINATION_LOCATIONS, MULTI_PLATFORM, + PYTHON_TO_MIN_AIRFLOW_MAPPING, UV_VERSION, ) from airflow_breeze.params.shell_params import ShellParams @@ -2756,6 +2757,21 @@ def generate_issue_content_core( ) +def is_airflow_version_supported_for_python(airflow_version: str, python_version: str) -> bool: + from packaging.version import Version + + min_airflow_version = PYTHON_TO_MIN_AIRFLOW_MAPPING.get(python_version) + if not min_airflow_version: + return False + return Version(airflow_version) >= Version(min_airflow_version) + + +def get_airflow_versions_supported_by_python( + all_airflow_versions: list[str], python_version: str +) -> list[str]: + return [v for v in all_airflow_versions if is_airflow_version_supported_for_python(v, python_version)] + + def get_all_constraint_files( refresh_constraints: bool, python_version: str, @@ -2764,6 +2780,13 @@ def get_all_constraint_files( if refresh_constraints: shutil.rmtree(CONSTRAINTS_CACHE_PATH, ignore_errors=True) all_airflow_versions, airflow_release_dates = get_active_airflow_versions(confirm=False) + + get_console().print( + f"[info]Filtering to only use airflow versions supported by current python version: {python_version}[/]" + ) + + all_airflow_versions = get_airflow_versions_supported_by_python(all_airflow_versions, python_version) + if not CONSTRAINTS_CACHE_PATH.exists(): with ci_group(f"Downloading constraints for all Airflow versions for Python {python_version}"): CONSTRAINTS_CACHE_PATH.mkdir(parents=True, exist_ok=True) diff --git a/dev/breeze/src/airflow_breeze/global_constants.py b/dev/breeze/src/airflow_breeze/global_constants.py index e1536bdc87325..b16293f1318ab 100644 --- a/dev/breeze/src/airflow_breeze/global_constants.py +++ b/dev/breeze/src/airflow_breeze/global_constants.py @@ -46,6 +46,11 @@ # Checked before putting in build cache ALLOWED_PYTHON_MAJOR_MINOR_VERSIONS = ["3.9", "3.10", "3.11", "3.12"] DEFAULT_PYTHON_MAJOR_MINOR_VERSION = ALLOWED_PYTHON_MAJOR_MINOR_VERSIONS[0] + +# Maps each supported Python version to the minimum Airflow version that supports it. +# Used to filter Airflow versions incompatible with a given Python runtime. +PYTHON_TO_MIN_AIRFLOW_MAPPING = {"3.10": "2.4.0"} + ALLOWED_ARCHITECTURES = [Architecture.X86_64, Architecture.ARM] # Database Backends used when starting Breeze. The "none" value means that the configuration is invalid. # No database will be started - access to a database will fail.