Skip to content

Commit

Permalink
find uv binary relative to package root (#4336)
Browse files Browse the repository at this point in the history
<!--
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`.
  • Loading branch information
ericmarkmartin committed Jun 15, 2024
1 parent 294f0e0 commit 5752817
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python/uv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down

0 comments on commit 5752817

Please sign in to comment.