Skip to content

Commit 5752817

Browse files
authoredJun 15, 2024
find uv binary relative to package root (astral-sh#4336)
<!-- Thank you for contributing to uv! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? - Does this pull request include references to any relevant issues? --> ## 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`.
1 parent 294f0e0 commit 5752817

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed
 

‎python/uv/__init__.py

+6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ def find_uv_bin() -> str:
2727
if os.path.isfile(path):
2828
return path
2929

30+
# Search in `bin` adjacent to package root (as created by `pip install --target`).
31+
pkg_root = os.path.dirname(os.path.dirname(__file__))
32+
target_path = os.path.join(pkg_root, "bin", uv_exe)
33+
if os.path.isfile(target_path):
34+
return target_path
35+
3036
raise FileNotFoundError(path)
3137

3238

0 commit comments

Comments
 (0)
Please sign in to comment.