This is an automated email from the ASF dual-hosted git repository.

turaga pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 736c262a272 Run hatch always in a clean env (#61970)
736c262a272 is described below

commit 736c262a272814bd829b8299f66ba329c6112ecf
Author: Jens Scheffler <[email protected]>
AuthorDate: Mon Feb 16 03:32:18 2026 +0100

    Run hatch always in a clean env (#61970)
    
    * Run hatch always in a clean env
    
    * Add PATH to env
---
 .../commands/release_candidate_command.py               |  5 ++---
 .../commands/release_management_commands.py             | 17 +++++++----------
 .../prepare_providers/provider_distributions.py         |  9 +++------
 .../in_container/run_prepare_airflow_distributions.py   |  7 +++----
 4 files changed, 15 insertions(+), 23 deletions(-)

diff --git 
a/dev/breeze/src/airflow_breeze/commands/release_candidate_command.py 
b/dev/breeze/src/airflow_breeze/commands/release_candidate_command.py
index 08aa6b67da2..651aa803dd6 100644
--- a/dev/breeze/src/airflow_breeze/commands/release_candidate_command.py
+++ b/dev/breeze/src/airflow_breeze/commands/release_candidate_command.py
@@ -362,11 +362,10 @@ def create_artifacts_with_hatch(source_date_epoch: int):
     console_print("[info]Creating artifacts with hatch")
     shutil.rmtree(AIRFLOW_DIST_PATH, ignore_errors=True)
     AIRFLOW_DIST_PATH.mkdir(exist_ok=True)
-    env_copy = os.environ.copy()
-    env_copy["SOURCE_DATE_EPOCH"] = str(source_date_epoch)
+    hatch_env = {"SOURCE_DATE_EPOCH": str(source_date_epoch), "PATH": 
os.environ["PATH"]}
     # Build Airflow packages
     run_command(
-        ["hatch", "build", "-c", "-t", "custom", "-t", "sdist", "-t", 
"wheel"], check=True, env=env_copy
+        ["hatch", "build", "-c", "-t", "custom", "-t", "sdist", "-t", 
"wheel"], check=True, env=hatch_env
     )
     # Build Task SDK packages
     run_command(
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 a94d4c09bb9..4226ad2e027 100644
--- a/dev/breeze/src/airflow_breeze/commands/release_management_commands.py
+++ b/dev/breeze/src/airflow_breeze/commands/release_management_commands.py
@@ -445,8 +445,7 @@ def 
apply_distribution_format_to_hatch_command(build_command: list[str], distrib
 
 
 def _build_airflow_packages_with_hatch(distribution_format: str, 
source_date_epoch: int, version_suffix: str):
-    env_copy = os.environ.copy()
-    env_copy["SOURCE_DATE_EPOCH"] = str(source_date_epoch)
+    hatch_env = {"SOURCE_DATE_EPOCH": str(source_date_epoch), "PATH": 
os.environ["PATH"]}
     build_airflow_core_command = ["hatch", "build", "-c", "-t", "custom"]
     apply_distribution_format_to_hatch_command(build_airflow_core_command, 
distribution_format)
     get_console().print(f"[bright_blue]Building apache-airflow-core 
distributions: {distribution_format}\n")
@@ -459,7 +458,7 @@ def _build_airflow_packages_with_hatch(distribution_format: 
str, source_date_epo
         run_command(
             build_airflow_core_command,
             check=True,
-            env=env_copy,
+            env=hatch_env,
             cwd=AIRFLOW_CORE_ROOT_PATH,
         )
     get_console().print(f"[bright_blue]Building apache-airflow distributions: 
{distribution_format}\n")
@@ -474,7 +473,7 @@ def _build_airflow_packages_with_hatch(distribution_format: 
str, source_date_epo
         run_command(
             build_airflow_command,
             check=True,
-            env=env_copy,
+            env=hatch_env,
             cwd=AIRFLOW_ROOT_PATH,
         )
     for distribution_path in (AIRFLOW_CORE_ROOT_PATH / 
"dist").glob("apache_airflow_core*"):
@@ -613,12 +612,11 @@ def _prepare_non_core_distributions(
             command += ["-t", "sdist"]
         if build_distribution_format == "wheel" or build_distribution_format 
== "both":
             command += ["-t", "wheel"]
-        env_copy = os.environ.copy()
-        env_copy["SOURCE_DATE_EPOCH"] = str(source_date_epoch)
+        hatch_env = {"SOURCE_DATE_EPOCH": str(source_date_epoch), "PATH": 
os.environ["PATH"]}
         run_command(
             cmd=command,
             cwd=root_path,
-            env=env_copy,
+            env=hatch_env,
             check=True,
         )
         shutil.copytree(distribution_path, AIRFLOW_DIST_PATH, 
dirs_exist_ok=True)
@@ -3451,12 +3449,11 @@ def 
_build_client_packages_with_hatch(source_date_epoch: int, distribution_forma
         command += ["-t", "sdist"]
     if distribution_format == "wheel" or distribution_format == "both":
         command += ["-t", "wheel"]
-    env_copy = os.environ.copy()
-    env_copy["SOURCE_DATE_EPOCH"] = str(source_date_epoch)
+    hatch_env = {"SOURCE_DATE_EPOCH": str(source_date_epoch), "PATH": 
os.environ["PATH"]}
     run_command(
         cmd=command,
         cwd=PYTHON_CLIENT_DIR_PATH,
-        env=env_copy,
+        env=hatch_env,
         check=True,
     )
     shutil.copytree(PYTHON_CLIENT_DIST_DIR_PATH, AIRFLOW_DIST_PATH, 
dirs_exist_ok=True)
diff --git 
a/dev/breeze/src/airflow_breeze/prepare_providers/provider_distributions.py 
b/dev/breeze/src/airflow_breeze/prepare_providers/provider_distributions.py
index 7187b83fedd..47e7cef548d 100644
--- a/dev/breeze/src/airflow_breeze/prepare_providers/provider_distributions.py
+++ b/dev/breeze/src/airflow_breeze/prepare_providers/provider_distributions.py
@@ -103,6 +103,7 @@ def build_provider_distribution(
     if not provider_info:
         raise RuntimeError(f"The provider {provider_id} has no provider.yaml 
defined.")
     build_backend = provider_info.get("build-system", "flit_core")
+    build_env = {"SOURCE_DATE_EPOCH": 
str(get_provider_details(provider_id).source_date_epoch)}
     if build_backend == "flit_core":
         command: list[str] = [sys.executable, "-m", "flit", "build", 
"--no-setup-py", "--use-vcs"]
         get_console().print(
@@ -121,9 +122,7 @@ def build_provider_distribution(
                 command,
                 check=True,
                 cwd=target_provider_root_sources_path,
-                env={
-                    "SOURCE_DATE_EPOCH": 
str(get_provider_details(provider_id).source_date_epoch),
-                },
+                env=build_env,
             )
         except subprocess.CalledProcessError as ex:
             get_console().print(f"[error]The command returned an error {ex}")
@@ -145,9 +144,7 @@ def build_provider_distribution(
             run_command(
                 cmd=command,
                 cwd=target_provider_root_sources_path,
-                env={
-                    "SOURCE_DATE_EPOCH": 
str(get_provider_details(provider_id).source_date_epoch),
-                },
+                env=build_env,
                 check=True,
             )
         except subprocess.CalledProcessError as ex:
diff --git a/scripts/in_container/run_prepare_airflow_distributions.py 
b/scripts/in_container/run_prepare_airflow_distributions.py
index 6dfc64a8d38..1c61f52ad84 100755
--- a/scripts/in_container/run_prepare_airflow_distributions.py
+++ b/scripts/in_container/run_prepare_airflow_distributions.py
@@ -86,8 +86,7 @@ def apply_distribution_format_to_hatch_command(build_command: 
list[str], distrib
 
 def build_airflow_packages(distribution_format: str):
     reproducible_date = 
yaml.safe_load(REPRODUCIBLE_BUILD_YAML_PATH.read_text())["source-date-epoch"]
-    envcopy = os.environ.copy()
-    envcopy["SOURCE_DATE_EPOCH"] = str(reproducible_date)
+    hatch_env = {"SOURCE_DATE_EPOCH": str(reproducible_date), "PATH": 
os.environ["PATH"]}
     airflow_core_build_command = [sys.executable, "-m", "hatch", "build", 
"-t", "custom"]
     apply_distribution_format_to_hatch_command(airflow_core_build_command, 
distribution_format)
     console.print(f"[bright_blue]Building apache-airflow-core distributions: 
{distribution_format}\n")
@@ -96,7 +95,7 @@ def build_airflow_packages(distribution_format: str):
         check=False,
         capture_output=False,
         cwd=AIRFLOW_CORE_ROOT_PATH,
-        env=envcopy,
+        env=hatch_env,
     )
     if build_process.returncode != 0:
         console.print("[red]Error building Airflow packages")
@@ -109,7 +108,7 @@ def build_airflow_packages(distribution_format: str):
         check=False,
         capture_output=False,
         cwd=AIRFLOW_ROOT_PATH,
-        env=envcopy,
+        env=hatch_env,
     )
     if build_process.returncode != 0:
         console.print("[red]Error building Airflow packages")

Reply via email to