9898 DEFAULT_PYTHON_MAJOR_MINOR_VERSION ,
9999 DESTINATION_LOCATIONS ,
100100 MULTI_PLATFORM ,
101+ PYTHON_TO_MIN_AIRFLOW_MAPPING ,
101102 UV_VERSION ,
102103)
103104from airflow_breeze .params .shell_params import ShellParams
@@ -2756,6 +2757,21 @@ def generate_issue_content_core(
27562757 )
27572758
27582759
2760+ def is_airflow_version_supported_for_python (airflow_version : str , python_version : str ) -> bool :
2761+ from packaging .version import Version
2762+
2763+ min_airflow_version = PYTHON_TO_MIN_AIRFLOW_MAPPING .get (python_version )
2764+ if not min_airflow_version :
2765+ return False
2766+ return Version (airflow_version ) >= Version (min_airflow_version )
2767+
2768+
2769+ def get_airflow_versions_supported_by_python (
2770+ all_airflow_versions : list [str ], python_version : str
2771+ ) -> list [str ]:
2772+ return [v for v in all_airflow_versions if is_airflow_version_supported_for_python (v , python_version )]
2773+
2774+
27592775def get_all_constraint_files (
27602776 refresh_constraints : bool ,
27612777 python_version : str ,
@@ -2764,6 +2780,13 @@ def get_all_constraint_files(
27642780 if refresh_constraints :
27652781 shutil .rmtree (CONSTRAINTS_CACHE_PATH , ignore_errors = True )
27662782 all_airflow_versions , airflow_release_dates = get_active_airflow_versions (confirm = False )
2783+
2784+ get_console ().print (
2785+ f"[info]Filtering to only use airflow versions supported by current python version: { python_version } [/]"
2786+ )
2787+
2788+ all_airflow_versions = get_airflow_versions_supported_by_python (all_airflow_versions , python_version )
2789+
27672790 if not CONSTRAINTS_CACHE_PATH .exists ():
27682791 with ci_group (f"Downloading constraints for all Airflow versions for Python { python_version } " ):
27692792 CONSTRAINTS_CACHE_PATH .mkdir (parents = True , exist_ok = True )
0 commit comments