Commit Graph

24 Commits

Author SHA1 Message Date
Zanie Blue 66c1c0d24c
Update the target Python version for Ruff to 3.7 in the `uv` module (#15183)
This fixes our Ruff target Python version for our Python module, which
avoids it enforcing things that break compatibility like
https://github.com/astral-sh/uv/issues/15176

---------

Co-authored-by: arielle <me@arielle.codes>
2025-08-08 19:23:08 -05:00
Dustin Ngo 0924490456
fix: Use 3.9 compatible zip (#15177)
<!--
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

Uses a <3.10-compatible version of `zip` since the `strict` argument was
[added in 3.10](https://docs.python.org/3.10/library/functions.html#zip)

## Test Plan

I executed the `_matching_parents` function in a local 3.9 environment

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2025-08-08 18:45:13 -05:00
Zanie Blue 8a22572338
Bump version to 0.8.7 (#15173) 2025-08-08 14:42:23 -05:00
Zanie Blue 5c729332c1
Use `\n` instead of linesep in not found error message (#15166)
https://github.com/astral-sh/uv/pull/14182#discussion_r2262979815
2025-08-08 09:14:54 -05:00
Zanie Blue a9302906ce
Search in the user scheme scripts directory last in `find_uv_bin` (#14191)
We should definitely not pick up user-level installations unless we
can't find uv anywhere else. Otherwise, e.g., we would find a uv
installed with `pipx install uv` before the one matching the uv module.
2025-08-08 11:46:32 +00:00
Zanie Blue 8968d783de
Add support for `--prefix` and `--with` installations in `find_uv_bin` (#14184)
Follows #14182

Adds support for the case described at
https://github.com/astral-sh/uv/issues/10194#issuecomment-2993544346

This also happens to fix both `--with` requirement test cases, which
should close https://github.com/tox-dev/pre-commit-uv/issues/70
2025-08-07 16:48:07 -05:00
Zanie Blue b1a036ccf5
Refactor `find_uv_bin` and add a better error message (#14182)
Follows https://github.com/astral-sh/uv/pull/14181

Two goals here

- Remove duplicated logic and make the search order clear
- Resolve user confusion around the searched directories; we previously
only displayed the last attempt, which we rarely expect to be relevant
2025-08-07 15:10:38 -05:00
Zanie Blue ceb610c047
Update `find_uv_bin` to locate uv in the base prefix (#14181)
Closes https://github.com/astral-sh/uv/issues/10194
2025-08-07 13:40:57 -05:00
Zanie Blue a186fda2d2
Elide traceback when `python -m uv` in interrupted with Ctrl-C on Windows (#14715)
Closes https://github.com/astral-sh/uv/issues/14704
2025-07-18 08:07:36 -05:00
konsti bf4c7afe8b
A minimal build backend for uv: uv_build (#11446)
uv itself is a large package with many dependencies and lots of
features. To build a package using the uv build backend, you shouldn't
have to download and install the entirety of uv. For platform where we
don't provide wheels, it should be possible and fast to compile the uv
build backend. To that end, we're introducing a python package that
contains a trimmed down version of uv that only contains the build
backend, with a minimal dependency tree in rust.

The `uv_build` package is publish from CI just like uv itself. It is
part of the workspace, but has much less dependencies for its own
binary. We're using cargo deny to enforce that the network stack is not
part of the dependencies. A new build profile ensure we're getting the
minimum possible binary size for a rust binary.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2025-03-06 13:27:20 -06:00
Charles Tapley Hoyt 2401878644
Make build backend type annotations more generic (#10549) 2025-01-13 19:34:17 +01:00
Charles Tapley Hoyt f4f1587549
Add remaining Python type annotations to build backend (#10434) 2025-01-10 13:27:15 +01:00
konsti ff860296c5
Use `shutil.which` for the build backend (#10028)
From PEP 517:

> All command-line scripts provided by the build-required packages must
be present in the build environment’s PATH. For example, if a project
declares a build-requirement on flit, then the following must work as a
mechanism for running the flit command-line tool:
>
> ```python
> import subprocess
> import shutil
> subprocess.check_call([shutil.which("flit"), ...])
> ```

Fixes #9991

---------

Co-authored-by: Charles Tapley Hoyt <cthoyt@gmail.com>
2024-12-20 10:15:24 +01:00
Zanie Blue 7a885eaa09
Add hint on build backend import with preview disabled (#9691)
See #9686

```
❯ uv run python -c "import uv; uv.build_sdist"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/zb/workspace/uv/python/uv/__init__.py", line 45, in __getattr__
    raise AttributeError(err)
AttributeError: Using `uv.build_sdist` is not allowed. The uv build backend requires preview mode to be 
                enabled, e.g., via the `UV_PREVIEW=1` environment variable.

❯ uv run python -c "import uv; uv.foo"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/zb/workspace/uv/python/uv/__init__.py", line 48, in __getattr__
    raise AttributeError(err)
AttributeError: module 'uv' has no attribute 'foo'

❯ uv run python -c "import uv; uv.find_uv_bin"
```
2024-12-06 14:08:00 -06:00
sobolevn d5c5a29490
Check `python/uv/` folder with `mypy` (#7891)
It used to report:

```
» mypy 
python/uv/_build_backend.py:40: error: Incompatible types in assignment (expression has type "list[str]", variable has type "CompletedProcess[bytes]")  [assignment]
python/uv/_build_backend.py:41: error: Value of type "CompletedProcess[bytes]" is not indexable  [index]
python/uv/_build_backend.py:46: error: Value of type "CompletedProcess[bytes]" is not indexable  [index]
Found 3 errors in 1 file (checked 6 source files)
```

So, I had to fix this problem by renaming the `result` var.
2024-10-03 13:05:01 +01:00
konsti c4c5378c0b
Add build backend scaffolding (#7662) 2024-09-24 19:23:17 +02:00
Eric Mark Martin 5752817494
find uv binary relative to package root (#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](19cd9d7d8a/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`.
2024-06-14 20:02:23 -05:00
Zanie Blue 5fe891082d
Discover and prefer the parent interpreter when invoked with `python -m uv` (#3736)
Closes #2222
Closes https://github.com/astral-sh/uv/issues/2058
Replaces https://github.com/astral-sh/uv/pull/2338
See also https://github.com/astral-sh/uv/issues/2649

We use an environment variable (`UV_INTERNAL__PARENT_INTERPRETER`) to
track the invoking interpreter when `python -m uv` is used. The parent
interpreter is preferred over all other sources (though it will be
skipped if it does not meet a `--python` request or if `--system` is
used and it belongs to a virtual environment). We warn if `--system` is
not provided and this interpreter would mutate system packages, but
allow it.
2024-05-22 11:34:24 -05:00
konsti 79fbac7af5
Fast lint CI job: Rustfmt, Prettier, Ruff (#2406)
Add a single job for for fast lint tools. Rustfmt for rust, ruff for
python formatting and linting, prettier avoids inconsistent formatter
changes between pycharm and vscode.
2024-03-20 00:16:46 +00:00
Bernát Gábor 469ccf826f
Expose find_uv_bin and declare typing support (#1728)
Resolves https://github.com/astral-sh/uv/issues/1677

Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>
2024-02-20 09:21:58 -06:00
Zanie Blue b317e6fc56
Ensure we retain existing environment variables during `python -m uv` (#1667)
From https://github.com/astral-sh/uv/issues/1623#issuecomment-1951368507

I thought I checked this was working correctly in #1504 but I guess the
environment is not preserved like I thought.
2024-02-18 15:22:39 -06:00
Zanie Blue f87c29e326
Automatically detect virtual environments when used via `python -m uv` (#1504)
Closes https://github.com/astral-sh/uv/issues/1501
2024-02-16 12:55:24 -06:00
Zanie Blue 2586f655bb
Rename to `uv` (#1302)
First, replace all usages in files in-place. I used my editor for this.
If someone wants to add a one-liner that'd be fun.

Then, update directory and file names:

```
# Run twice for nested directories
find . -type d -print0 | xargs -0 rename s/puffin/uv/g
find . -type d -print0 | xargs -0 rename s/puffin/uv/g

# Update files
find . -type f -print0 | xargs -0 rename s/puffin/uv/g
```

Then add all the files again

```
# Add all the files again
git add crates
git add python/uv

# This one needs a force-add
git add -f crates/uv-trampoline
```
2024-02-15 11:19:46 -06:00
Charlie Marsh f9154e8297
Add release workflow (#961)
## Summary

This PR adds a release workflow powered by `cargo-dist`. It's similar to
the version that's PR'd in Ruff
(https://github.com/astral-sh/ruff/pull/9559), with the exception that
it doesn't include the Docker build or the "update dependents" step for
pre-commit.
2024-01-18 15:44:11 -05:00