Commit Graph

3925 Commits

Author SHA1 Message Date
Charlie Marsh b5a3d09958
Respect comma-separated extras in `--with` (#8946)
## Summary

We need to treat `flask,anyio` as two requirements, but
`psycopg[binary,pool]` as a single requirement.

Closes #8918.
2024-11-08 20:13:30 +00:00
Charlie Marsh 0b5a06194b
Compute superset of existing and required hashes when healing cache (#8955)
## Summary

The basic issue here is that `uv add` will compute and store a hash for
each package. But if you later run `uv pip install` _after_ `uv cache
prune --ci`, we need to re-download the source distribution. After
re-downloading, we compare the hashes before and after. But `uv pip
install` doesn't compute any hashes by default. So the hashes "differ"
and we error.

Instead, we need to compute a superset of the already-existing and
newly-requested hashes when performing this re-download. (In practice,
this will always be SHA-256.)

Closes https://github.com/astral-sh/uv/issues/8929.

## Test Plan

```shell
export UV_CACHE_DIR="$PWD/cache"

rm -rf "$UV_CACHE_DIR" .venv .venv-2 pyproject.toml uv.lock

echo $(uv --version)

uv init --name uv-cache-issue
cargo run add --python 3.13 "pycairo"

uv cache prune --ci

rm -rf .venv .venv-2

uv venv --python python3.11 .venv-2
. .venv-2/bin/activate
cargo run pip install "pycairo"
```
2024-11-08 15:12:15 -05:00
Mark Ryan a11d27b502
Allow installation of manylinux wheels on riscv64 (#8934)
<!--
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

auditwheel is capable of generating riscv64 wheels for manylinux_2_31
and above. Here we modify uv-platform-tags so that those wheels can be
installed using uv.

Fixes: #8889

## Test Plan

- ran `cargo nextest run` locally on an x86 machine
- also ran `cargo nextest run` locally on a riscv64 VM but there were a
fair few failures (with and without this patch)
- built a riscv64 uv wheel, installed it on a riscv64 VM and checked
that I could use the newly built version of uv to install
manylinux_2_35_riscv64 wheels.
2024-11-08 16:57:51 +01:00
Charlie Marsh 04c445a3db
Respect `--index-url` in `uv pip list` (#8942)
## Summary

As an oversight, these arguments weren't being respected from the CLI or
elsewhere -- we always hit PyPI, ignored `--exclude-newer`, etc. It has
to do with the way that the `PipOptions` are setup -- there's a global
struct that we pass around everywhere and fill in with defaults, so
there's no type safety to guarantee that we provide whatever it is we
need to use in the command. The newer APIs are much better about this.

Closes #8927.
2024-11-08 09:52:32 -05:00
Charlie Marsh 0b4e5cffa6
Allow non-registry dependencies in `uv pip list --outdated` (#8939)
## Summary

Closes https://github.com/astral-sh/uv/issues/8926.
2024-11-08 14:12:25 +00:00
Zanie Blue 7835ce0c4e
Fix `prune_unzipped` test on `main` (#8938) 2024-11-08 13:40:27 +00:00
Zanie Blue 980d25a801
Remove some missed references to `~/.cargo/bin` (#8936) 2024-11-08 07:29:32 -06:00
Charlie Marsh 0db38844d9
Enable uv to replace and delete itself on Windows (#8914)
## Summary

On Windows, we can't delete the currently-running executable -- at
least, not trivially. But the
[`self_replace`](https://docs.rs/self-replace/latest/self_replace/)
crate can help us here.

Closes https://github.com/astral-sh/uv/issues/1368.

Closes https://github.com/astral-sh/uv/issues/4980.

## Test Plan

On my Windows machine:

- `maturin build`
- `python -m venv .venv`
- `.venv/Scripts/activate`
- `pip install /path/to/uv.whl`
- `uv pip install /path/to/uv.whl`
- `uv pip uninstall uv`
2024-11-07 21:57:38 -05:00
Charlie Marsh 9cd51c8a57
Add dedicated cache method for creating build directories (#8910)
## Summary

Based on feedback from
https://github.com/astral-sh/uv/pull/8905/files#r1833531812.
2024-11-08 00:50:55 +00:00
Charlie Marsh 88033610b5
Remove source distribution filename from cache (#8907)
## Summary

In the example outlined in https://github.com/astral-sh/uv/issues/8884,
this removes an unnecessary `jupyter_contrib_nbextensions-0.7.0.tar.gz`
segment (replacing it with `src`), thereby saving 39 characters and
getting that build working on my Windows machine.

This should _not_ require a version bump because we already have logic
in place to "heal" partial cache entries that lack an unzipped
distribution.

Closes https://github.com/astral-sh/uv/issues/8884.

Closes https://github.com/astral-sh/uv/issues/7376.
2024-11-08 00:50:06 +00:00
Charlie Marsh 8a1b581d07
Build source distributions at top-level of cache (#8905)
## Summary

See: https://github.com/astral-sh/uv/issues/8884. We build in a
directory that's deep within the cache; to help with file name length
limits, we should build at the top-level of the cache.
2024-11-08 00:20:24 +00:00
Zanie Blue 8d665267cd
Bump version to 0.5.0 (#8899)
Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>
2024-11-07 22:38:25 +00:00
Zanie Blue 8047d8484a Only write `.python-version` files during `uv init` for workspace members if the version differs (#8897)
We'll read these from the workspace root anyway!
2024-11-07 14:29:54 -06:00
Zanie Blue 73cd1c8fd8 Create `.python-version` files in projects even if one exists outside of it (#8896) 2024-11-07 14:29:54 -06:00
Zanie Blue c134ac2eab Only report Python pins as updated if its the same file (#8894) 2024-11-07 14:29:54 -06:00
Charlie Marsh 4d760ac1f9 Add dedicated tests for the max local version sentinel (#8869) 2024-11-07 14:29:54 -06:00
Charlie Marsh a80b6f51b0 Use a + for the visual max local (#8844)
We don't actually want users to see this, but we should be stripping it
anyway. Without this change, we show ranges in the debug logs that look
like `>=1.0.0, <1.0.0`, which is more confusing than helpful. (We may
want to post-process those debug ranges to remove these.)
2024-11-07 14:29:54 -06:00
Charlie Marsh 70f8377928 Incorporate `[max]` local version into `VersionSmall` (#8843)
See discussion in https://github.com/astral-sh/uv/pull/8797.
2024-11-07 14:29:54 -06:00
Charlie Marsh 90653e1f5e Remove all special-casing for local version identifiers (#8818)
After https://github.com/astral-sh/uv/pull/8797, we have spec-compliant
handling for local version identifiers and can completely remove all the
special-casing around it.
2024-11-07 14:29:54 -06:00
Eric Mark Martin c49c7bdf97 Implement PEP 440-compliant local version semantics (#8797)
Implement a full working version of local version semantics. The (AFAIA)
major move towards this was implemented in #2430. This added support
such that the version specifier `torch==2.1.0+cpu` would install
`torch@2.1.0+cpu` and consider `torch@2.1.0+cpu` a valid way to satisfy
the requirement `torch==2.1.0` in further dependency resolution.

In this feature, we more fully support local version semantics. Namely,
we now allow `torch==2.1.0` to install `torch@2.1.0+cpu` regardless of
whether `torch@2.1.0` (no local tag) actually exists.

We do this by adding an internal-only `Max` value to local versions that
compare greater to all other local versions. Then we can translate
`torch==2.1.0` into bounds: greater than 2.1.0 with no local tag and
less than 2.1.0 with the `Max` local tag.

Depends on https://github.com/astral-sh/packse/pull/227.
2024-11-07 14:29:54 -06:00
Zanie Blue 8ef5949294 Discover and respect `.python-version` files in parent directories (#6370)
Uses #6369 for test coverage.

Updates version file discovery to search up into parent directories.
Also refactors Python request determination to avoid duplicating the
user request / version file / workspace lookup logic in every command
(this supersedes the work started in
https://github.com/astral-sh/uv/pull/6372).

There is a bit of remaining work here, mostly around documentation.
There are some edge-cases where we don't use the refactored request
utility, like `uv build` — I'm not sure how I'm going to handle that yet
as it needs a separate root directory.
2024-11-07 14:29:54 -06:00
Zanie Blue fb89b64acf Make `--allow-insecure-host` a global option (#8476)
Not verifying the certificates of certain hosts should be supported for
all kinds of HTTPS connections, so we're making it a global option, just
like native tls. This fixes the remaining places using a client but were
not configuring allow insecure host.

Fixes #6983 (i think)
Closes #6983

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-11-07 14:29:54 -06:00
Charlie Marsh 633467576b Use base executable to set virtualenv Python path (#8481)
See extensive discussion in
https://github.com/astral-sh/uv/pull/8433#issuecomment-2430472849.

This PR brings us into alignment with the standard library by using
`sys._base_executable` rather than canonicalizing the executable path.

The benefits are primarily for Homebrew, where we'll now resolve to
paths like `/opt/homebrew/opt/python@3.12/bin` instead of the
undesirable
`/opt/homebrew/Cellar/python@3.9/3.9.19_1/Frameworks/Python.framework/Versions/3.9/bin`.

Most other users should see no change, though in some cases, nested
virtual environments now have slightly different behavior -- namely,
they _sometimes_ resolve to the virtual environment Python (at least for
Homebrew; not for rtx or uv Pythons though). See
[here](https://docs.google.com/spreadsheets/d/1Vw5ClYEjgrBJJhQiwa3cCenIA1GbcRyudYN9NwQaEcM/edit?gid=0#gid=0)
for a breakdown.

Closes https://github.com/astral-sh/uv/issues/1640.
Closes https://github.com/astral-sh/uv/issues/1795.
2024-11-07 14:29:54 -06:00
Zanie Blue b6c531f4dd Error when disallowed settings are defined in `uv.toml` (#8550)
These settings can only be defined in `pyproject.toml`, since they're
project-centric, and not _configuration_.

Closes https://github.com/astral-sh/uv/issues/8539.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
Co-authored-by: konsti <konstin@mailbox.org>
2024-11-07 14:29:54 -06:00
Zanie Blue 8034de7295 Treat the base Conda environment as a system environment (#7691)
Closes https://github.com/astral-sh/uv/issues/7124
Closes https://github.com/astral-sh/uv/issues/7137
2024-11-07 14:29:54 -06:00
Zanie Blue 1df8f86c22 Eliminate dependencies on `directores` and `dirs-sys` (#8048)
Migrate all directory related logic to `etcetera`, eliminated two
dependecies.
2024-11-07 14:29:54 -06:00
Zanie Blue 4874b32d85 do not imply pre-release when `!=` operator is used (#7974)
closes #6640

Could you suggest how I should test it?

(already tested locally)

---------

Co-authored-by: konstin <konstin@mailbox.org>
Co-authored-by: Charles Tapley Hoyt <cthoyt@gmail.com>
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-11-07 14:29:54 -06:00
Aditya Pratap Singh b622315a6c Improve interactions between color environment variables and CLI options (#8215)
closes #8173
2024-11-07 14:29:54 -06:00
Zanie Blue 55502842c0 Use 3.13 in CI (#8014) 2024-11-07 14:29:54 -06:00
Charlie Marsh 29e1b15473
Add `uv tree --outdated` (#8893)
## Summary

Similar to `pip list --outdated`, but for `uv tree`.

## Test Plan

Looks like:

```
foo v0.1.0
└── flask v2.0.0 (latest: v3.0.3)
    ├── click v8.1.7
    ├── itsdangerous v2.2.0
    ├── jinja2 v3.1.4
    │   └── markupsafe v3.0.2
    └── werkzeug v3.1.2
        └── markupsafe v3.0.2
```

With `(latest: v3.0.3)` in bold cyan.
2024-11-07 14:10:46 -06:00
Zanie Blue 88331e756e
Improve Python discovery source messages (#8890)
e.g.

```
❯ echo "anyio" |  cargo run -q -- pip compile - -v
DEBUG uv 0.4.30 (107ab3d71 2024-11-07)
DEBUG Starting Python discovery for a default Python
DEBUG Looking for exact match for request a default Python
DEBUG Searching for default Python interpreter in virtual environments, managed installations, or search path
DEBUG Found `cpython-3.12.7-macos-aarch64-none` at `/Users/zb/workspace/uv/.venv/bin/python3` (virtual environment)
```
```
❯ cargo run -q -- pip install anyio -v
DEBUG uv 0.4.30 (107ab3d71 2024-11-07)
DEBUG Searching for default Python interpreter in virtual environments
DEBUG Found `cpython-3.12.7-macos-aarch64-none` at `/Users/zb/workspace/uv/.venv/bin/python3` (virtual environment)
```

vs

```
❯ uv  pip install anyio -v
DEBUG uv 0.4.30 (61ed2a236 2024-11-04)
DEBUG Searching for default Python interpreter in system path
DEBUG Found `cpython-3.12.7-macos-aarch64-none` at `/Users/zb/workspace/uv/.venv/bin/python3` (virtual environment)
```

```
❯ echo "anyio" | uv pip compile - -v
DEBUG uv 0.4.30 (61ed2a236 2024-11-04)
DEBUG Starting Python discovery for a default Python
DEBUG Looking for exact match for request a default Python
DEBUG Searching for default Python interpreter in managed installations or system path
DEBUG Found `cpython-3.12.7-macos-aarch64-none` at `/Users/zb/workspace/uv/.venv/bin/python3` (virtual environment)
```
2024-11-07 14:08:49 -06:00
Adam Björnberg b4fa46bf4f
Add armv8l alias for armv7l to support arm 32-bit compatibility mode (#8881)
## Summary

`uv` commands like `uv venv` and `uv tool` throw this error when running
on arm64 in 32-bit [compatibility
mode](https://elixir.bootlin.com/linux/v6.11.6/source/arch/arm64/include/asm/compat.h#L32):
```
unknown variant `armv8l`, expected one of `aarch64`, `arm64`, `armv6l`, `armv7l`, `powerpc64le`, `ppc64le`, `powerpc64`, `ppc64`, `i386`, `i686`, `x86`, `amd64`, `x86_64`, `s390x`, `riscv64`
--- stdout:
{"result": "success", "markers": {"implementation_name": "cpython", "implementation_version": "3.11.10", "os_name": "posix", "platform_machine": "armv8l", "platform_python_implementation": "CPython", "platform_release": "6.8.0-1015-azure", "platform_system": "Linux", "platform_version": "#17-Ubuntu SMP Mon Sep  2 15:50:42 UTC 2024", "python_full_version": "3.11.10", "python_version": "3.11", "sys_platform": "linux"}, "sys_base_prefix": "/home/pi/.local/share/uv/python/cpython-3.11.10-linux-armv7-gnueabihf", "sys_base_exec_prefix": "/home/pi/.local/share/uv/python/cpython-3.11.10-linux-armv7-gnueabihf", "sys_prefix": "/home/pi/.local/share/uv/python/cpython-3.11.10-linux-armv7-gnueabihf", "sys_base_executable": "/home/pi/.local/share/uv/python/cpython-3.11.10-linux-armv7-gnueabihf/bin/python3.11", "sys_executable": "/home/pi/.local/share/uv/python/cpython-3.11.10-linux-armv7-gnueabihf/bin/python3.11", "sys_path": ["/home/pi/.cache/uv/.tmpvXy34S", "/home/pi/.local/share/uv/python/cpython-3.11.10-linux-armv7-gnueabihf/lib/python311.zip", "/home/pi/.local/share/uv/python/cpython-3.11.10-linux-armv7-gnueabihf/lib/python3.11", "/home/pi/.local/share/uv/python/cpython-3.11.10-linux-armv7-gnueabihf/lib/python3.11/lib-dynload", "/home/pi/.local/share/uv/python/cpython-3.11.10-linux-armv7-gnueabihf/lib/python3.11/site-packages"], "stdlib": "/home/pi/.local/share/uv/python/cpython-3.11.10-linux-armv7-gnueabihf/lib/python3.11", "scheme": {"platlib": "/home/pi/.local/share/uv/python/cpython-3.11.10-linux-armv7-gnueabihf/lib/python3.11/site-packages", "purelib": "/home/pi/.local/share/uv/python/cpython-3.11.10-linux-armv7-gnueabihf/lib/python3.11/site-packages", "include": "/home/pi/.local/share/uv/python/cpython-3.11.10-linux-armv7-gnueabihf/include/python3.11", "scripts": "/home/pi/.local/share/uv/python/cpython-3.11.10-linux-armv7-gnueabihf/bin", "data": "/home/pi/.local/share/uv/python/cpython-3.11.10-linux-armv7-gnueabihf"}, "virtualenv": {"purelib": "lib/python3.11/site-packages", "platlib": "lib/python3.11/site-packages", "include": "include/site/python3.11", "scripts": "bin", "data": ""}, "platform": {"os": {"name": "manylinux", "major": 2, "minor": 31}, "arch": "armv8l"}, "manylinux_compatible": true, "gil_disabled": false, "pointer_size": "32"}
--- stderr:

---
```

This is needed when building for 32-bit arm on a arm64 runner.

The `platform.machine()` function in python (which uses the `uname`
syscall) outputs`armv8l` when running in 32-bit [compatibility
mode](https://elixir.bootlin.com/linux/v6.11.6/source/arch/arm64/include/asm/compat.h#L32),
which means that the system supports armv7l binaries.

## Test Plan

Not tested :)
2024-11-07 11:42:05 -05:00
konsti 107ab3d71c
Build basic source distributions (#8886)
Very basic source distribution support. What's included:

- Include and exclude patterns (hard-coded): Currently, we have
globset+walkdir in one part and glob in the other. I'll migrate
everything to globset+walkset and some custom perf optimizations to
avoid traversing irrelevant directories on top. I'll also pick a glob
syntax (or subset), PEP 639 seems like a good candidate since it's
consistent with what we already have to support.
- Add the `PKG-INFO` file with metadata: Thanks to Code Metadata 2.2,
this metadata is reliable and can be read statically by external tools.

Example output:

```
$ tar -ztvf dist/dummy-0.1.0.tar.gz
-rw-r--r-- 0/0             154 1970-01-01 01:00 dummy-0.1.0/PKG-INFO
-rw-rw-r-- 0/0             509 1970-01-01 01:00 dummy-0.1.0/pyproject.toml
drwxrwxr-x 0/0               0 1970-01-01 01:00 dummy-0.1.0/src/dummy
drwxrwxr-x 0/0               0 1970-01-01 01:00 dummy-0.1.0/src/dummy/submodule
-rw-rw-r-- 0/0              30 1970-01-01 01:00 dummy-0.1.0/src/dummy/submodule/impl.py
-rw-rw-r-- 0/0              14 1970-01-01 01:00 dummy-0.1.0/src/dummy/submodule/__init__.py
-rw-rw-r-- 0/0              12 1970-01-01 01:00 dummy-0.1.0/src/dummy/__init__.py
```

No tests since the source distributions don't build valid wheels yet.
2024-11-07 14:29:54 +01:00
Charlie Marsh 5eba64a641
Add installer variables to environment reference (#8874)
## Summary

I decided to omit the new URL options from the installer configuration
page since they're pretty niche.
2024-11-07 07:45:06 -05:00
Noé Rubinstein eb8498d92b
docs: document how to mimic --verbose with environment variable RUST_LOG (#8858)
The doc was unclear to me and I had to dig in the code to understand
that RUST_LOG could do the same as adding `--verbose`
2024-11-07 10:24:32 +01:00
Charlie Marsh b98bdc818f
Add support for `pip list --outdated` (#8872)
## Summary

Closes https://github.com/astral-sh/uv/issues/2150.
2024-11-07 02:32:30 +00:00
Charlie Marsh 273f453e75
Use no reporter by default in `cache clean` (#8868) 2024-11-06 17:07:10 +00:00
Jo dcd24b7c42
Add progress bar for `uv cache clean` (#8857)
## Summary

Closes #8786
2024-11-06 11:43:43 -05:00
Charlie Marsh 987d778631
Respect dynamic version updates in `uv lock` (#8867)
## Summary

Closes https://github.com/astral-sh/uv/issues/8866.
2024-11-06 11:40:23 -05:00
Zanie Blue 129c6f61d4
Revert "Using `--build-backend` in `uv init` implies `--package` (#8837)" (#8850)
This reverts commit 515993c743 from
https://github.com/astral-sh/uv/pull/8837 as it was already implemented
differently in https://github.com/astral-sh/uv/pull/8593 and I missed it
2024-11-06 01:36:11 +00:00
Charlie Marsh 26e3511ebd
Respect fork markers in `--resolution-mode=lowest-direct` (#8839)
## Summary

Previously, given:

```toml
dependencies = [
    "pycountry >= 22.1.10",
    "setuptools >= 50.0.0; python_version>='3.12'"
]
```

We'd solve for the lowest version of setuptools (with _no_ lower-bound
constraint) in the `python_version < '3.12'` complement.

Closes https://github.com/astral-sh/uv/issues/8819.
2024-11-05 21:09:38 +00:00
Charlie Marsh d238642d76
Allow semicolons directly after direct URLs (#8836)
## Summary

Like pip, we now allow the semicolon to directly proceed the URL (but
require that it's either preceded or followed by a space):

```
# OK
./test.whl; sys_platform == 'darwin'

# OK
./test.whl ;sys_platform == 'darwin'

# Error
./test.whl;sys_platform == 'darwin'
```

Closes https://github.com/astral-sh/uv/issues/8831.
2024-11-05 16:07:07 -05:00
Zanie Blue 515993c743
Using `--build-backend` in `uv init` implies `--package` (#8837) 2024-11-05 14:15:55 -06:00
Charlie Marsh eeb8736448
Show dedicated error for trailing ; on URL and path requirements (#8835)
## Summary

I think we lost this error in a prior refactor. I've added an end-to-end
test too.
2024-11-05 13:29:36 -05:00
Andrew Gallant fae03a7287
uv-pep440: DRY up VersionSmall implementation (#8834)
This PR simplifies the VersionSmall implementation a bit by utilizing
more constants. That is, if the bit-level format changes, *most* of
those changes should be implementable by just changing the constants.
Previously, you would need to audit and tweak the code as well. (The
exception here is `push_release`. If the release segment bit format is
changed, then that function will need to be tweaked. I didn't think it
was worth over-complicating things to make its implementation more
general.)
2024-11-05 13:26:19 -05:00
Charlie Marsh 23ea5df76a
Warn on failure to query system configuration file (#8829)
## Summary

See: #8828.
2024-11-05 16:11:38 +00:00
Robert Deaton 177fafceb4
Enable support for arbitrary git transports (#8769) 2024-11-05 08:55:15 +01:00
Zanie Blue 61ed2a236a
Bump version to 0.4.30 (#8820) 2024-11-04 18:52:57 -06:00
konsti c39936e9c8
Publish: Hint at `--skip-existing` -> `--check-url` transition (#8803)
See https://github.com/astral-sh/uv/pull/8531#issuecomment-2442698889,
we hint users coming from twine to use `--check-url` instead.

> `uv publish` does not support `--skip-existing`, use `--check-url`
with the simple index URL instead.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-11-04 23:21:01 +00:00
Charlie Marsh f8ec7975c8
Update Packse snapshots (#8795)
## Summary

The diff here is challenging because it looks like some tests got
reordered.
2024-11-04 16:17:43 -05:00
Zanie Blue fb1d679f69
Improve interactions with existing Python executables during install (#8733)
Previously, we'd use the `--reinstall` flag to determine if we should
replace existing Python executables in the bin directory during an
install. There are a few problems with this:

- We replace executables we don't manage
- We can replace executables from other uv Python installations during
reinstall (surprising)
- We don't do the "right" thing when installing patch versions e.g.
installing `3.12.4` then `3.12.6` would fail without the reinstall flag

In `uv tool`, we have separate `--force` and `--reinstall` concepts.
Here we separate the flags (`--force` was previously just a
`--reinstall` alias) and add inspection of the existing executables to
inform a decision on replacement.

In brief, we will:

- Replace any executables with `--force`
- Replace executables for the same installation with `--reinstall`
- Replace executables for an older patch version by default
2024-11-04 20:22:44 +00:00
Zanie Blue 6a6b9af466
Fix test case on `main` (#8816) 2024-11-04 19:50:59 +00:00
Charlie Marsh a42c09fdfb
Add support for `.env` and custom env files in `uv run` (#8811)
## Summary

This PR pulls in https://github.com/astral-sh/uv/pull/8263 and
https://github.com/astral-sh/uv/pull/8463, which were originally merged
into the v0.5 tracking branch but can now be committed separately, as
we've made `.env` loading opt-in.

In summary:

- `.env` loading is now opt-in (`--env-file .env`).
- `.env` remains supported on `uv run`, so it's meant for providing
environment variables to the run command, rather than to uv itself.

---------

Co-authored-by: Eduardo González Vaquero <47718648+edugzlez@users.noreply.github.com>
2024-11-04 14:26:05 -05:00
Andrew Gallant 224622b089
uv/tests: make `python_version < '0'` regression test smaller (#8809)
Running this test manually on the latest release shows that it still
emits a `python_version < '0'` marker:

$ uv-0.4.29 pip compile requirements.in -c constraints.txt
--annotation-style line --python 3.10 --universal | rg "< '0'"
    Resolved 151 packages in 97ms
apache-airflow-providers-common-sql==1.19.0 ; python_version < '0' # via
apache-airflow-providers-sqlite

That is, even though this is a smaller test, it's still testing the same
bug.

This is about twice as fast on my machine. It's probably still worth
moving to a packse test, but this was quick to do.
2024-11-04 11:10:17 -05:00
Andrew Gallant acaed763b7 uv: use ResolverEnvironment instead of ResolverMarkers
This updates the surrounding code to use the new ResolverEnvironment
type. In some cases, this simplifies caller code by removing case
analysis. There *shouldn't* be any behavior changes here. Some test
snapshots were updated to account for some minor tweaks to error
messages.

I didn't split this up into separate commits because it would have been
too difficult/costly.
2024-11-04 11:09:06 -05:00
Andrew Gallant 44c9ef6aea uv-resolver: add new ResolverEnvironment type
This type is intended to replace `ResolverMarkers`. The main difference
between them is that this type encapsulates more decision making by
un-exporting the different cases. So instead of callers needing to do
explicit case analysis depending on the type of resolver environment,
callers instead use methods that know how to do the right thing. In the
next commit, there are at least a few cases where this greatly
simplifies case analysis on the caller side.

The motivation for this type is to centralize decision making about
forking. In particular, we want to expand forking to include conflicting
groups instead of just `MarkerTree`. So to a certain extent, the
refactor here is about removing bare use of `MarkerTree` in favor of a
more purpose built type that encapsulates the forking logic.

The encapsulation is not quite perfect here. I expect to improve on it a
bit once we add support for conflicting groups.

This is split off from the subsequent commit (that makes use of
`ResolverEnvironment`) so that it's a bit easier to review the addition
in isolation.
2024-11-04 11:09:06 -05:00
Andrew Gallant fccd48ce61 uv-normalize: add `as_str` method
`ExtraName` did implement `AsRef<str>`, but that should generally
only be used in a context with an `AsRef<str>` generic bound. If
you just want a `&str` from a concrete `ExtraName`, then a specific
method for that purpose should be used.
2024-11-04 11:09:06 -05:00
Zanie Blue 6250b900b7
Allow managed downloads with `--python-preference system` (#8808)
Closes https://github.com/astral-sh/uv/issues/8804
2024-11-04 07:45:24 -06:00
Tim de Jager d82607d038
Extend BaseClient to accept extra middleware (#8807)
This PR is a revival of #3502, albeit in a much simpler form.

This would allow for different middlewares like authentication and such,
useful for if you want to deviate from the keychain authentication
methods when using uv as a library.

@zanieb I hope I made the changes as you noted you wanted to see them :)

Happy to add/change anything you need.
2024-11-04 07:04:26 -06:00
Tim de Jager ef8724c979
Add `From` for `FlatDistributions` struct (#8800)
Co-authored-by: konsti <konstin@mailbox.org>
2024-11-04 08:41:39 +00:00
renovate[bot] a052418dcd
Update Rust crate which to v7 (#8794) 2024-11-03 21:15:17 -05:00
renovate[bot] 15d003a65f
Update Rust crate thiserror to v1.0.67 (#8790) 2024-11-03 21:14:54 -05:00
renovate[bot] a0cbf5d32b
Update Rust crate anyhow to v1.0.92 (#8787) 2024-11-03 21:14:31 -05:00
Charlie Marsh bf79d985ee
Allow incompatible `requires-python` for source distributions with static metadata (#8768)
## Summary

At present, when we have a Python requirement and we see a wheel, we
verify that the Python requirement is compatible with the wheel. For
source distributions, though, we verify that both the Python requirement
_and_ the currently-installed version are compatible, because we assume
that we'll need to build the source distribution in order to get
metadata. However, we can often extract source distribution metadata
_without_ building (e.g., if there's a `pyproject.toml` with no dynamic
keys).

This PR thus modifies the source distribution handling to defer that
incompatibility ("We couldn't get metadata for this project, because it
has no static metadata and requires a higher Python version to run /
build") until we actually try to build the package. As a result, you can
now resolve source distribution-only packages using Python versions
below their `requires-python`, as long as they include static metadata.

Closes https://github.com/astral-sh/uv/issues/8767.
2024-11-03 19:03:55 +00:00
samypr100 647494b998
docs: env var doc improvements (#8777)
## Summary

* Env docs now support anchors, which allows sending a link to someone
with a direct reference to an env var or cross-reference them in the
docs.
* Marked additional env vars as hidden from the docs due to their
internal use
* Updates some tests still using literals to use the static env vars

## Test Plan

<img width="1370" alt="env_var_anchors"
src="https://github.com/user-attachments/assets/52ae1caa-5199-4798-9eb5-81b8f5b57c24">
2024-11-03 13:56:17 -05:00
konsti f52814e729
Fix no_binary_only_binary test (#8776) 2024-11-03 15:52:14 +00:00
Jo 3dfedf1fef
Generate environment variables doc from code (#8493)
## Summary

Resolves #8417

I've just begun learning procedural macros, so this PR is more of a
proof of concept. It's still a work in progress, and I welcome any
assistance or feedback.
2024-11-03 08:31:38 -06:00
Zanie Blue 2ed94745a2
Show full error chain on tool upgrade failures (#8753)
As reported in https://github.com/astral-sh/uv/issues/8555
2024-11-02 11:55:41 -05:00
Charlie Marsh d3e50a2376
Enable `--all-packages --frozen` in `uv sync` and `uv export` (#8760)
## Summary

This PR improves the interaction of `--frozen` such that we reduce the
dependency on the `pyproject.toml` and increase the dependency on the
`uv.lock`. Specifically, we now read the list of workspace members from
the `uv.lock` rather than the `pyproject.toml`, which means we don't
need to discover the member `pyproject.toml` files in order to perform a
`uv sync --frozen --all-packages`.
2024-11-02 02:48:55 +00:00
Charlie Marsh b36ae6d5ae
Add support for `uv export --all-packages` (#8742)
## Summary

Same as the other PRs, but for `uv export`.
2024-11-02 02:25:29 +00:00
Charlie Marsh 3808b61fc1
Add support for `uv run --all-packages` (#8741)
## Summary

Closes https://github.com/astral-sh/uv/issues/8724.
2024-11-02 02:16:06 +00:00
Charlie Marsh 3c9dd97fe9
Add support for `uv sync --all-packages` (#8739)
## Summary

This PR enables `uv sync --all-packages` to sync all packages in a
workspace. It removes a common use-case for the legacy non-`[project]`
packages that we're trying to move away from.

Closes https://github.com/astral-sh/uv/issues/8724.
2024-11-02 01:55:08 +00:00
Andrew Gallant 58a9811881
fix bug where `python_version < '0'` could appear in a final resolution (#8759)
This PR fixes a bug where it was possible for dependencies to be
included in a final resolution with markers that always evaluate to
false. Specifically, `python_version < '0'`.

While we do filter based on Python markers during forking, it turns out
that the markers for each fork are "combined" *after* this filtering
step. But the process of combination can result in a more specific
marker that is always false for the configured Python requirement. This
could result in dependencies with markers that are always false (like
`python_version < '0'`) appearing in the resolution.

The first commit in this PR adds a regression test (with an undesirable
result), and the second commit fixes the regression and updates the
test.

Fixes #8676
2024-11-01 20:11:40 +00:00
Charlie Marsh f4da6ffdd6
Run `cargo update` (#8703)
Pull in https://github.com/prefix-dev/async_http_range_reader/pull/19,
removes a version of `itertools`.
2024-11-01 10:26:21 -04:00
Andrew Gallant 049ccf7d77
uv-client: switch to RFC 9110 compatible format (#8752)
This still utilizes the RFC 2822 datetime formatter, but utilizes new
methods [added in jiff 0.1.14] to emit timestamps in a format strictly
compatible with RFC 9110.

It seems like most HTTP servers were pretty flexible and supported RFC
2822 datetime formats, but #8747 shows at least one case where that
isn't true. Given that the [MDN docs prescribe RFC 9110], we defer to
them.

Fixes #8747

[added in jiff 0.1.14]: https://github.com/BurntSushi/jiff/pull/154
[MDN docs prescribe RFC 9110]:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Modified-Since
2024-11-01 09:46:24 -04:00
Charlie Marsh 40b48267e5
Include member groups when locking workspace (#8736)
## Summary

It turns out that when locking, we were only taking the groups from the
root `pyproject.toml` into account, and ignoring groups that were only
defined in a workspace member.
2024-11-01 00:04:34 +00:00
Charlie Marsh 5a46b5e52c
Avoid error for `--group` defined in non-root workspace member (#8734)
## Summary

Closes https://github.com/astral-sh/uv/issues/8722.
2024-10-31 20:11:22 +00:00
Charlie Marsh 24ad43e79c
Avoid showing dependency group annotations on workspace members in tree (#8730)
## Summary

By default, `uv tree` shows the full workspace, not _just_ the root. If
the root depended on a workspace member as a dev dependency, then we'd
still show it as `(group: dev)` in `uv tree` even if you passed
`--no-dev`, because we weren't filtering the edges in the right place.

This is still somewhat confusing, because if `root` depends on workspace
member `child` as a dev dependency, `uv tree --no-dev` still shows both.

Closes https://github.com/astral-sh/uv/issues/8719.
2024-10-31 16:09:36 -04:00
Charlie Marsh f3264583ac
Sanitize filenames during zip extraction (#8732)
## Summary

Based on the example in `async-zip`:
527bda9d58/examples/file_extraction.rs (L33)

Closes: https://github.com/astral-sh/uv/issues/8731.

## Test Plan

Created https://github.com/astral-sh/sanitize-wheel-test.
2024-10-31 19:12:51 +00:00
Zanie Blue 8d3408fe39
Add support for installing versioned Python executables on Windows (#8663)
Incorporating #8637 into #8458 

- Adds `python-managed` feature selection to Windows CI for `python
install` tests
- Adds trampoline sniffing utilities to `uv-trampoline-builder`
- Uses a trampoline to install Python executables into the `PATH` on
Windows
2024-10-31 15:58:35 +00:00
konsti f5a7d70642
Check error case for skip existing (#8631) 2024-10-31 15:37:30 +00:00
konsti 082259493e
Skip existing, second iteration: Check the index before uploading (#8531)
Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-10-31 16:23:12 +01:00
Zanie Blue b52f229862
Do not error when the Python bin directory is missing on `uv python uninstall` (#8725) 2024-10-31 14:15:47 +00:00
Zanie Blue 1b760af79d
Fix test context filtering of Python platform keys with elided patch versions (#8713)
Cherry-picked from #8650
2024-10-30 22:34:37 -05:00
Zanie Blue 85f9a0d0ec
Bump version to 0.4.29 (#8711) 2024-10-30 18:22:53 -05:00
Zanie Blue 995307767f
Clarify preview requirement for relevance of `uv python dir --bin` (#8709) 2024-10-30 21:48:34 +00:00
Zanie Blue 47eb66b138
Add test coverage for `uv python install` with invalid requests (#8708) 2024-10-30 16:38:47 -05:00
Zanie Blue 893257bb0b
Refactor `uv python install` (#8701)
Pulling out of https://github.com/astral-sh/uv/pull/8650 for
readability.

Trying to clean this up to simplify extensions in the future. This is
not a strict refactor, there are behavioral changes here.

- Adds some structs for managing state.
- Addresses some likely inconsistent behavior for weird edge-cases. 
- We fill platform information before checking if a request is
satisfied.
- We error earlier if we can't find a download for the request, i.e.,
even if you somehow have it installed.
- Only reports versions as uninstalled if a download actually replaces
them.
- Moves some of the default output to tracing messages.
- Even if an installation was already satisfied, we'll check that it is
setup properly
2024-10-30 21:28:08 +00:00
Charlie Marsh bed47d512a
Use portable paths for subdirectories in lock URLs (#8707)
## Summary

We're writing different URLs on Windows vs. Linux because the
subdirectory path is being serialized with a back vs. forward slash.
2024-10-30 15:37:40 -04:00
konsti 4a5a79eed8
Support transitive dependencies in Git workspaces (#8665)
When resolving workspace dependencies (from one workspace member to
another) from a workspace that's in git, we need to emit these
transitive dependencies as git dependencies, not path dependencies as
all other workspace deps. This fixes a bug where we would treat them as
path dependencies inside the checkout directory, leading either to
clashes (between a local path and another direct git dependency) or
invalid lockfiles (referencing the checkout dir in the lockfile when we
should be referencing the git repo).

Fixes #8087
Fixes #4920
Fixes #3936 since we needed that information anyway

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-10-30 19:12:23 +00:00
Zanie Blue 4dd36b799f
Install versioned Python executables into the bin directory during `uv python install` (#8458)
Updates `uv python install` to link `python3.x` in the executable
directory (i.e., `~/.local/bin`) to the the managed interpreter path.

Includes

- #8569 
- #8571 

Remaining work

- #8663 
- #8650 
- Add an opt-out setting and flag
- Update documentation
2024-10-30 14:13:20 +00:00
konsti 94fc35edd9
Fix feature scoping for pep508 wasm32 support for ruff (#8694) 2024-10-30 12:21:23 +00:00
konsti c1a0fb35e8
Simplify pep440 -> version ranges conversion (#8683) 2024-10-30 13:10:48 +01:00
konsti d0afd10ca4
Update windows-registry to 0.3.0 (#8696) 2024-10-30 12:00:33 +00:00
konsti 4bf01ed337
Fix non-optional uv-pep440 features (#8693) 2024-10-30 09:20:56 +00:00
Pietro Zambelli 2b0e16cb75
Fix hard and soft float libc detection for managed Python distributions on ARM (#8498) 2024-10-29 23:46:21 +00:00
Zanie Blue 6d3de9a104
Sort errors during display in `uv python install` (#8684)
This is important for determinism
2024-10-29 22:40:39 +00:00
Charlie Marsh 2e14724224
Handle cycles in `uv pip tree` (#8689)
## Summary

Porting the improvements I made to `uv tree` over to `uv pip tree`.

Closes #8678.
2024-10-29 22:18:46 +00:00
Charlie Marsh cd408cbc51
Clarify relationship between specifiers and `requires-python` range (#8688) 2024-10-29 22:30:01 +01:00
Charlie Marsh dc5e35ee5d
Fix outdated documentation on `Requires-Python` (#8679)
## Summary

Closes https://github.com/astral-sh/uv/issues/8675.
2024-10-29 20:18:43 +00:00
konsti e5b8cdba70
Merge uv-pubgrub into uv-pep440 (#8669) 2024-10-29 20:15:18 +01:00
Charlie Marsh f903cd2cce
Simplify `pip tree` tests to improve performance (#8677)
## Summary

These use really heavy test packages, like SciPy, NumPy, scikit-learn --
and packages with large dependency trees, like packse.

I removed a few redundant tests, and replaced the tests with smaller
packages.

Closes https://github.com/astral-sh/uv/issues/8674.
2024-10-29 14:59:26 -04:00
Charlie Marsh ab00a82881
Fix flaky failure in `run_from_directory` (#8673)
## Summary

See, e.g.,
https://github.com/astral-sh/uv/actions/runs/11578473249/job/32232394993.

I suspect this is some sort of timing flakiness in the cache, so let's
just clear the environment for each run.
2024-10-29 17:44:59 +00:00
Andrew Gallant 9fcc21236e
uv-resolver: simplify case analysis in ForkMap::get (#8672)
Previously, when doing a `uv pip` resolution, we would only return the
first entry in the map. But there should only ever be one entry, or else
we would have incompatible dependencies. So we can collapse the case
with the "one universal fork" case.

(I found this while doing some refactoring of how we handle forking, and
collapsing these cases simplifies some of that refactoring work.)
2024-10-29 13:38:21 -04:00
Andrew Gallant e9d962ef36
uv/tests: try harder to isolate tests from parent git repositories (#8668)
Previously, when tests were run in `~/.local/share/uv`, the behavior of
some tests could be impacted by a git repository in `~` (as on my
system). To avoid this, we set `GIT_CEILING_DIRECTORIES` to forcefully
prevent git from climbing out of its test directory to look for parent
git repositories.
2024-10-29 13:16:02 -04:00
konsti 36102dbd0e
Start using the version ranges crate (#8667) 2024-10-29 16:39:50 +00:00
Andrew Gallant a56e521179
uv-resolver: use disjointness checks instead of marker equality (#8661)
When this code was written, we didn't have "proper" disjointness checks,
and so simple equality was used instead. Arguably disjointness checks
are
more correct, and this would also simplify some case analysis in an
ongoing
refactor.
2024-10-29 11:25:18 -04:00
Zanie Blue c335dc5e5d
Add a trampoline variant that just executes `python` (#8637)
Currently, our trampoline is used to convert `<command> [args]` to
`python <command> [args]` for script entrypoints installed into virtual
environments. For #8458, it'd be nice to convert a shim `python3.12
[args]` to `python [args]`. Here, we modify the trampolines to support
this use-case.

The only change we really need here is to avoid injecting `<command>`
into the child process. We change the "magic number" at the end of the
trampoline executables from `UVUV` to `UVSC` and `UVPY` which define
"script" and "python" variants to the trampoline. We then omit the
`<command>` injection in the latter case. We also omit writing the zip
script payload.

To support construction of the new variant, a new
`uv-trampoline-builder` crate is introduced — this avoids requirements
on `uv-install-wheel` in future work. I also use `uv-trampoline-builder`
to consolidate some of the test setup for `uv-trampoline`.

There should be no backwards compatibility concerns, since trampolines
are fully self-referential.

I rebased to fix the commits at the end, as this took many iterations to
get working via CI. This should roughly be reviewable by commit if you
prefer.
2024-10-29 09:21:15 -05:00
Zanie Blue 94ae79d90d
Add riscv64 to supported Python platform tags (#8660)
Closes #8657
2024-10-29 08:48:19 -05:00
Jo d9ea307615
uv init: `--virtual` should imply `--no-package` instead (#8595)
## Summary

`uv init --virtual` should create a non-package project.
2024-10-29 09:42:14 -04:00
Charlie Marsh bf14b6a282
Respect dependency group markers in `uv export` (#8659)
## Summary

Closes https://github.com/astral-sh/uv/issues/8658.
2024-10-29 13:41:27 +00:00
konsti 9fa4fea8f2
Fix tests on main (#8655) 2024-10-29 10:46:54 +00:00
Charlie Marsh debe67ffdb
Use `dev-dependencies` and `requires-dev` for lockfile compatibility (#8599)
## Summary

Unfortunately, it looks like we lost
https://github.com/astral-sh/uv/pull/8501 somewhere in a bad rebase.
This PR re-adds the change, with compatibility for those lockfiles
created in v0.4.27. I'm not certain we should actually merge this. It
might be less painful and confusing to just bite the bullet on the
change.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-10-28 22:08:33 +00:00
Zanie Blue 4c82561488
Bump version to 0.4.28 (#8648) 2024-10-28 16:38:59 -05:00
Zanie Blue dc23a60277
Add support for requesting free-threaded builds via `+freethreaded` (#8645)
e.g., `uv python install 3.13+freethreaded` which matches the
distribution keys.
2024-10-28 15:22:49 -05:00
konsti 0044000ed3
Better trusted publishing error story (#8633) 2024-10-28 21:13:43 +01:00
Zanie Blue 18c9bc1e70
Add note about local version segments (#8646) 2024-10-28 19:52:40 +00:00
Charlie Marsh 9e851c116f
Skip Python interpreter discovery for `uv export` (#8638)
## Summary

We can skip interpreter discovery with `--frozen` in a few cases: `uv
export`, `uv tree --universal`, etc.

Closes https://github.com/astral-sh/uv/issues/8634.

## Test Plan

Before:

```
❯ uv export --python-preference only-managed --no-python-downloads
error: No interpreter found for Python 3.12 in managed installations
```

After:

```
❯ cargo run export --python-preference only-managed --no-python-downloads --frozen
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.16s
     Running `/Users/crmarsh/workspace/uv/target/debug/uv export --python-preference only-managed --no-python-downloads --frozen`
# This file was autogenerated by uv via the following command:
#    uv export --python-preference only-managed --no-python-downloads --frozen
blinker==1.8.2 \
    --hash=sha256:8f77b09d3bf7c795e969e9486f39c2c5e9c39d4ee07424be2bc594ece9642d83 \
    --hash=sha256:1779309f71bf239144b9399d06ae925637cf6634cf6bd131104184531bf67c01
click==8.1.7 \
    --hash=sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de \
    --hash=sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28
colorama==0.4.6 ; platform_system == 'Windows' \
    --hash=sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44 \
    --hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6
flask==3.0.3 \
    --hash=sha256:ceb27b0af3823ea2737928a4d99d125a06175b8512c445cbd9a9ce200ef76842 \
    --hash=sha256:34e815dfaa43340d1d15a5c3a02b8476004037eb4840b34910c6e21679d288f3
itsdangerous==2.2.0 \
    --hash=sha256:e0050c0b7da1eea53ffaf149c0cfbb5c6e2e2b69c4bef22c81fa6eb73e5f6173 \
    --hash=sha256:c6242fc49e35958c8b15141343aa660db5fc54d4f13a1db01a3f5891b98700ef
jinja2==3.1.4 \
    --hash=sha256:4a3aee7acbbe7303aede8e9648d13b8bf88a429282aa6122a993f0ac800cb369 \
    --hash=sha256:bc5dd2abb727a5319567b7a813e6a2e7318c39f4f487cfe6c89c6f9c7d25197d
markupsafe==3.0.2 \
    --hash=sha256:ee55d3edf80167e48ea11a923c7386f4669df67d7994554387f84e7d8b0a2bf0 \
    --hash=sha256:9778bd8ab0a994ebf6f84c2b949e65736d5575320a17ae8984a77fab08db94cf \
    --hash=sha256:846ade7b71e3536c4e56b386c2a47adf5741d2d8b94ec9dc3e92e5e1ee1e2225 \
    --hash=sha256:1c99d261bd2d5f6b59325c92c73df481e05e57f19837bdca8413b9eac4bd8028 \
    --hash=sha256:e17c96c14e19278594aa4841ec148115f9c7615a47382ecb6b82bd8fea3ab0c8 \
    --hash=sha256:88416bd1e65dcea10bc7569faacb2c20ce071dd1f87539ca2ab364bf6231393c \
    --hash=sha256:2181e67807fc2fa785d0592dc2d6206c019b9502410671cc905d132a92866557 \
    --hash=sha256:52305740fe773d09cffb16f8ed0427942901f00adedac82ec8b67752f58a1b22 \
    --hash=sha256:ad10d3ded218f1039f11a75f8091880239651b52e9bb592ca27de44eed242a48 \
    --hash=sha256:0f4ca02bea9a23221c0182836703cbf8930c5e9454bacce27e767509fa286a30 \
    --hash=sha256:8e06879fc22a25ca47312fbe7c8264eb0b662f6db27cb2d3bbbc74b1df4b9b87 \
    --hash=sha256:ba9527cdd4c926ed0760bc301f6728ef34d841f405abf9d4f959c478421e4efd \
    --hash=sha256:f8b3d067f2e40fe93e1ccdd6b2e1d16c43140e76f02fb1319a05cf2b79d99430 \
    --hash=sha256:569511d3b58c8791ab4c2e1285575265991e6d8f8700c7be0e88f86cb0672094 \
    --hash=sha256:15ab75ef81add55874e7ab7055e9c397312385bd9ced94920f2802310c930396 \
    --hash=sha256:f3818cb119498c0678015754eba762e0d61e5b52d34c8b13d770f0719f7b1d79 \
    --hash=sha256:cdb82a876c47801bb54a690c5ae105a46b392ac6099881cdfb9f6e95e4014c6a \
    --hash=sha256:cabc348d87e913db6ab4aa100f01b08f481097838bdddf7c7a84b7575b7309ca \
    --hash=sha256:444dcda765c8a838eaae23112db52f1efaf750daddb2d9ca300bcae1039adc5c \
    --hash=sha256:bcf3e58998965654fdaff38e58584d8937aa3096ab5354d493c77d1fdd66d7a1 \
    --hash=sha256:e6a2a455bd412959b57a172ce6328d2dd1f01cb2135efda2e4576e8a23fa3b0f \
    --hash=sha256:b5a6b3ada725cea8a5e634536b1b01c30bcdcd7f9c6fff4151548d5bf6b3a36c \
    --hash=sha256:a904af0a6162c73e3edcb969eeeb53a63ceeb5d8cf642fade7d39e7963a22ddb \
    --hash=sha256:4aa4e5faecf353ed117801a068ebab7b7e09ffb6e1d5e412dc852e0da018126c \
    --hash=sha256:c0ef13eaeee5b615fb07c9a7dadb38eac06a0608b41570d8ade51c56539e509d \
    --hash=sha256:d16a81a06776313e817c951135cf7340a3e91e8c1ff2fac444cfd75fffa04afe \
    --hash=sha256:6381026f158fdb7c72a168278597a5e3a5222e83ea18f543112b2662a9b699c5 \
    --hash=sha256:3d79d162e7be8f996986c064d1c7c817f6df3a77fe3d6859f6f9e7be4b8c213a \
    --hash=sha256:131a3c7689c85f5ad20f9f6fb1b866f402c445b220c19fe4308c0b147ccd2ad9 \
    --hash=sha256:ba8062ed2cf21c07a9e295d5b8a2a5ce678b913b45fdf68c32d95d6c1291e0b6 \
    --hash=sha256:e444a31f8db13eb18ada366ab3cf45fd4b31e4db1236a4448f68778c1d1a5a2f
werkzeug==3.0.6 \
    --hash=sha256:a8dd59d4de28ca70471a34cba79bed5f7ef2e036a76b3ab0835474246eb41f8d \
    --hash=sha256:1bc0c2310d2fbb07b1dd1105eba2f7af72f322e1e455f2f93c993bee8c8a5f17
```
2024-10-28 15:00:08 -04:00
Charlie Marsh bfa84cd1ab
Fork when minimum Python version increases (#8628)
## Summary

This is a re-implementation of
https://github.com/astral-sh/uv/pull/4712, though is now seemingly much
simpler. This issue keeps coming up, and users have a workaround with
`tool.uv.environments`, but it's really a bug in the resolver.

Closes https://github.com/astral-sh/uv/issues/4668.
2024-10-28 09:48:04 -04:00
konsti 635223ef00
Hint about missing trusted publishing permission (#8632) 2024-10-28 11:26:46 +00:00
Simon Willison 572840dfe2
Update CLI documentation for `--cache-dir` (#8627)
Refs:
- #8626

## Summary

Current documentation incorrectly suggests that the macOS cache
directory location is `$HOME/Library/Caches/uv`, but that changed in:

- #5806

Updates docs to say this instead:

> <p>Defaults to <code>$HOME/.cache/uv</code> on macOS,
<code>$XDG_CACHE_HOME/uv</code> or <code>$HOME/.cache/uv</code> on
Linux, and <code>%LOCALAPPDATA%\uv\cache</code> on Windows. The <code>uv
cache dir</code> command will show the location of the cache
directory.</p>

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-10-28 02:01:21 +00:00
renovate[bot] be92a2bbef
Update Rust crate thiserror to v1.0.65 (#8618) 2024-10-28 01:06:22 +00:00
renovate[bot] 0a83f957fb
Update Rust crate anyhow to v1.0.91 (#8612) 2024-10-27 20:56:33 -04:00
Charlie Marsh 001d00ba26
Remove inverse-node tracking in `uv tree` (#8610)
## Summary

Just simplifying some of the representations.
2024-10-27 20:44:32 -04:00
Tim Chan 4caa1586fd
feat: add environment variable to disable progress output (#8600)
The changes in this commit introduce the `UV_NO_PROGRESS` environment
variable as an alternative way to control progress output suppression in
uv-cli, equivalent to using the `--no-progress` flag. This enhancement
simplifies configuration in CI environments and automated scripts by
eliminating the need to detect whether the script is running in a CI
environment.

Previously, disabling progress output required either passing the
`--no-progress` flag directly or implementing script logic to detect CI
environments and conditionally add the flag. With this change, users can
now simply set `UV_NO_PROGRESS=true` in their environment to achieve the
same effect.

The changes include:

- Adding the `UV_NO_PROGRESS` environment variable to the `EnvVars`
struct in `crates/uv-static/src/env_vars.rs`.
- Updating the `GlobalArgs` struct in `crates/uv-cli/src/lib.rs` to
include a new `no_progress` field that is bound to the `UV_NO_PROGRESS`
environment variable.
- Adding documentation for the new `UV_NO_PROGRESS` environment variable
in `docs/configuration/environment.md`.
## Test Plan

After creating a uv project using `uv init` in a temp directory in this
project:
```
cargo run cache clean && cargo run venv && UV_NO_PROGRESS=false cargo run sync 
cargo run cache clean && cargo run venv && cargo run sync  
```
produce the expected default behavior 

```
cargo run cache clean && cargo run venv && UV_NO_PROGRESS=false cargo run sync  
```
produces the same behavior as having the `--no-progress` flag.
2024-10-27 15:14:12 -04:00
Vivien Maisonneuve 1e1b6ce186
Set `LC_ALL=C` in test commands (#8606) 2024-10-27 14:24:41 +00:00
Vivien Maisonneuve c648150ff0
Remove unneeded `return` from Maturin project template (#8604)
## Summary

This PR removes an unnecessary `return` statement from Rust code in the
Maturin template. This makes the generated code more idiomatic and
prevents a Clippy warning.

## Test Plan

This change was tested both in unit tests and by manually creating a
Maturin project.
2024-10-27 09:15:27 -05:00
Zanie Blue a09415f008
Fix Python install path in tests (#8578)
The shared arguments were resetting the `UV_PYTHON_INSTALL_DIR`,
breaking the intent of the test.

Added some uninstall tests too, needed later for #8571
2024-10-26 20:56:51 -05:00
Charlie Marsh f23d9c1a21
Support cyclic dependencies in `uv tree` (#8564)
## Summary

Closes https://github.com/astral-sh/uv/issues/8551.
2024-10-26 13:30:42 -04:00
Charlie Marsh 5ef0e6c838
Ignore empty groups when validating lock (#8598)
## Summary

It turns out we were omitting empty dependency groups from the lockfile
metadata, which was then causing us to reject locks when empty groups
were defined.

We now include them (that section of the lock is meant to be a true
representation of the metadata, and an empty-but-defined group is
different from an absent group), though we can ignore them for
validation, since it doesn't affect any behavior.

Closes https://github.com/astral-sh/uv/issues/8581.
2024-10-26 17:29:07 +00:00
Magnus Markling 084ad2ed2b
Remove duplicate word in error message (#8589)
## Summary

Remove duplicate word ("because" ) in error message.

## Test Plan

I ran all the tests locally.
2024-10-26 11:10:00 -05:00
Jo 0b02a8c28b
uv init: Implies `--package` when using `--build-backend` (#8593)
## Summary

Closes #8568
2024-10-26 09:51:16 -05:00
Charlie Marsh d362e03a81
Add more tests for non-`[project]` groups (#8575) 2024-10-25 19:08:29 +00:00
Charlie Marsh 36b729e927
Add error message when `uv build` is used with non-packaged projects (#8537)
## Summary

Closes https://github.com/astral-sh/uv/issues/8530.
2024-10-25 15:06:46 -04:00
Zanie Blue 4727acbc62
Bump version to 0.4.27 (#8573) 2024-10-25 19:06:06 +00:00
Charlie Marsh dd0f696695
Allow `[dependency-groups]` in non-`[project]` projects (#8574)
## Summary

We already support `tool.uv.dev-dependencies` in the legacy
non-`[project]` projects. This adds equivalent support for
`[dependency-groups]`, e.g.:

```toml
[tool.uv.workspace]

[dependency-groups]
lint = ["ruff"]
```
2024-10-25 13:57:06 -05:00
Zanie Blue 73544098f3 Add a few more test cases for `default-groups` (#8572) 2024-10-25 13:27:37 -05:00
Zanie Blue 8262e91e2f Update reference documentation for PEP 735 (#8567)
Updates the CLI and setting documentation to reflect the PEP 735
changes.
2024-10-25 13:27:37 -05:00
Charlie Marsh 07b6887c08 Add to `dependency-groups.dev` in `uv add --dev` (#8570)
## Summary

`uv add --dev` now updates the `dependency-groups.dev` section, rather
than `tool.uv.dev-dependencies` -- unless the dependency is already
present in `tool.uv.dev-dependencies`.

`uv remove --dev` now removes from both `dependency-groups.dev` and
`tool.uv.dev-dependencies`.

`--dev` and `--group dev` are now treated equivalently in `uv add` and
`uv remove`.
2024-10-25 13:27:37 -05:00
Charlie Marsh 810b430031 Add `--no-group` support to CLI (#8477)
## Summary

Now that `default-groups` can include more than just `"dev"`, it makes
sense to allow users to remove groups with `--no-group`.
2024-10-25 13:27:37 -05:00
Charlie Marsh 291c4c496d Add support for `default-groups` (#8471)
This PR adds support for `tool.uv.default-groups`, which defaults to
`["dev"]` for backwards-compatibility. These represent the groups we
sync by default.
2024-10-25 13:27:37 -05:00
Charlie Marsh 2e028cd3b6 Rewrite some references to "optional groups" (#8454)
## Summary

We generally want to avoid references to "optional groups" now that
dependency groups are a first-class, standardized concept.
2024-10-25 13:27:37 -05:00
Charlie Marsh 5ab860be20 Rename dev dependencies to dependency groups in lockfile (#8391)
This is backwards compatible (we respect `dev-dependencies` as an
alias).

Part of https://github.com/astral-sh/uv/pull/8272.
2024-10-25 13:27:37 -05:00
Charlie Marsh c7ccf88939 Error when --group includes non-existent groups (#8394)
## Summary

Part of https://github.com/astral-sh/uv/pull/8272.
2024-10-25 13:27:37 -05:00
Charlie Marsh 4d134a4ffe Error on duplicate PEP 735 dependency groups (#8390)
## Summary

Part of: https://github.com/astral-sh/uv/pull/8272.
2024-10-25 13:27:37 -05:00
Charlie Marsh 384f4459a1 Check dependency groups for credentials (#8393)
## Summary

We have to iterate over all user-defined dependencies here. We were
missing the new `[dependency-groups]` section.

Part of https://github.com/astral-sh/uv/pull/8272.
2024-10-25 13:27:37 -05:00
Zanie Blue 1bee82329c Add `--group`, `--only-group`, and `--only-dev` support to `uv tree` (#8338)
Part of #8090

Most of the heavy lifting is done in #8309

Includes `--only-dev` which appears to be missing as an oversight.
2024-10-25 13:27:37 -05:00
Zanie Blue a71a0674f0 Add `--group` and `--only-group` to `uv export` (#8332)
Part of #8090

Most of the heavy lifting is done in #8309
2024-10-25 13:27:37 -05:00
Zanie Blue 39ca57f3c8 Add `--group` and `--only-group` to `uv run` (#8274)
Similar to #8110

Part of #8090
2024-10-25 13:27:37 -05:00
Zanie Blue d2e1f180ef Refactor development dependency configuration (#8309)
Part of #8090
Unblocks https://github.com/astral-sh/uv/pull/8274

Refactors `DevMode` and `DevSpecification` into a shared type
`DevGroupsSpecification` that allows us to track if `--dev` was
implicitly or explicitly provided.
2024-10-25 13:27:37 -05:00
Zanie Blue fc2e79c6ce Add support for reading and resolving `include-group` in dependency groups (#8266)
Part of #8090

Adds the ability to read group inclusions (`include-group = <name>`) in
the `pyproject.toml`. Resolves groups into concrete dependencies for
resolution.

See https://github.com/astral-sh/uv/pull/8110 for a bit more commentary
on deferred work.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-10-25 13:27:37 -05:00
Zanie Blue 2dc4fd0a19 Add `--group` and `--only-group` to `uv sync` and includes all groups in `uv lock` (#8110)
Part of #8090

Adds the ability to include a group (`--group`) in the sync or _only_
sync a group (`--only-group`). Includes all groups in the resolution,
which will have the same limitations as extras as described in #6981.

There's a great deal of refactoring of the "development" concept into
"groups" behind the scenes that I am continuing to defer here to
minimize the diff.

Additionally, this does not yet resolve interactions with the existing
`dev` group — we'll tackle that separately as well. I probably won't
merge the stack until that design is resolved. The current proposal is
that we'll just "combine' the `dev-dependencies` contents into the `dev`
group.
2024-10-25 13:27:37 -05:00
Zanie Blue 4c0590ff6f Add `--group` support to `uv add` and `uv remove` (#8108)
Part of #8090

Adds the ability to add and remove dependencies from arbitrary groups
using `uv add` and `uv remove`. Does not include resolving with the new
dependencies — tackling that in #8110.

Additionally, this does not yet resolve interactions with the existing
`dev` group — we'll tackle that separately as well. I probably won't
merge the stack until that design is resolved.
2024-10-25 13:27:37 -05:00
Zanie Blue 3c9d783e09 Add support for reading PEP 735 dependency groups (#8104)
Part of #8090

As a basic first step, we parse these groups defined in `pyproject.toml`
files.
2024-10-25 13:27:37 -05:00
Nathan McDougall d2cd09bbd7
Update docs for `--publish-url` to avoid duplication. (#8561)
## Summary

These two sentences in the docs for `--publish-url` seem to basically be
duplicates:


3eda248ef5/crates/uv-cli/src/lib.rs (L4616-L4618)

I found the first to be easier to read, so this commit removes the
second.

## Test Plan

No tests, change is docs-only.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-10-25 13:55:33 +00:00
konsti 3eda248ef5
Always attach URL to network errors (#8444) 2024-10-25 09:10:18 +00:00
Charlie Marsh 58b5fd4aff
Add `tool.uv.sources` to the "Settings" reference (#8543)
## Summary

Closes https://github.com/astral-sh/uv/issues/8540.
2024-10-24 23:17:50 +00:00
Charlie Marsh 99a87464eb
Avoid duplicate `[tool.uv]` header in TOML examples (#8545)
## Summary

For example, in:

```toml
[tool.uv]
[[tool.uv.index]]
name = "pytorch"
url = "https://download.pytorch.org/whl/cu121"
```

We can just omit `[tool.uv]`.
2024-10-24 21:10:01 +00:00
Charlie Marsh f4a3f97fe0
Fix dangling non-platform dependencies in `uv tree` (#8532)
## Summary

We were including dependencies that were only included by a dependency
that isn't relevant on the current platform (i.e., we were enforcing the
"current environment" at one level, but not transitively).

Closes https://github.com/astral-sh/uv/issues/8516.
2024-10-24 16:39:00 +00:00
Charlie Marsh 2651aee33f
Enforce lockfile schema versions (#8509)
## Summary

Historically, we haven't enforced schema versions. This PR adds a
versioning policy such that, if a uv version writes schema v2, then...

- It will always reject lockfiles with schema v3 or later.
- It _may_ reject lockfiles with schema v1, but can also choose to read
them, if possible.

(For example, the change we proposed to rename `dev-dependencies` to
`dependency-groups` would've been backwards-compatible: newer versions
of uv could still read lockfiles that used the `dev-dependencies` field
name, but older versions should reject lockfiles that use the
`dependency-groups` field name.)

Closes https://github.com/astral-sh/uv/issues/8465.
2024-10-24 12:23:56 -04:00
Zanie Blue b713877bdc
Add basic testing of managed Python installs (#8462)
With a change like https://github.com/astral-sh/uv/pull/8458, we really
need tests for these.

I'm just going to take the possible performance hit of these slow tests
and deal with optimizing them separately.
2024-10-24 11:18:20 -05:00
konsti 6caeb6aba1
Don't allow non-string email in authors (#8520) 2024-10-24 15:25:52 +00:00
Jo 41462e5987
Fix a typo in `fetch-download-metadata.py` (#8515)
Fix this typo:

98523e2014/crates/uv-python/fetch-download-metadata.py (L399)

and removed an empty line in the `downloads.inc.mustache" template.
2024-10-24 07:33:14 -05:00
Andrey Bozhko b6883ed7fb
Fix typo in description of `--strict` flag (#8513)
<!--
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

<!-- What's the purpose of the change? What does it do, and why? -->
Fix the flag description: `to detect and with` --> `to detect packages
with`
2024-10-24 07:21:56 -05:00
tfsingh 98523e2014
Add support for `--dry-run` mode in `uv lock` (#7783)
This PR adds support for `uv lock --dry-run`, as described in issue
#6408.

One thing to note: this functionality, as implemented, isn't limited to
`-U` (if someone adds a dependency to the project's `pyproject.toml`,
the plan will include these changes).

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-10-24 03:21:55 +00:00
Charlie Marsh ede47c0793
Document `.netrc` environment variable and path (#8511)
## Summary

Closes https://github.com/astral-sh/uv/issues/8482.
2024-10-24 02:34:45 +00:00
Charlie Marsh 1b9b9d56b3
Bump version to v0.4.26 (#8508) 2024-10-23 15:17:49 -04:00
Jo 9540d6ad24
Use reinstall report formatting for `uv python install --reinstall` (#8487)
## Summary

Resolves #8456

## Test Plan

```console
$ cargo run -- python install 3.13
$ cargo run -- python install --reinstall 3.13
Searching for Python versions matching: Python 3.13
Found existing installation for Python 3.13: cpython-3.13.0-macos-aarch64-none
Installed Python 3.13.0 in 7.39s
 ~ cpython-3.13.0-macos-aarch64-none
```

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-10-23 18:53:33 +00:00
Charlie Marsh e9c08b1639
Rewrite `uv tree` to allow arbitrary `--package` includes (#8507)
## Summary

Previously, `uv tree --package` had some strange behavior due to how we
were computing the root nodes. This PR refactors the entire
implementation to use `petgraph` so we can do proper operations on a
graph structure.

Closes https://github.com/astral-sh/uv/issues/8382.
2024-10-23 18:43:26 +00:00
Jo 56f93d9cfc
`uv python install`: remove the existing version only after the new installation is downloaded successfully (#8485)
## Summary

This PR delays the removal of an existing version after downloading the
new version when running `uv python install --reinstall`.

If the download fails, we can keep the existing version working.

## Test Plan

```console
$ cargo run -- python install 3.13
$ cargo run -- python install --reinstall 3.13 # when downloading, `ctrl-c` to interrupt
$ cargo run -- python list
```
2024-10-23 14:43:09 -04:00
Charlie Marsh 9ca1f0003f
Fix `uv add` comment handling for empty arrays (#8504)
## Summary

Closes https://github.com/astral-sh/uv/issues/8496.
2024-10-23 16:14:58 +00:00
Charlie Marsh 72185baf70
Avoid rewriting `[[tool.uv.index]]` entries when credentials are provided (#8502)
## Summary

Instead of creating a new entry, we should reuse the existing entry (to
preserve decor); similarly, we should avoid overwriting fields that are
already "correct".

Closes https://github.com/astral-sh/uv/issues/8483.
2024-10-23 10:57:13 -04:00
Charlie Marsh 29193acc67
Improve error message for cache info serialization (#8500)
## Summary

We no longer need this struct; we bumped the cache bucket version
anyway, so the `Timestamp` variant is never encountered. This means we
get real Serde error messages.

Closes https://github.com/astral-sh/uv/issues/8488.
2024-10-23 13:17:31 +00:00
Charlie Marsh cc734ea2b6
Allow dependency metadata entries for direct URL requirements (#7846)
## Summary

This is part of making
https://github.com/astral-sh/uv/issues/7299#issuecomment-2385286341
better. You can now use `tool.uv.dependency-metadata` for direct URL
requirements. Unfortunately, you _must_ include a version, since we need
one to perform resolution.
2024-10-22 22:01:23 -04:00
Ahmed Ilyas 82df00a917
Support `--with-editable` in `uv tool install` (#8472)
## Summary

Closes https://github.com/astral-sh/uv/issues/7528

## Test Plan

`cargo test`

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-10-23 00:06:33 +00:00
Ahmed Ilyas 21b9254949
Suggest `--from` command when executable is available for `uvx` (#8473)
## Summary

Closes https://github.com/astral-sh/uv/issues/8319

## Test Plan

`cargo test`

<img width="545" alt="Screenshot 2024-10-22 at 20 17 35"
src="https://github.com/user-attachments/assets/286e0168-7f25-4c85-86a3-23c8bb66a5ff">
2024-10-22 14:16:10 -05:00
Zanie Blue 2f6fa082c4
Add `uv-dirs` to consolidate directory lookup methods (#8453)
I need the executable directory outside `uv-tool` and figured I should
consolidate these to a central location.
2024-10-22 11:33:25 -05:00
Charlie Marsh ff3ed3b797
Add type-based validation for index names (#8464)
## Summary

Also documents the normalization scheme.
2024-10-22 16:10:20 +00:00
Charlie Marsh 399d5ab50a
Replace dashes with underscores in index credential variables (#8452)
## Summary

Closes https://github.com/astral-sh/uv/issues/8448.
2024-10-22 09:37:55 -04:00
konsti 9a8ff85083
Don't build the maturin test (#8447) 2024-10-22 12:17:28 +00:00
konsti e7ae0f50d2
Respect allow insecure host in publish (#8440) 2024-10-22 13:36:18 +02:00
konsti 0dd4d017e3
Link to Dependency specifiers instead of PEP 508 (#8411)
The canonical source is
https://packaging.python.org/en/latest/specifications/dependency-specifiers/,
not PEP 508 anymore, so we should link there and use the new name.
2024-10-21 14:43:38 -04:00
Amjith Ramanujam 351ad84eaf
Add support for system-level `uv.toml` configuration (#7851)
## Summary

Look for a system level uv.toml config file under `/etc/uv/uv.toml` or
`C:\ProgramData`.

This PR is to address #6742 and start a conversation. 

## Test Plan

This was tested locally manually on MacOS. I am happy to contribute
tests once we settle on the approach.

cc @thatch

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-10-21 17:33:02 +00:00
kkdamowang ec8eee0fde
Fix navigators in crates/README.md (#8408) 2024-10-21 10:45:07 +02:00
Charlie Marsh 3542251c76
Apply narrowing with upper bounds (#8403)
## Summary

If the user has an upper-bound in a `requires-python`, we don't
correctly narrow it during resolution. We should be narrowing based on
the intersection.

Closes #8297.
2024-10-21 01:03:50 +00:00
Charlie Marsh 97eb6ab4aa
Bump version to v0.4.25 (#8402) 2024-10-21 00:37:50 +00:00
renovate[bot] 159b664f95
Update Rust crate anyhow to v1.0.90 (#8395) 2024-10-21 00:10:22 +00:00
Alexander Gherm 823ee8fcb0
Modify pip list and tree to print to stdout regardless of the --quiet flag (#8392)
## Summary

The desired behavior for `uv tree` and `uv pip list` with `-q | --quiet`
flag is
https://github.com/astral-sh/uv/issues/8379#issuecomment-2425093709 to
still produce output. This is implemented here.

Closes https://github.com/astral-sh/uv/issues/8379

## Test Plan

Use `uv tree -q` or `uv pip list -q` on any uv project setup and expect
the corresponding output.
Added tests for that as well.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-10-20 23:24:34 +00:00
Charlie Marsh 6ff674f5bf
Use correct indentation when project table contains open bracket comment (#8387)
## Summary

Now, we use four space (rather than one space) for cases like:

```toml
dependencies = [ # comment 0
    # comment 1
    "anyio==3.7.0", # comment 2
    # comment 3
]
```
2024-10-20 15:56:36 -04:00
Charlie Marsh 7e2822d694
Avoid panic when Git dependencies are included in fork markers (#8388)
## Summary

Rather than relying on the distribution and package URL being the same
(which isn't true for Git dependencies), we can just use the
intersection of the markers directly.

Closes https://github.com/astral-sh/uv/issues/8381.
2024-10-20 18:42:21 +00:00
Zanie Blue ab16bf0a8c
Set `UV_LINK_MODE=copy` for Windows test runs (#8350)
Cherry-picked from #8347 

Might fix https://github.com/astral-sh/uv/issues/6940 — I'm not seeing a
failure over there after this change. I think there may be some problem
with concurrent reads of junctioned files on the DevDrive? It's really
hard to say.

We might lose some important test coverage with this change. I'm not
sure what to do about that either.
2024-10-20 13:37:41 -05:00
Zanie Blue be26e47d2f
Log unfiltered snapshots on failure (#8349)
Cherry-picked from https://github.com/astral-sh/uv/pull/8347

Seems generally really helpful to see the unfiltered snapshot when a
test fails. Especially when debugging filters on Windows.
2024-10-20 13:37:29 -05:00
InSync 93f3316c88
Fix typos in new `uv self` help messages (#8376)
[Originally
reported](https://discord.com/channels/1039017663004942429/1060247592765759518/1297405236599591004)
by dice on Discord.
2024-10-20 13:20:04 -04:00
Alexander Gherm 20053f3aa7
Fix to respect comments positioning in pyproject.toml on change (#8384)
## Summary

This PR is is to address the problem when the same-line comments in
`pyproject.toml` could be found in unpredictable positions after `uv
add` or `remove` reformats the `pyproject.toml` file.

Introduced the `Comment` structure in `pyproject_mut` module to
distinguish "same-line" comments and "full-line" comments while
reformatting, because logic for them differs.
Sorry, the implementation could be clumsy, I'm just learning Rust, but
it seems to work 😅

Closes https://github.com/astral-sh/uv/issues/8343

## Test Plan

Added the new test:
`add_preserves_comments_indentation_and_sameline_comments`

To test followed the actions from the issue ticket
https://github.com/astral-sh/uv/issues/8343

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-10-20 17:16:13 +00:00
Charlie Marsh e9f1161b95
Modify cache versioning to support backwards compatibility (#8386)
## Summary

Going forward, we're going to provide better versioning guarantees
around using the same cache across multiple uv versions, so this PR
updates the docs to reflect that. It also bumps the `sdists-` version to
fix the inconvenience demonstrated in
https://github.com/astral-sh/uv/issues/8367.

Closes https://github.com/astral-sh/uv/issues/8367.
2024-10-20 16:48:04 +00:00
Jo 842ef12017
Log netrc parsing error (#8364)
## Summary

Resolves #7685

## Test Plan

```console
$ echo "this is an invalid netrc" > .netrc
$ NETRC=.netrc cargo run -- pip install anyio --index-url https://pypi-proxy.fly.dev/basic-auth/simple --strict -v
DEBUG uv 0.4.24 (f4d5fba61 2024-10-19)
DEBUG Searching for default Python interpreter in system path or `py` launcher
DEBUG Found `cpython-3.11.2-windows-x86_64-none` at `D:\Projects\Rust\uv\.venv\Scripts\python.exe` (virtual environment)
DEBUG Using Python 3.11.2 environment at .venv
DEBUG Acquired lock for `.venv`
DEBUG At least one requirement is not satisfied: anyio
DEBUG Using request timeout of 30s
DEBUG Solving with installed Python version: 3.11.2
DEBUG Solving with target Python version: >=3.11.2
DEBUG Adding direct dependency: anyio*
DEBUG No cache entry for: https://pypi-proxy.fly.dev/basic-auth/simple/anyio/
WARN Error reading netrc file: parsing error: bad toplevel token 'this' (line 1) in the file '.netrc'
DEBUG Searching for a compatible version of anyio (*)
DEBUG No compatible version found for: anyio
  × No solution found when resolving dependencies:
  ╰─▶ Because anyio was not found in the package registry and you require anyio, we can conclude that your
      requirements are unsatisfiable.

      hint: An index URL (https://pypi-proxy.fly.dev/basic-auth/simple) could not be queried due to a lack of valid
      authentication credentials (401 Unauthorized).
DEBUG Released lock at `D:\Projects\Rust\uv\.venv\.lock`
error: process didn't exit successfully: `target\debug\uv.exe pip install anyio --index-url https://pypi-proxy.fly.dev/basic-auth/simple --strict -v` (exit code: 1)

```
2024-10-20 12:27:44 -04:00
Zanie Blue fff2094a35
Use a dedicated message for incompatible Python versions in wheel ABI tags (#8363)
Part of https://github.com/astral-sh/uv/issues/2777

I noticed we're seeing "Python ABI" _a lot_ in error messages which I
did not expect. This improves a common case by being a little more
specific.
2024-10-20 12:14:11 -04:00
Jo bcc52ed108
Add `uv pip show --files` (#8369)
## Summary

Resolves #8357
2024-10-20 12:13:41 -04:00
Zanie Blue 05a56dab61
Copy the workspace examples into test contexts (#8348)
Cherry-picked from https://github.com/astral-sh/uv/pull/8347

Per [this
flake](https://github.com/astral-sh/uv/actions/runs/11411928073/job/31757053523?pr=8347)
it doesn't solve the problem unfortunately. Still seems like best
practice.
2024-10-20 12:11:52 -04:00
Jo e980c1b0f8
Only remove a source from `[tool.uv.sources]` if it is no long being referenced (#8366)
## Summary

Resolves #8361
2024-10-19 10:52:01 -05:00
Jo ca55793a90
Remove `tool.uv.sources` table if it is empty (#8365)
## Summary

Resolves #8362
2024-10-19 15:20:45 +00:00
Zanie Blue 4355392c82
Add a `uv remove` test where a dependency is repeated (#8360) 2024-10-19 14:33:54 +00:00
Jo ac451af1bd
Check existing source by normalized name before add and remove (#8359)
Resolves #8328
Resolves #8330
2024-10-19 08:26:01 -05:00
Zanie Blue 4b0a4dadb7
Fix bug where username from authentication cache could be ignored (#8345)
Basically, if username-only authentication came from the _cache_ instead
of being present on the _request URL_ to start, we'd end up ignoring it
during password lookups which breaks keyring.

Includes some cosmetic changes to the logging and commentary in the
middleware, because I was confused when reading the code and logs.
2024-10-18 18:45:31 -05:00
konsti e26eed10e4
Better missing self update feature (#8337) 2024-10-18 17:38:34 +00:00
Charlie Marsh d53d580221
Add support for `UV_FROZEN` and `UV_LOCKED` (#8340)
## Summary

Closes https://github.com/astral-sh/uv/issues/8321.
2024-10-18 13:37:49 -04:00
Vini Brasil 69d5e084d5
Allow dashes and underscores in custom index names (#8339)
Previously, `uv add --index` command threw an error when the index name
included characters like hyphens or underscores.

Closes #8315
2024-10-18 13:24:16 -04:00
konsti c162078050
Add cfg for other external resources tests (#8320)
Fixes #8295
2024-10-18 12:30:11 -04:00
Zanie Blue 42dac85bf7
Remove commands available in the top-level from the suggested subcommand error (#8316)
Part of https://github.com/astral-sh/uv/issues/8313

I think we'll need to open an issue upstream to add more context to the
error here, because there's not sufficient information about the parent
command to provide a good error message. As a first step, let's avoid
giving these suggestions for subcommands that overlap with our top-level
commands.. because that's just confusing.

Here's all the information we have here

```rust
[crates/uv/src/lib.rs:1530:13] &err = ErrorInner {
    kind: InvalidSubcommand,
    context: FlatMap {
        keys: [
            InvalidSubcommand,
            Usage,
        ],
        values: [
            String(
                "remove",
            ),
            StyledStr(
                StyledStr(
                    "\u{1b}[1m\u{1b}[32mUsage:\u{1b}[0m \u{1b}[1m\u{1b}[36muv python\u{1b}[0m \u{1b}[36m[OPTIONS]\u{1b}[0m \u{1b}[36m<COMMAND>\u{1b}[0m",
                ),
            ),
        ],
    },
    message: None,
    source: None,
    help_flag: Some(
        "--help",
    ),
    styles: Styles {
        header: Style {
            fg: Some(
                Ansi(
                    Green,
                ),
            ),
            bg: None,
            underline: None,
            effects: Effects(BOLD),
        },
        error: Style {
            fg: Some(
                Ansi(
                    Red,
                ),
            ),
            bg: None,
            underline: None,
            effects: Effects(BOLD),
        },
        usage: Style {
            fg: Some(
                Ansi(
                    Green,
                ),
            ),
            bg: None,
            underline: None,
            effects: Effects(BOLD),
        },
        literal: Style {
            fg: Some(
                Ansi(
                    Cyan,
                ),
            ),
            bg: None,
            underline: None,
            effects: Effects(BOLD),
        },
        placeholder: Style {
            fg: Some(
                Ansi(
                    Cyan,
                ),
            ),
            bg: None,
            underline: None,
            effects: Effects(),
        },
        valid: Style {
            fg: Some(
                Ansi(
                    Green,
                ),
            ),
            bg: None,
            underline: None,
            effects: Effects(),
        },
        invalid: Style {
            fg: Some(
                Ansi(
                    Yellow,
                ),
            ),
            bg: None,
            underline: None,
            effects: Effects(),
        },
    },
    color_when: Auto,
    color_help_when: Auto,
    backtrace: None,
}
```
2024-10-18 10:57:07 -05:00
konsti 6b8f447387
Make `lock_multiple_sources` stable over time (#8336) 2024-10-18 15:51:51 +00:00
Charlie Marsh a459052f44
Redact index sources in `uv.lock` (#8333)
## Summary

Closes https://github.com/astral-sh/uv/issues/8296.
2024-10-18 11:20:15 -04:00
konsti 23c80c547c
Remove trailing newlines in error messages (#8322) 2024-10-18 17:17:41 +02:00
konsti 32bba9f33b
Don't prefetch unreachable packages (#8246) 2024-10-18 13:44:24 +02:00
Zanie Blue cf7fcaa942
Fixup `HTTP_BASIC` reference in docstring (#8314) 2024-10-17 19:37:06 -05:00
Zanie Blue b9cd549138
Bump version to 0.4.24 (#8312) 2024-10-17 18:50:13 -05:00
Zanie Blue c8cbd62a30
Patch Python executable name for Windows free-threaded builds (#8310)
A temporary fix for https://github.com/astral-sh/uv/issues/8298 while we
wait for my slower upstream fix at
https://github.com/indygreg/python-build-standalone/pull/373

I think we'll want this machinery anyway to ensure that the various
executable names are available? Otherwise we need to special-case all
the `python` names in `uv run`?

We don't have unit test coverage of managed downloads, so I added an
[integration
test](https://github.com/astral-sh/uv/actions/runs/11394150653/job/31703956805?pr=8310)
similar to what we have for Linux.
2024-10-17 18:27:55 -05:00
David Bern 3fd69b448e
Respect `UV_INDEX_` rather than `UV_HTTP_BASIC_` (#8306)
The docs reference `UV_INDEX_`, but the code actually uses
UV_HTTP_BASIC_ as the prefix for environment variable credentials.

See PR #7741

Code is at
https://github.com/astral-sh/uv/blob/main/crates/uv-static/src/env_vars.rs#L163

```rust
    /// Generates the environment variable key for the HTTP Basic authentication username.
    pub fn http_basic_username(name: &str) -> String {
        format!("UV_HTTP_BASIC_{name}_USERNAME")
    }

    /// Generates the environment variable key for the HTTP Basic authentication password.
    pub fn http_basic_password(name: &str) -> String {
        format!("UV_HTTP_BASIC_{name}_PASSWORD")
    }
```

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-10-17 21:42:04 +00:00
Charlie Marsh c62f8d769c
Redact index credentials from lockfile sources (#8307)
## Summary

Closes https://github.com/astral-sh/uv/issues/8296.
2024-10-17 21:38:21 +00:00
Charlie Marsh 7beb5ebe26
Improve sources deserialization errors (#8308) 2024-10-17 21:33:04 +00:00
Zanie Blue 16b77e7fd4
Add a FreeBSD build to CI (#8269)
Playing with this because it's interesting and I learned about this cool
firecracker action.

Related #3370
2024-10-17 15:24:21 +00:00
Zanie Blue 83f835b0d0
Bump version to 0.4.23 (#8275)
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-10-17 14:26:39 +00:00
InSync d2e3026160
Fix error leading to out-of-bound panic in `uv-pep508` (#8282)
Resolves #8281.

## Summary


[`Cursor.slice()`](d930367f8c/crates/uv-pep508/src/cursor.rs (L39))
expects a start index and a length, but it is instead [given a start
index and an end
index](d930367f8c/crates/uv-pep508/src/lib.rs (L936)).

## Test plan

A new "leading whitespace" test is added to `tests.rs`.
2024-10-17 08:22:58 -04:00
konsti 7eed0bcd23
Add more context on resolve client error (#8285)
I'm not clear where #8144 comes from, so I'm adding some more error
context to narrow it down.
2024-10-17 08:22:09 -04:00
Charlie Marsh d930367f8c
Fix test fixtures to reflect installer new error messages (#8278)
## Summary

I unintentionally pushed this change directly to main; this PR just
updates the fixtures to reflect the more nuanced messages.
2024-10-16 22:22:06 -04:00
Charlie Marsh 5201550685
Update Saleor ecosystem snapshot (#8277) 2024-10-16 22:20:15 -04:00
Charlie Marsh 66211cb028 Use more precise error messages for preparation failures 2024-10-16 22:08:45 -04:00
Tim Hatch 91585a90e7
Narrow what the pip3.<minor> logic drops from entry points. (#8273)
## Summary

The hack in pip itself only modifies entry points called
`pip<number>.<number>` and `easy_install-<number>.<number>`, uv
previously dropped too many items including any of the form
`foo.<number>`.

Found while trying to install `memray` which somewhat notably does not
provide an abi3 wheel, so the installed, suffixed script matches. At a
minimum, this makes the installed files match the `entry_points.txt`
more than it did previously, which makes `pickley` happy.

## Test Plan

New test provided for previously-untested code.
2024-10-16 21:33:13 -04:00
Zanie Blue b851ced09e
Fix selection of free-threaded interpreters during default Python discovery (#8239)
Closes https://github.com/astral-sh/uv/issues/8228

e.g., on this branch

```
❯ uv python install 3.13t 3.13
❯ cargo build
❯ cargo run -q --bin uvx -- --from build python -c "import sys; print(sys.base_prefix)"
/Users/zb/.local/share/uv/python/cpython-3.13.0-macos-aarch64-none
❯ cargo run -q --bin uvx -- -p 3.13 --from build python -c "import sys; print(sys.base_prefix)"
/Users/zb/.local/share/uv/python/cpython-3.13.0-macos-aarch64-none
❯ cargo run -q --bin uvx -- -p 3.13t --from build python -c "import sys; print(sys.base_prefix)"
/Users/zb/.local/share/uv/python/cpython-3.13.0+freethreaded-macos-aarch64-none
```

and on main

```
❯ cargo build
❯ cargo run -q --bin uvx -- --from build python -c "import sys; print(sys.base_prefix)"
Installed 3 packages in 12ms
/Users/zb/.local/share/uv/python/cpython-3.13.0+freethreaded-macos-aarch64-none
```

I want to add more test coverage around this, but I've noticed the
free-threaded discovery tests are a bit off as-is and it'll be a bigger
task. I think the recent bugs around discovery indicate we should invest
more into that test framework.
2024-10-16 14:44:32 -05:00
github-actions[bot] 94a2686385
Fix managed distributions of free-threaded Python on Windows (#8268)
See upstream fix at
https://github.com/indygreg/python-build-standalone/pull/368

Co-authored-by: zanieb <2586601+zanieb@users.noreply.github.com>
2024-10-16 14:35:29 -05:00
Jo 76a9afbae5
Ignore try lock error if it is WouldBlock (#8258)
## Summary

Address a TODO comment, seems like we don't need `raw_os_err`?
2024-10-16 14:15:48 -05:00
Zanie Blue 6ac5859b1a
Improve styling of `requires-python` warnings (#8240)
Extends #7959

While I was looking at that message, I noticed I didn't love the
readability of the existing message and opted to follow-up with a change
to them both.
2024-10-16 13:08:21 -05:00
Charlie Marsh 4ca158931a
Show hint in resolution failure on `Forbidden` (`403`) or `Unauthorized` (`401`) (#8264)
## Summary

Closes https://github.com/astral-sh/uv/issues/8167.
2024-10-16 17:34:29 +00:00
Charlie Marsh 5e05a62004
Respect index priority when storing credentials (#8256)
## Summary

Closes https://github.com/astral-sh/uv/issues/8248.
2024-10-16 15:52:26 +00:00
konsti 31bf8eb43b
Update PubGrub (#8245) 2024-10-16 15:39:23 +00:00
Charlie Marsh 7730861bc5
Allow users to incorporate Git tags into dynamic cache keys (#8259)
## Summary

You can now use `cache-keys = [{ git = { commit = true, tags = true }
}]` to include both the current commit and set of tags in the cache key.

Closes https://github.com/astral-sh/uv/issues/7866.

Closes https://github.com/astral-sh/uv/issues/7997.
2024-10-16 11:13:29 -04:00
Aditya Pratap Singh 0bd6e46bcf
Avoid writing duplicate index URLs with `--emit-index-url` (#8226)
closes #8116

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-10-16 12:45:25 +00:00
Charlie Marsh 0c445eb11d
Fix flaky test in `build.rs` (#8250)
## Summary

Closes https://github.com/astral-sh/uv/issues/8241.
2024-10-16 12:26:05 +00:00
samypr100 319c0183c6
Add templates for popular build backends (#7857)
Co-authored-by: konstin <konstin@mailbox.org>
2024-10-16 14:19:59 +02:00
konsti 9f2e54ffba
Make rkyv optional in pep440-rs (#8249) 2024-10-16 12:15:51 +00:00
Ian Paul e71b1d0c42
Warn when patch isn't specified (#7959)
When patch version isn't specified and a matching version is referenced,
it will default patch to 0 which could be unclear/confusing. This PR
warns the user of that default.

<!--
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

<!-- What's the purpose of the change? What does it do, and why? -->

The first part of this issue
https://github.com/astral-sh/uv/issues/7426. Will tackle the second part
mentioned (`~=`) in a separate PR once I know this is the correct way to
warn users.

## Test Plan

<!-- How was it tested? -->

Unit tests were added

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-10-16 04:21:26 +00:00
Charlie Marsh 999b3f06a4
Respect relative paths in `uv build` sources (#8237)
## Summary

Right now, `uv build` will fail if a package depends on a local source
in `build-system.requires`.
2024-10-16 01:46:29 +00:00
samypr100 b4dca669b4
chore(uv): update env vars map to include newly added ones (#8233)
## Summary

Add some new env var mappings

## Test Plan

Existing tests
2024-10-15 21:40:09 -04:00
Charlie Marsh 98d049407f
Ignore sources in build requirements for non-source trees (#8235)
## Summary

We shouldn't enforce sources when, e.g., you provide a `.tar.gz` file.

Closes https://github.com/astral-sh/uv/issues/8236.
2024-10-16 00:53:19 +00:00
Charlie Marsh 59003cb021
Avoid showing lower-bound warning outside of explicit lock and sync (#8234)
## Summary

We shouldn't show these in `uv add`, especially when the thing we're
adding is about to have a lower-bound put on it. Now, we only show these
when the user runs `uv lock` or `uv sync`.
2024-10-15 20:49:40 -04:00
Charlie Marsh 2153c6ac0d
Respect named `--index` and `--default-index` values in `tool.uv.sources` (#7910)
## Summary

If you pass a named index via the CLI, you can now reference it as a
named source. This required some surprisingly large refactors, since we
now need to be able to track whether a given index was provided on the
CLI vs. elsewhere (since, e.g., we don't want users to be able to
reference named indexes defined in global configuration).

Closes https://github.com/astral-sh/uv/issues/7899.
2024-10-15 23:56:24 +00:00
Charlie Marsh a034a8b83b
Remove the flat index types (#7759)
## Summary

I think these really don't pull their weight.
2024-10-15 23:30:37 +00:00
Charlie Marsh d31b995511
Pin named indexes in `uv add` (#7747)
## Summary

This PR adds an index pin with `uv add` when the user provides exactly
one named index. We don't pin if the user provides an unnamed index, or
if they provide multiple indexes.

We probably _could_ pin on multiple indexes by writing the sources
_after_ resolution, if that's desirable. But we have no idea which index
the user _expects_ each package to come from.

Possible extensions:

- `uv add --no-pin` to avoid this pinning.
- Warn if they provide a single, unnamed index? I'm not sure if that's
worth a warn. Open to input.
2024-10-15 23:22:45 +00:00
Charlie Marsh beab67e225
Invalid cache when adding lower bound to lockfile (#8230)
## Summary

This was already properly handled, but the operation itself was in a
`debug_assert!`, so it wasn't running at all in production builds...

Closes https://github.com/astral-sh/uv/issues/8208.
2024-10-15 23:09:55 +00:00
Charlie Marsh 9a76e47888
Allow multiple pinned indexes in `tool.uv.sources` (#7769)
## Summary

This PR lifts the restriction that a package must come from a single
index. For example, you can now do:

```toml
[project]
name = "project"
version = "0.1.0"
readme = "README.md"
requires-python = ">=3.12"
dependencies = ["jinja2"]

[tool.uv.sources]
jinja2 = [
    { index = "torch-cu118", marker = "sys_platform == 'darwin'"},
    { index = "torch-cu124", marker = "sys_platform != 'darwin'"},
]

[[tool.uv.index]]
name = "torch-cu118"
url = "https://download.pytorch.org/whl/cu118"

[[tool.uv.index]]
name = "torch-cu124"
url = "https://download.pytorch.org/whl/cu124"
```

The construction is very similar to the way we handle URLs today: you
can have multiple URLs for a given package, but they must appear in
disjoint forks. So most of the code is just adding that abstraction to
the resolver, following our handling of URLs.

Closes #7761.
2024-10-15 22:58:15 +00:00
Charlie Marsh ad24cee7c6
Add index URLs when provided via `uv add --index` or `--default-index` (#7746)
## Summary

The behavior is as follows:

- If you provide `--index` or `--default-index` on the command-line, we
add those indexes to the `pyproject.toml` (with names, if provided, as
in `--index pytorch=https://download.pytorch.org/whl/cu121`.
- If you provide `--index-url` or `--default-index`, we warn, but don't
add the indexes to the file. (This seems wrong -- why not add them?)
- If you provide an index with a name or URL that already exists, we
remove that entry, and add the new index to the top of the list (since
it now has highest priority).
- If you provide a `--default-index`, and an index already has `default
= true`, we remove that entry, since it won't be used anymore.

We do _not_ pin packages to specific indexes yet.
2024-10-15 22:57:26 +00:00