This is an automated email from the ASF dual-hosted git repository. potiuk pushed a commit to branch v2-8-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit 05ebe7ad49b43d49299f9ee4239f8e6134f8157b Author: Jarek Potiuk <[email protected]> AuthorDate: Mon Jan 8 23:23:41 2024 +0100 Add version check for k8s setup venv command (#36673) This command install airflow in k8s venv and in case version of Python is not yet supported by Airflow, it might fail. We do not have check it lower-bound because breeze supports the same minimum version of Airflow as Airflow itself. The command prints instructions on how to reinstall breeze with different Python version in such case. (cherry picked from commit 9264a4b4e21702a2bc71bb77ee3cc4ada9dfd5e7) --- .../src/airflow_breeze/utils/kubernetes_utils.py | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/dev/breeze/src/airflow_breeze/utils/kubernetes_utils.py b/dev/breeze/src/airflow_breeze/utils/kubernetes_utils.py index b7002add2a..8a8db025d5 100644 --- a/dev/breeze/src/airflow_breeze/utils/kubernetes_utils.py +++ b/dev/breeze/src/airflow_breeze/utils/kubernetes_utils.py @@ -32,7 +32,13 @@ from time import sleep from typing import Any, NamedTuple from urllib import request -from airflow_breeze.global_constants import ALLOWED_ARCHITECTURES, HELM_VERSION, KIND_VERSION, PIP_VERSION +from airflow_breeze.global_constants import ( + ALLOWED_ARCHITECTURES, + ALLOWED_PYTHON_MAJOR_MINOR_VERSIONS, + HELM_VERSION, + KIND_VERSION, + PIP_VERSION, +) from airflow_breeze.utils.console import Output, get_console from airflow_breeze.utils.host_info_utils import Architecture, get_host_architecture, get_host_os 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: get_console().print(f"[info]Dry run - would be removing {K8S_ENV_PATH}") else: shutil.rmtree(K8S_ENV_PATH, ignore_errors=True) + max_python_version = ALLOWED_PYTHON_MAJOR_MINOR_VERSIONS[-1] + max_python_version_tuple = tuple(int(x) for x in max_python_version.split(".")) + higher_python_version_tuple = max_python_version_tuple[0], max_python_version_tuple[1] + 1 + if sys.version_info >= higher_python_version_tuple: + get_console().print( + f"[red]This is not supported in Python {higher_python_version_tuple} and above[/]\n" + ) + get_console().print(f"[warning]Please use Python version before {higher_python_version_tuple}[/]\n") + get_console().print( + "[info]You can uninstall breeze and install it again with earlier Python " + "version. For example:[/]\n" + ) + get_console().print("pipx uninstall apache-airflow-breeze") + get_console().print("pipx install --python PYTHON_PATH -e ./dev/breeze\n") + get_console().print( + f"[info]PYTHON_PATH - path to your Python binary(< {higher_python_version_tuple})[/]\n" + ) + get_console().print("[info]Then recreate your k8s virtualenv with:[/]\n") + get_console().print("breeze k8s setup-env --force-venv-setup\n") + sys.exit(1) venv_command_result = run_command( [sys.executable, "-m", "venv", str(K8S_ENV_PATH)], check=False,
