From 5752817494923f1fa3475a5a4390b9d916d91a4f Mon Sep 17 00:00:00 2001 From: Eric Mark Martin Date: Fri, 14 Jun 2024 21:02:23 -0400 Subject: [PATCH] find uv binary relative to package root (#4336) ## Summary [ruff's `find_bin` implementation](https://github.com/astral-sh/ruff/blob/19cd9d7d8a849cc6e0da65e58fb8c7b6a7a9cb9f/python/ruff/__main__.py#L31) can find the binary in relative to the package root. It'd be nice to have the same functionality for `uv`. --- python/uv/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/python/uv/__init__.py b/python/uv/__init__.py index 38a17d6ce917..781eee4f97bf 100644 --- a/python/uv/__init__.py +++ b/python/uv/__init__.py @@ -27,6 +27,12 @@ def find_uv_bin() -> str: if os.path.isfile(path): return path + # Search in `bin` adjacent to package root (as created by `pip install --target`). + pkg_root = os.path.dirname(os.path.dirname(__file__)) + target_path = os.path.join(pkg_root, "bin", uv_exe) + if os.path.isfile(target_path): + return target_path + raise FileNotFoundError(path)