Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BACKPORT] Detect situation where Breeze is installed with both pipx and uv (#43… #43695

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading