|
32 | 32 | from typing import Any, NamedTuple |
33 | 33 | from urllib import request |
34 | 34 |
|
35 | | -from airflow_breeze.global_constants import ALLOWED_ARCHITECTURES, HELM_VERSION, KIND_VERSION, PIP_VERSION |
| 35 | +from airflow_breeze.global_constants import ( |
| 36 | + ALLOWED_ARCHITECTURES, |
| 37 | + ALLOWED_PYTHON_MAJOR_MINOR_VERSIONS, |
| 38 | + HELM_VERSION, |
| 39 | + KIND_VERSION, |
| 40 | + PIP_VERSION, |
| 41 | +) |
36 | 42 | from airflow_breeze.utils.console import Output, get_console |
37 | 43 | from airflow_breeze.utils.host_info_utils import Architecture, get_host_architecture, get_host_os |
38 | 44 | from airflow_breeze.utils.path_utils import AIRFLOW_SOURCES_ROOT, BUILD_CACHE_DIR |
@@ -330,6 +336,26 @@ def create_virtualenv(force_venv_setup: bool) -> RunCommandResult: |
330 | 336 | get_console().print(f"[info]Dry run - would be removing {K8S_ENV_PATH}") |
331 | 337 | else: |
332 | 338 | shutil.rmtree(K8S_ENV_PATH, ignore_errors=True) |
| 339 | + max_python_version = ALLOWED_PYTHON_MAJOR_MINOR_VERSIONS[-1] |
| 340 | + max_python_version_tuple = tuple(int(x) for x in max_python_version.split(".")) |
| 341 | + higher_python_version_tuple = max_python_version_tuple[0], max_python_version_tuple[1] + 1 |
| 342 | + if sys.version_info >= higher_python_version_tuple: |
| 343 | + get_console().print( |
| 344 | + f"[red]This is not supported in Python {higher_python_version_tuple} and above[/]\n" |
| 345 | + ) |
| 346 | + get_console().print(f"[warning]Please use Python version before {higher_python_version_tuple}[/]\n") |
| 347 | + get_console().print( |
| 348 | + "[info]You can uninstall breeze and install it again with earlier Python " |
| 349 | + "version. For example:[/]\n" |
| 350 | + ) |
| 351 | + get_console().print("pipx uninstall apache-airflow-breeze") |
| 352 | + get_console().print("pipx install --python PYTHON_PATH -e ./dev/breeze\n") |
| 353 | + get_console().print( |
| 354 | + f"[info]PYTHON_PATH - path to your Python binary(< {higher_python_version_tuple})[/]\n" |
| 355 | + ) |
| 356 | + get_console().print("[info]Then recreate your k8s virtualenv with:[/]\n") |
| 357 | + get_console().print("breeze k8s setup-env --force-venv-setup\n") |
| 358 | + sys.exit(1) |
333 | 359 | venv_command_result = run_command( |
334 | 360 | [sys.executable, "-m", "venv", str(K8S_ENV_PATH)], |
335 | 361 | check=False, |
|
0 commit comments