Skip to content

Commit

Permalink
Detect situation where Breeze is installed with both pipx and uv (#43694
Browse files Browse the repository at this point in the history
)

When breeze is installed with both - pipx and uv, we do not know
which version is available first on the path and self-upgrading
breeze might not upgrade the one that is first. Therefore we
detect that situation and fail self upgrade with appropriate
instructions what to do (recommending leaving uv as faster)
  • Loading branch information
potiuk authored Nov 5, 2024
1 parent 1116f28 commit ccd6586
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions dev/breeze/src/airflow_breeze/utils/reinstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,38 @@ def reinstall_breeze(breeze_sources: Path, re_run: bool = True):
# Breeze from different sources than originally installed (i.e. when we reinstall airflow
# From the current directory.
get_console().print(f"\n[info]Reinstalling Breeze from {breeze_sources}\n")
result = subprocess.run(["uv", "tool", "list"], text=True, capture_output=True, check=False)
if result.returncode == 0:
if "apache-airflow-breeze" in result.stdout:
subprocess.check_call(
["uv", "tool", "install", "--force", "--reinstall", "-e", breeze_sources.as_posix()]
)
else:
breeze_installed_with_uv = False
breeze_installed_with_pipx = False
result_uv = subprocess.run(["uv", "tool", "list"], text=True, capture_output=True, check=False)
if result_uv.returncode == 0:
if "apache-airflow-breeze" in result_uv.stdout:
breeze_installed_with_uv = True
result_pipx = subprocess.run(["pipx", "list"], text=True, capture_output=True, check=False)
if result_pipx.returncode == 0:
if "apache-airflow-breeze" in result_pipx.stdout:
breeze_installed_with_pipx = True
if breeze_installed_with_uv and breeze_installed_with_pipx:
get_console().print(
"[error]Breeze is installed both with `uv` and `pipx`. This is not supported.[/]\n"
)
get_console().print(
"[info]Please uninstall Breeze and install it only with one of the methods[/]\n"
"[info]The `uv` installation method is recommended as it is much faster[/]\n"
)
get_console().print(
"To uninstall Breeze installed with pipx run:\n pipx uninstall apache-airflow-breeze\n"
)
get_console().print(
"To uninstall Breeze installed with uv run:\n uv tool uninstall apache-airflow-breeze\n"
)
sys.exit(1)
elif breeze_installed_with_uv:
subprocess.check_call(
["uv", "tool", "install", "--force", "--reinstall", "-e", breeze_sources.as_posix()]
)
elif breeze_installed_with_pipx:
subprocess.check_call(["pipx", "install", "-e", breeze_sources.as_posix(), "--force"])

if re_run:
# Make sure we don't loop forever if the metadata hash hasn't been updated yet (else it is tricky to
# run pre-commit checks via breeze!)
Expand Down

0 comments on commit ccd6586

Please sign in to comment.