code: def build_airflow_packages(package_format: str):
      build_command = [
          sys.executable,
          "-m",
          "hatch",
          "build",
          "-t",
          "custom",
      ]
      if package_format in ["both", "sdist"]:
          build_command.extend(["-t", "sdist"])
      if package_format in ["both", "wheel"]:
          build_command.extend(["-t", "wheel"])
  
      reproducible_date = yaml.safe_load(
          REPRODUCIBLE_BUILD_FILE.read_text()
      )["source-date-epoch"]
  
      envcopy = os.environ.copy()
      envcopy["SOURCE_DATE_EPOCH"] = str(reproducible_date)
      console.print(
          f"[bright_blue]Building packages: {package_format}\n"
      )
      build_process = subprocess.run(
          build_command,
          capture_output=False,
          cwd=AIRFLOW_SOURCES_ROOT,
          env=envcopy,
      )
  
      if build_process.returncode != 0:
          console.print("[red]Error building Airflow packages")
          sys.exit(build_process.returncode)
      else:
          console.print("[green]Airflow packages built successfully")
  
file_path: airflow/scripts/in_container/run_prepare_airflow_packages.py
imports: from __future__ import annotations
  import os
  import re
  import subprocess
  import sys
  from contextlib import contextmanager
  from pathlib import Path
  from shutil import rmtree
  import yaml
  from rich.console import Console
label_desc: Use image node_id 4 for calling a global function with example usage: build_airflow_packages(package_format) without return types