Commit graph

4903 commits

Author SHA1 Message Date
Andrew Gallant
a085b01d30 uv/tests: another update to error messages
Unlike the previous update, this message is specifically referring to a
fork's markers inside the resolver. We probably *could* massage the
message to be simplified with respect to requires-python, but it's not
obvious to me that that is the right thing to do.
2024-09-03 18:41:15 -04:00
Andrew Gallant
3241033f46 uv/tests: update transformers ecosystem snapshot
It is not clear whether this update is correct or not. Moreover, it's
not clear whether the status quo is correct or not. The problem is that
`transformers` is so big that it's very hard to understand what the
right output is without a deeper investigation.

One thing that is interesting is if fork prioritization is removed in
this PR *and* on `main`, then the differences in this ecosystem test go
away.

We've decided for now to move forward with this update even though we're
uncertain because this PR fixes a few outstanding correctness issues.
2024-09-03 18:41:15 -04:00
Andrew Gallant
95a8493f5a uv/tests: update error message
This update changes the error message to one that is worse than the
status quo, but it is still correct because `datasets >= 2.19` doesn't
actually exist given our `EXCLUDE_NEWER` in tests at present.

The underlying cause here seems to be in how PubGrub deals with
reporting incompatibilities. Namely, when it has `foo < 1` and
`foo >= 1`, it reports an incompatibility immediately before looking for
versions. But when it has `foo < 1` and `foo >= 1 ; marker`, then
because they aren't both pubgrub "packages," it starts requesting
versions first and hits the "not available" error path instead of the
"incompatible" error path.

Since this is more of an underlying issue with how we setup
`PubGrubPackage` and our interaction with pubgrub, we ended up deciding
to move forward here with the regression since this PR is fixing a
correctness issue. In particular, if one changes the `requires-python`
to `>=3.8`, then both `main` and this PR produce similarly bad error
messages.
2024-09-03 18:41:15 -04:00
Andrew Gallant
4ff057e108 uv-resolver: refactor how we deal with requires-python
This commit refactors how deal with `requires-python` so that instead of
simplifying markers of dependencies inside the resolver, we do it at the
edges of our system. When writing markers to output, we simplify when
there's an obvious `requires-python` context. And when reading markers
as input, we complexity markers with the relevant `requires-python`
constraint.
2024-09-03 18:41:15 -04:00
Andrew Gallant
94a0a0f2ee uv-resolver: rejigger 'trace_resolution'
When I first wrote this routine, it was intended to only emit a trace
for the final "unioned" resolution. But we actually moved that semantic
operation to the construction of the resolution *graph*. So there is no
unioned `Resolution` any more.

But this is still useful to see. So I changed this to just emit a trace
of *every* resolution right before constructing the graph.

It might be nice to also emit a trace of the unioned graph too. Or
perhaps we should do that instead if this proves too noisy. (Although
this is only emitted at TRACE level.)
2024-09-03 18:41:15 -04:00
Andrew Gallant
d6a14464ab uv-cli: use PathBuf::from
Conversions from strings to paths are always infallible.
2024-09-03 18:41:15 -04:00
Andrew Gallant
9348564580 uv/tests: add regression tests
These are regression tests for #6269, #6412 and #6836. In this commit,
their test outputs are all wrong. We'll update these snapshots after
fixing the underlying bug by refactoring how `requires-python`
simplification works.
2024-09-03 18:41:15 -04:00
Zanie Blue
4a6bea5321
Fix outdated references to the help menu documentation in the first steps page (#6980) 2024-09-03 17:14:38 -05:00
Zanie Blue
d87256bebe
Improve project handling in uv venv (#6835)
- Respect `UV_PROJECT_ENVIRONMENT` when in project root
- Add `--no-project` and `--no-workspace` to opt-out of above and
`requires-python` detection
- Rename `[NAME]` to `[PATH]` in CLI
2024-09-03 14:22:30 -05:00
Zanie Blue
1e89d3e44f
Remove VIRTUAL_ENV from project commmands by default (#6976)
And use test context helpers for commands consistently.

Needed for https://github.com/astral-sh/uv/pull/6864
2024-09-03 14:11:23 -05:00
Zanie Blue
1234b6dcf1
Allow customizing the project environment path with UV_PROJECT_ENVIRONMENT (#6834)
Allows configuration of the (currently hard-coded) path to the virtual
environment in projects using the `UV_PROJECT_ENVIRONMENT` environment
variable.

If empty, we'll ignore it. If a relative path, it will be resolved
relative to the workspace root. If an absolute path, we'll use that.

This feature targets use in Docker images and CI. The variable is
intended to be set once in an isolated system and used for all uv
operations.

We do not expose a CLI option or configuration file setting — we may
pursue those later but I see them as lower priority. I think a
system-level environment variable addresses the most pressing use-cases
here.

This doesn't special-case the system environment. Which means that you
can use this to write to the system Python environment. I would
generally strongly recommend against doing so. The insightful comment
from @edmorley at
https://github.com/astral-sh/uv/issues/5229#issuecomment-2312702902
provides some context on why. More generally, `uv sync` will remove
packages from the environment by default. This means that if the system
environment contains any packages relevant to the operation of the
system (that are not dependencies of your project), `uv sync` will break
it. I'd only use this in Docker or CI, if anywhere. Virtual environments
have lots of benefits, and it's only [one line to "activate"
them](https://docs.astral.sh/uv/guides/integration/docker/#using-the-environment).

If you are considering using this feature to use Docker bind mounts for
developing in containers, I would highly recommend reading our [Docker
container development
documentation](https://docs.astral.sh/uv/guides/integration/docker/#developing-in-a-container)
first. If the solutions there do not work for you, please open an issue
describing your use-case and why.

We do not read `VIRTUAL_ENV` and do not have plans to at this time.
Reading `VIRTUAL_ENV` is high-risk, because users can easily leave an
environment active and use the uv project interface today. Reading
`VIRTUAL_ENV` would be a breaking change. Additionally, uv is
intentionally moving away from the concept of "active environments" and
I don't think syncing to an "active" environment is the right behavior
while managing projects. I plan to add a warning if `VIRTUAL_ENV` is
set, to avoid confusion in this area (see
https://github.com/astral-sh/uv/pull/6864).

This does not directly enable centrally managed virtual environments. If
you set `UV_PROJECT_ENVIRONMENT` to an absolute path and use it across
multiple projects, they will clobber each other's environments. However,
you could use this with something like `direnv` to achieve "centrally
managed" environments. I intend to build a prototype of this eventually.
See #1495 for more details on this use-case.

Lots of discussion about this feature in:

- https://github.com/astral-sh/rye/issues/371
- https://github.com/astral-sh/rye/pull/1222
- https://github.com/astral-sh/rye/issues/1211
- https://github.com/astral-sh/uv/issues/5229
- https://github.com/astral-sh/uv/issues/6669
- https://github.com/astral-sh/uv/issues/6612

Follow-ups:

- #6835 
- https://github.com/astral-sh/uv/pull/6864
- Document this in the project concept documentation (can probably
re-use some of this post)

Closes https://github.com/astral-sh/uv/issues/6669
Closes https://github.com/astral-sh/uv/issues/5229
Closes https://github.com/astral-sh/uv/issues/6612
2024-09-03 12:52:18 -05:00
Leiser Fernández Gallo
bc7b6f109e
Make headers title case for backward compatibility (#6887)
## Summary
Http headers are supposed to be case-insensitive (RFC 2616), but there
are some implementations that don't normalize them.
I noticed it while migrating to `uv`, calls to an internal registry
failed. A man in the middle server helped me to find that `pip` uses
Title-Case while `uv pip` uses lowercase.

## Test Plan

I tested `uv` with the same server and now it works fine.
2024-09-03 13:28:45 -04:00
eth3lbert
c667588524
Show env option in CLI reference documentation (#6863)
## Summary

Closes #6469.

<img width="721" alt="image"
src="https://github.com/user-attachments/assets/be144e43-e02f-473e-921c-91cf00c3c8d3">
2024-09-03 12:10:49 -05:00
Charlie Marsh
becdd4bdaf
Show all PyPy versions in uv python list --all-versions (#6917)
## Summary

Closes https://github.com/astral-sh/uv/issues/6905.
2024-09-03 11:40:27 -04:00
David Bern
b7795024a8
docs docker.md: example to use bind mounts (#6921)
## Summary

Update the extended docker example to use bind mounts and avoid creating
extra layers and avoid copying files into layers

This is in line with the official Docker templates for Python
applications (you can try them out using `docker init`. I found them
very helpful!)
2024-09-03 09:36:54 -05:00
samypr100
37e25e2b1d
feat: introduce more docker tags for uv (#6053)
## Summary

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

This PR introduces additional images with the uv/uvx binaries from
scratch for both amd64/arm64 and make the mapping easy to configure by
generating the Dockerfile on the fly. This approach focuses on
minimizing CI time by taking advantage of dedicating a worker per
mapping (20-30s~ per job).

This PR also fixes `org.opencontainers.image.version` for all tags
(including the one from `scratch) to contain the right release version
instead of branch name `main` (default when no tag patterns are
specified).

For example, on release `x.y.z`, this will publish the following image
tags with format `ghcr.io/astral-sh/uv:{tag}` with manifests for both
amd64/arm64. This also include `x.y` tags for each respective additional
tag.

* From **scratch**: `latest`, `x.y.z`, `x.y` (currently being published)
* From **alpine:3.20**: `alpine`, `alpine3.20`, `x.y.z-alpine`,
`x.y.z-alpine3.20`
* From **debian:bookworm-slim**: `debian-slim`, `bookworm-slim`,
`x.y.z-debian-slim`, `x.y.z-bookworm-slim`
* From **buildpack-deps:bookworm**: `debian`, `bookworm`,
`x.y.z-debian`, `x.y.z-bookworm`
* From **python:3.12-alpine**: `python3.12-alpine`,
`x.y.z-python3.12-alpine`
* From **python:3.11-alpine**: `python3.11-alpine`,
`x.y.z-python3.11-alpine`
* From **python:3.10-alpine**: `python3.10-alpine`,
`x.y.z-python3.10-alpine`
* From **python:3.9-alpine**: `python3.9-alpine`,
`x.y.z-python3.9-alpine`
* From **python:3.8-alpine**: `python3.8-alpine`,
`x.y.z-python3.8-alpine`
* From **python:3.12-bookworm**: `python3.12-bookworm`,
`x.y.z-python3.12-bookworm`
* From **python:3.11-bookworm**: `python3.11-bookworm`,
`x.y.z-python3.11-bookworm`
* From **python:3.10-bookworm**: `python3.10-bookworm`,
`x.y.z-python3.10-bookworm`
* From **python:3.9-bookworm**: `python3.9-bookworm`,
`x.y.z-python3.9-bookworm`
* From **python:3.8-bookworm**: `python3.8-bookworm`,
`x.y.z-python3.8-bookworm`
* From **python:3.12-slim-bookworm**: `python3.12-slim-bookworm`,
`x.y.z-python3.12-slim-bookworm`
* From **python:3.11-slim-bookworm**: `python3.11-slim-bookworm`,
`x.y.z-python3.11-slim-bookworm`
* From **python:3.10-slim-bookworm**: `python3.10-slim-bookworm`,
`x.y.z-python3.10-slim-bookworm`
* From **python:3.9-slim-bookworm**: `python3.9-slim-bookworm`,
`x.y.z-python3.9-slim-bookworm`
* From **python:3.8-slim-bookworm**: `python3.8-slim-bookworm`,
`x.y.z-python3.8-slim-bookworm`
2024-09-03 08:44:01 -05:00
Michal Čihař
01f4beeafe
Differentiate startup and compile timeouts (#6958)
<!--
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

Separate exceptions for different timeouts to make it easier to debug
issues like #6105.

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

## Test Plan

<!-- How was it tested? -->
Not tested at all.
2024-09-03 10:32:43 +02:00
konsti
9e34c42cec
Move unreachable wheels check (#6957)
Prep for fixing #6512. No functional changes.
2024-09-03 07:48:54 +00:00
Charlie Marsh
ccdf2d793b
Add --no-hashes to uv export (#6954)
## Summary

Closes https://github.com/astral-sh/uv/issues/6944.
2024-09-02 22:12:29 -04:00
eth3lbert
ad82b94856
Support file:// URLs for UV_PYTHON_INSTALL_MIRROR (#6950)
## Summary

Closes #6319.

## Test Plan

I tested with `file:///mirror`, `file://localhost/mirror`, and
`http://mirror` to confirm that it was working as expected.

``` shell-session
/private/tmp/mirror-local                                                                                                                                                                      07:08:18
:)  tree mirror 
mirror/
└── 20240814/
   └── cpython-3.12.5+20240814-aarch64-apple-darwin-install_only_stripped.tar.gz
```

<img width="626" alt="image"
src="https://github.com/user-attachments/assets/9c04224d-305c-47ee-a524-4a6abeb79da4">
2024-09-03 01:20:01 +00:00
Charlie Marsh
b229230643
Use | for page separator in meta titles (#6953)
I generally prefer this style:

![Screenshot 2024-09-02 at 8 41
38 PM](https://github.com/user-attachments/assets/795dab85-b6c4-4278-913f-1d723379b225)
2024-09-03 00:42:59 +00:00
Charlie Marsh
fe17797240
Update URL in structured schema (#6952) 2024-09-02 20:28:36 -04:00
Charlie Marsh
7c37bae8f1
Avoid canonicalizing cache directory (#6949)
Taking a look at #6948.
2024-09-03 00:11:44 +00:00
Charlie Marsh
92e93da81d
Add static assets to docs pages (#6951)
## Summary

This PR points the docs towards the static assets that we use for
`astral.sh`, so that we can use shared assets for the Ruff and uv docs.
2024-09-02 20:00:30 -04:00
Charlie Marsh
47f4ca24b3
Bump version to v0.4.3 (#6947) 2024-09-02 17:18:57 -04:00
Charlie Marsh
f9c04581e6
Allow uv sync --package without copying member pyproject.toml (#6943)
## Summary

Closes https://github.com/astral-sh/uv/issues/6935.
2024-09-02 21:01:50 +00:00
Charlie Marsh
6897001fee
Stream build backend output to debug! (#6903)
## Summary

We need to decide whether we want this in `debug!` or `tracing!`. We
also _probably_ (?) want to show this by default in `uv build`.

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

Closes https://github.com/astral-sh/uv/issues/5893.
2024-09-02 19:46:09 +00:00
Charlie Marsh
8eef1a2314
Use lower-bound semantics for all Python compatibility comparisons (#6882)
## Summary

Right now, we have slightly different `requires-python` semantics for
`-p 3.11` vs. `-p 3.11 --universal`, and slightly different (wrong)
semantics for how we compare against the _installed_ Python version
(which doesn't ignore upper bounds, but should).

This PR rips it all out and replaces it with consistent semantics across
`uv lock`, `uv pip compile -p 3.11`, and `uv pip compile -p 3.11
--universal`. We now always ignore upper bounds.

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

Closes https://github.com/astral-sh/uv/issues/5045.
2024-09-02 18:23:42 +00:00
Charlie Marsh
cbe2827e97
Avoid updating incorrect dependencies for sorted uv add (#6939)
## Summary

The indexes stored in the edits is wrong now that we add dependencies
out-of-order.

Closes https://github.com/astral-sh/uv/issues/6933.
2024-09-02 14:21:25 -04:00
Charlie Marsh
42a4d80a63
Add source distribution support to uv-build crate (#6896)
## Summary

Just exposes the correct PEP 517 hooks.
2024-09-02 18:14:49 +00:00
renovate[bot]
ea0a0db7a7
Update fedora Docker tag to v42 (#6924) 2024-09-02 14:01:51 -04:00
renovate[bot]
9319319f84
Update pre-commit dependencies (#6923) 2024-09-02 14:01:40 -04:00
konsti
9edf2d8132
Avoid panic with missing temporary directory (#6929)
Forward an error for missing temp directories:

```
$ env TMPDIR=.tmp uv-debug pip install httpx
  error: No such file or directory (os error 2) at path "/home/konsti/projects/uv/.tmp/.tmpgIBhhh"
```

Fixes #6878
2024-09-02 07:32:42 +00:00
Charlie Marsh
7e6df8ffd4
Remove canonicalize calls (#6919)
## Summary

A few of these should use `absolute` instead of `canonicalize`; and
apparently we no longer need to strip the `CANONICAL_CWD` to get tests
passing.
2024-09-01 18:23:11 +00:00
Chao Ning
ae3f35cfe2
fix: replace std::fs::canonicalize with Simplified::simple_canonicaliz… (#6776)
## Summary
This PR addresses an issue on Windows where `std::fs::canonicalize` can
fail or panic when resolving paths on mapped network drives. By
replacing it with `Simplified::simple_canonicalize`, we aim to improve
the robustness and cross-platform compatibility of path resolution.

### Changes
* Updated `CANONICAL_CWD` in `path.rs` to use
`Simplified::simple_canonicalize` instead of `std::fs::canonicalize`.

### Why
* `std::fs::canonicalize` has known issues with resolving paths on
mapped network drives on Windows, which can lead to panics or incorrect
path resolution.
* `Simplified::simple_canonicalize` internally uses
`dunce::canonicalize`, which handles these cases more gracefully,
ensuring better stability and reliability.

## Test Plan
Since `simple_canonicalize` has already been tested in a prior PR, this
change is expected to work without introducing any new issues. No
additional tests are necessary beyond ensuring existing tests pass,
which will confirm the correctness of the change.
2024-09-01 13:59:15 -04:00
Charlie Marsh
736ccb950a
Bump version to v0.4.2 (#6916) 2024-09-01 13:37:27 -04:00
Charlie Marsh
049c73d09e
Remove dangling archives in uv cache clean ${package} (#6915)
## Summary

Closes https://github.com/astral-sh/uv/issues/6909.
2024-09-01 13:27:13 -04:00
Ed Morley
a5f1e1c765
Fix typos in docs, error messages and comments (#6910) 2024-09-01 11:37:43 +00:00
Mathieu Kniewallner
c9e4395322
docs: add missing console highlights (#6900)
## Summary

Spotted a few missing `console` highlights in the documentation.
2024-08-31 19:04:19 -04:00
Mathieu Kniewallner
fe5f085299
chore: run cargo dev generate-all on CI and locally (#6899)
## Summary

Noticed that running `cargo dev generate-all` on `main` produced changes
and saw that that the command is not run on the CI nor as a pre-commit
hook.

Not sure if having the command running as a pre-commit hook is something
we want, so I can remove it if you prefer. I find that nice to have as
it's probably easy to forget to run it, especially for new contributors
(and it will only run if there are changes in `uv_cli` or `uv_settings`
crates).

## Test Plan

- Added `cargo dev generate-all --mode check` on the CI, which produced
[this failing
job](2951669939)
- Ran `cargo dev generate-all` locally and committed the changes, which
produced [this succeeding
job](2951674494)
2024-08-31 19:03:53 -04:00
Charlie Marsh
3e647b139e
Fix is_disjoint check for supported environments (#6902) 2024-08-31 19:01:47 -04:00
Ed Morley
d2df51f5f5
Fix missing word in config files docs (#6901) 2024-08-31 22:33:59 +01:00
Charlie Marsh
83467f0a51
Fix typos (#6891) 2024-08-30 19:45:33 -04:00
Vikas
b441678cf6
Adding support for .pyc files in uv run (#6886)
## Summary
- The change relates to #6635 is to include compiled python files (.pyc)
in the uv run command.
- After this change `uv run foo.pyc` should spawn `python foo.pyc`.


## Test Plan
- There is a test that uses TestContext to compile and run a simple
python file that prints "Hello World".
- I built the project locally and tried the same with a simple python
file that I had compiled.
2024-08-30 19:45:24 -04:00
Charlie Marsh
a4bd875973
Remove unnecessary wheel from test dependencies (#6889) 2024-08-30 16:43:09 -04:00
Charlie Marsh
2ce8b916cc
Run cargo update (#6888) 2024-08-30 16:42:04 -04:00
konsti
00c98a82b0
Use from_range_bounds (#6879)
Not the most ergonomic api pubgrub has to offer, but better than rolling
our own.
2024-08-30 16:06:55 -04:00
Charlie Marsh
34435d7d9d
Error when discovered Python is incompatible with --isolated workspace (#6885)
## Summary

We should have consistent errors with and without `--isolated`.
2024-08-30 19:40:38 +00:00
Charlie Marsh
f21f1f29c6
Warn when discovered Python is incompatible with PEP 723 script (#6884)
## Summary

Closes https://github.com/astral-sh/uv/issues/6883.
2024-08-30 19:26:49 +00:00
Charlie Marsh
fa1498396e
Treat missing top_level.txt as non-fatal (#6881)
## Summary

Closes https://github.com/astral-sh/uv/issues/6872.
2024-08-30 19:02:06 +00:00