Skip to content

Add support for --prefix and --with installations in find_uv_bin#14184

Merged
zanieb merged 4 commits intomainfrom
zb/find-prefix
Aug 7, 2025
Merged

Add support for --prefix and --with installations in find_uv_bin#14184
zanieb merged 4 commits intomainfrom
zb/find-prefix

Conversation

@zanieb
Copy link
Copy Markdown
Member

@zanieb zanieb commented Jun 21, 2025

Follows #14182

Adds support for the case described at #10194 (comment)

This also happens to fix both --with requirement test cases, which should close tox-dev/pre-commit-uv#70

@zanieb zanieb added the enhancement New feature or improvement to existing functionality label Jun 21, 2025
@zanieb zanieb temporarily deployed to uv-test-registries June 21, 2025 12:35 — with GitHub Actions Inactive
@zanieb zanieb temporarily deployed to uv-test-registries June 21, 2025 18:38 — with GitHub Actions Inactive
@zanieb zanieb temporarily deployed to uv-test-registries June 21, 2025 18:41 — with GitHub Actions Inactive
@zanieb zanieb marked this pull request as ready for review June 26, 2025 12:53
@zanieb zanieb requested a review from konstin June 27, 2025 17:46
# The scripts directory for the base prefix
sysconfig.get_path("scripts", vars={"base": sys.base_prefix}),
# The user scheme scripts directory, e.g., `~/.local/bin`
sysconfig.get_path("scripts", scheme=_user_scheme()),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do this last? This could easily pick up a different, global uv installation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually happens for me:

$ uv pip install --prefix foo_prefix --find-links target/wheels/ --no-index uv
$ PYTHONPATH="foo_prefix/lib/python3.12/site-packages/" python -S -c "import sys; print(sys.path); from uv import find_uv_bin; print(find_uv_bin())"
['', '/home/konsti/projects/uv/bar', '/usr/lib/python312.zip', '/usr/lib/python3.12', '/usr/lib/python3.12/lib-dynload']
/home/konsti/.local/bin/uv

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's what we're discussing at #14184 (comment)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I consider this a distinct change, will be addressed by #14191

@zanieb zanieb temporarily deployed to uv-test-registries July 7, 2025 17:21 — with GitHub Actions Inactive
@zanieb zanieb temporarily deployed to uv-test-registries July 7, 2025 17:25 — with GitHub Actions Inactive
zanieb added a commit that referenced this pull request Aug 7, 2025
Adds test cases to unblock

- #14181
- #14182
- #14184
- #14184
- tox-dev/pre-commit-uv#70

We use a package with a symlink to the Python module to get a mock
installation of uv without building (or packaging) the uv binary. This
lets us test real patterns like `uv pip install --prefix` without
encoding logic about where things are placed during those installs.

---------

Co-authored-by: konstin <konstin@mailbox.org>
@zanieb zanieb force-pushed the zb/ref-find branch 7 times, most recently from 2bd9a39 to ee983d3 Compare August 7, 2025 18:58
Base automatically changed from zb/ref-find to main August 7, 2025 20:10
@zanieb zanieb had a problem deploying to uv-test-registries August 7, 2025 20:18 — with GitHub Actions Error
@zanieb zanieb changed the title Add support for --prefix installations in find_uv_bin Add support for --prefix and --with installations in find_uv_bin Aug 7, 2025
@zanieb zanieb temporarily deployed to uv-test-registries August 7, 2025 20:20 — with GitHub Actions Inactive
Copy link
Copy Markdown
Member

@woodruffw woodruffw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM -- confirming my understanding that this is intentionally overly permissive in what it'll discover, and #14191 will ratchet it down?

@zanieb
Copy link
Copy Markdown
Member Author

zanieb commented Aug 7, 2025

It depends on what you mean by overly permissive. #14191 just changes the ordering so we don't search in the user script directory before checking everywhere else that could be associated with the actual module.

@zanieb zanieb temporarily deployed to uv-test-registries August 7, 2025 20:44 — with GitHub Actions Inactive
@zanieb zanieb temporarily deployed to uv-test-registries August 7, 2025 21:18 — with GitHub Actions Inactive
@zanieb zanieb temporarily deployed to uv-test-publish August 7, 2025 21:19 — with GitHub Actions Inactive
@zanieb zanieb merged commit 8968d78 into main Aug 7, 2025
178 of 179 checks passed
@zanieb zanieb deleted the zb/find-prefix branch August 7, 2025 21:48
if not all(
fnmatch(part, match_part)
for part, match_part in zip(
reversed(parts), reversed(match_parts), strict=False
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't support Python 3.8 and 3.9. strict= was introduced in 3.10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or improvement to existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

uv 0.8.2 fails with FileNotFoundError

5 participants