You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ut...@apache.org on 2024/12/04 10:05:24 UTC

(airflow) 11/39: Handle FileNotFound Error returned by missing uv or pipx (#43714) (#43715)

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

utkarsharma pushed a commit to branch sync_2-10-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 037fa9c30555e7f1522fb4e14c10b5743c4c77fe
Author: Jarek Potiuk <ja...@potiuk.com>
AuthorDate: Tue Nov 5 19:17:15 2024 +0100

    Handle FileNotFound Error returned by missing uv or pipx (#43714) (#43715)
    
    Subprocess.run raises FileNotFound when uv or pipx are not installed
    at all. This PR will handle it.
    
    (cherry picked from commit ed3accb30086b9ed5eddcd12b17a5f7c8d52d53b)
---
 dev/breeze/src/airflow_breeze/utils/reinstall.py | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/dev/breeze/src/airflow_breeze/utils/reinstall.py b/dev/breeze/src/airflow_breeze/utils/reinstall.py
index 6fdf994c6e9..4030235e68e 100644
--- a/dev/breeze/src/airflow_breeze/utils/reinstall.py
+++ b/dev/breeze/src/airflow_breeze/utils/reinstall.py
@@ -39,14 +39,20 @@ def reinstall_breeze(breeze_sources: Path, re_run: bool = True):
     get_console().print(f"\n[info]Reinstalling Breeze from {breeze_sources}\n")
     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
+    try:
+        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
+    except FileNotFoundError:
+        pass
+    try:
+        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
+    except FileNotFoundError:
+        pass
     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"