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>
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"
```
<!--
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`.
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
```