Skip to content

Commit

Permalink
Check if Python 3.12 is used for release management commands as well (#…
Browse files Browse the repository at this point in the history
…37615)

We've been checking - for reproducibility - if python version used is
Python 3.9 or above, but since we are also rebuilding sdist packages,
we need to check if sdist packages can be converted to wheel packages
as well so we need to check python version used.
  • Loading branch information
potiuk authored Feb 22, 2024
1 parent 0900055 commit 4e2f743
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from airflow_breeze.utils.confirm import confirm_action
from airflow_breeze.utils.console import console_print
from airflow_breeze.utils.path_utils import AIRFLOW_SOURCES_ROOT, DIST_DIR, OUT_DIR
from airflow_breeze.utils.python_versions import check_python_3_9_or_above
from airflow_breeze.utils.python_versions import check_python_version
from airflow_breeze.utils.reproducible import get_source_date_epoch, repack_deterministically
from airflow_breeze.utils.run_utils import run_command

Expand Down Expand Up @@ -311,7 +311,7 @@ def remove_old_releases(version, repo_root):
"--version", required=True, help="The release candidate version e.g. 2.4.3rc1", envvar="VERSION"
)
def prepare_airflow_tarball(version: str):
check_python_3_9_or_above()
check_python_version()
from packaging.version import Version

airflow_version = Version(version)
Expand All @@ -337,7 +337,7 @@ def prepare_airflow_tarball(version: str):
)
@option_answer
def publish_release_candidate(version, previous_version, github_token):
check_python_3_9_or_above()
check_python_version()
from packaging.version import Version

airflow_version = Version(version)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
generate_providers_metadata_for_package,
get_related_providers,
)
from airflow_breeze.utils.python_versions import check_python_3_9_or_above, get_python_version_list
from airflow_breeze.utils.python_versions import check_python_version, get_python_version_list
from airflow_breeze.utils.reproducible import get_source_date_epoch, repack_deterministically
from airflow_breeze.utils.run_utils import (
run_command,
Expand Down Expand Up @@ -511,7 +511,7 @@ def prepare_airflow_packages(
version_suffix_for_pypi: str,
use_local_hatch: bool,
):
check_python_3_9_or_above()
check_python_version()
perform_environment_checks()
fix_ownership_using_docker()
cleanup_python_generated_files()
Expand Down Expand Up @@ -760,7 +760,7 @@ def prepare_provider_packages(
skip_tag_check: bool,
version_suffix_for_pypi: str,
):
check_python_3_9_or_above()
check_python_version()
perform_environment_checks()
fix_ownership_using_docker()
cleanup_python_generated_files()
Expand Down Expand Up @@ -2619,7 +2619,7 @@ def prepare_helm_chart_tarball(
) -> None:
import yaml

check_python_3_9_or_above()
check_python_version()
chart_yaml_file_content = CHART_YAML_FILE.read_text()
chart_yaml_dict = yaml.safe_load(chart_yaml_file_content)
version_in_chart = chart_yaml_dict["version"]
Expand Down Expand Up @@ -2761,7 +2761,7 @@ def prepare_helm_chart_tarball(
@option_dry_run
@option_verbose
def prepare_helm_chart_package(sign_email: str):
check_python_3_9_or_above()
check_python_version()

import yaml

Expand Down
15 changes: 11 additions & 4 deletions dev/breeze/src/airflow_breeze/utils/python_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,19 @@ def get_python_version_list(python_versions: str) -> list[str]:
return python_version_list


def check_python_3_9_or_above():
def check_python_version():
error = False
if not sys.version_info >= (3, 9):
get_console().print("[error]Python 3.9 or later is required to prepare reproducible archives.\n")
get_console().print("[error]At least Python 3.9 is required to prepare reproducible archives.\n")
error = True
elif not sys.version_info < (3, 12):
get_console().print("[error]Python 3.12 is not supported.\n")
error = True
if error:
get_console().print(
"[warning]Please reinstall Breeze in Python3.9+ environment. For example:[/]\n\n"
"pipx uninstall apache-airflow-breeze\n\n"
"[warning]Please reinstall Breeze using Python 3.9 - 3.11 environment.[/]\n\n"
"For example:\n\n"
"pipx uninstall apache-airflow-breeze\n"
"pipx install --python $(which python3.9) -e ./dev/breeze --force\n"
)
sys.exit(1)
6 changes: 3 additions & 3 deletions dev/breeze/src/airflow_breeze/utils/reproducible.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from subprocess import CalledProcessError, CompletedProcess

from airflow_breeze.utils.path_utils import AIRFLOW_SOURCES_ROOT, OUT_DIR, REPRODUCIBLE_DIR
from airflow_breeze.utils.python_versions import check_python_3_9_or_above
from airflow_breeze.utils.python_versions import check_python_version
from airflow_breeze.utils.run_utils import run_command


Expand Down Expand Up @@ -91,7 +91,7 @@ def reset(tarinfo):
tarinfo.mtime = timestamp
return tarinfo

check_python_3_9_or_above()
check_python_version()
OUT_DIR.mkdir(exist_ok=True)
shutil.rmtree(REPRODUCIBLE_DIR, ignore_errors=True)
REPRODUCIBLE_DIR.mkdir(exist_ok=True)
Expand Down Expand Up @@ -149,7 +149,7 @@ def reset(tarinfo):


def main():
check_python_3_9_or_above()
check_python_version()
parser = ArgumentParser()
parser.add_argument("-a", "--archive", help="archive to repack")
parser.add_argument("-o", "--out", help="archive destination")
Expand Down

0 comments on commit 4e2f743

Please sign in to comment.