Commit graph

3294 commits

Author SHA1 Message Date
Charlie Marsh
6ae005b0d0
Add --no-emit-project and friends to uv export (#7110)
## Summary

Like `uv sync`, you can omit the current project (`--no-emit-project`),
a specific package (`--no-emit-package`), or the entire workspace
(`--no-emit-workspace`).

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

Closes #6995.
2024-09-06 01:01:46 +00:00
Charlie Marsh
d0f9016eda
Add --output-file to uv export (#7109)
## Summary

Closes https://github.com/astral-sh/uv/issues/7058.
2024-09-05 20:53:53 -04:00
Charlie Marsh
c494f6912c
Take intersection of constraint and requirements hashes (#7108)
## Summary

Small follow-up to #7093.
2024-09-05 20:22:34 -04:00
Zanie Blue
84f25e8cf8
Bump version to 0.4.6 (#7103) 2024-09-05 17:39:53 -05:00
Charlie Marsh
58b25b560c
Invalidate lockfile when member versions change (#7102)
## Summary

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

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-09-05 17:14:57 -05:00
Charlie Marsh
29f53c3c63
Support --no-build and --no-binary in uv sync et al (#7100)
## Summary

This option already existed, but `--no-binary` always errored.

Closes https://github.com/astral-sh/uv/issues/7099.
2024-09-05 21:45:42 +00:00
Charlie Marsh
f2309bfd1e
Remove timestamp exact vs. approximate enum (#7098) 2024-09-05 20:49:20 +00:00
Charlie Marsh
5b89734c85
Add --require-hashes and --verify-hashes to uv build (#7094) 2024-09-05 15:22:03 -04:00
Charlie Marsh
80f51cee06
Accept --build-constraints in uv build (#7085)
## Summary

Closes #7082.

Closes #7065.
2024-09-05 18:46:36 +00:00
Charlie Marsh
bb61513952
Respect hashes in constraints files (#7093)
## Summary

Like pip, if hashes are present on both the requirement and the
constraint, we prefer the requirement.

Closes #7089.
2024-09-05 14:30:10 -04:00
konsti
750e8b1e2f
Remove propagate_markers (#7076)
Follow-up to #6959 and #6961: Use the reachability computation instead
of `propagate_markers` everywhere.

With `marker_reachability`, we have a function that computes for each
node the markers under which it is (`requirements.txt`, no markers
provided on installation) or can be (`uv.lock`, depending on the markers
provided on installation) included in the installation. Put differently:
If the marker computed by `marker_reachability` is not fulfilled for the
current platform, the package is never required on the current platform.

We compute the markers for each package in the graph, this includes the
virtual extra packages and the base packages. Since we know that each
virtual extra package depends on its base package (`foo[bar]` implied
`foo`), we only retain the base package marker in the `requirements.txt`
graph.

In #6959/#6961 we were only using it for pruning packages in `uv.lock`,
now we're also using it for the markers in `requirements.txt`.

I think this closes #4645, CC @bluss.
2024-09-05 16:52:21 +00:00
konsti
d5eb6eb12c
Move reachability function (#7091)
Split out from #7076
2024-09-05 16:44:21 +00:00
Charlie Marsh
d91f7ddf5f
Don't include registry hashes for URL distributions (#7086)
The opposite _can_ be true.
2024-09-05 11:42:07 -04:00
Ahmed Ilyas
567e213cbb
Accept vec of packages in uv tool uninstall (#7077)
## Summary

Follow up
https://github.com/astral-sh/uv/pull/7037#discussion_r1744515370

## Test Plan

`cargo test`
2024-09-05 08:24:13 -04:00
konsti
316f683071
Update packse (#7002)
Add additional tests for https://github.com/astral-sh/uv/pull/6959 and
https://github.com/astral-sh/uv/pull/6961
2024-09-05 08:14:34 +00:00
Alex Gaynor
6648a9b940
fix inverted log message (#7063) 2024-09-05 02:42:08 +00:00
eth3lbert
e7a7a813fb
Implement --show-version-specifiers for tool list (#7050)
## Summary

Closes #6747 .

## Test Plan

```
cargo test --test tool_list
```
2024-09-05 02:15:18 +00:00
Charlie Marsh
a20fecedaa
Strip fragments from direct source URLs in lockfile (#7061)
## Summary

In resolving https://github.com/astral-sh/uv/issues/7059, I noticed that
we left the fragment on the `source = { url = "..." }`.
2024-09-05 02:05:39 +00:00
Charlie Marsh
1f7a9a7407
Use distribution hash over registry hash (#7060)
## Summary

We need to prioritize hashes for the distribution over hashes for the
related packages.

I think this needs to be redone entirely though. I can see other issues
with the current approach.

Closes https://github.com/astral-sh/uv/issues/7059.
2024-09-05 01:58:21 +00:00
Charlie Marsh
20c666c10d
Sort by implementation in uv python list (#6918)
## Summary

With #6917, there are a lot more PyPy downloads in `uv python list
--all-versions`. I find it clearer to have all the CPython downloads
listed, then all the PyPy downloads, rather than interspersing them. But
this is subjective, feel free to push back!
2024-09-04 17:35:51 -04:00
Ahmed Ilyas
ff39950545
Allow multiple packages for uv tool upgrade/uninstall (#7037)
## Summary

Resolves https://github.com/astral-sh/uv/issues/6571

## Test Plan

`cargo test`
2024-09-04 17:18:52 -04:00
Zanie Blue
42b6bfbad7
Bump version to 0.4.5 (#7044) 2024-09-04 16:56:10 -04:00
Charlie Marsh
1c25c76be6
Make invlaid core-metadata tag non-fatal (#7046)
## Summary

One of the indexes we test against is using a non-compliant value (the
actual URL).
2024-09-04 16:44:04 -04:00
Charlie Marsh
1ccc15e7bb
Use correct ordering semantics for narrowing upper-bounded Python requirements (#7031)
## Summary

We need to use different ordering semantics for upper and lower Python
bounds.

Closes https://github.com/astral-sh/uv/issues/6911.
2024-09-04 15:57:14 +00:00
Charlie Marsh
7aed94bed2
Add --package support to uv build (#6990)
## Summary

This PR adds `--package` support to `uv build`, such that you can use
`--package` from anywhere in a workspace to build any member.

If a source directory is provided, we use that as the workspace root.

If a file is provided, we error.

For now, `uv build` only builds the current package, making it
semantically identical to `uv sync`.
2024-09-04 15:52:21 +00:00
Charlie Marsh
05ed4bc11d
Show build output by default in uv build (#6912)
## Summary

This is a big improvement IMO:

![Screenshot 2024-09-01 at 12 52
28 PM](https://github.com/user-attachments/assets/2d8b1370-3385-429a-9a1d-e1d44611a2b4)
2024-09-04 15:39:21 +00:00
Charlie Marsh
5d8e99045a
Support uv build --wheel from source distributions (#6898)
## Summary

This PR allows users to run `uv build --wheel ./path/to/source.tar.gz`
to build a wheel from a source distribution. This is also the default
behavior if you run `uv build ./path/to/source.tar.gz`. If you pass
`--sdist`, we error.
2024-09-04 15:30:32 +00:00
Charlie Marsh
df84d25a7e
Implement uv build (#6895)
## Summary

This PR exposes uv's PEP 517 implementation via a `uv build` frontend,
such that you can use `uv build` to build source and binary
distributions (i.e., wheels and sdists) from a given directory.

There are some TODOs that I'll tackle in separate PRs:

- [x] Support building a wheel from a source distribution (rather than
from source) (#6898)
- [x] Stream the build output (#6912)

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

Closes https://github.com/astral-sh/uv/issues/1663.
2024-09-04 11:23:46 -04:00
Zanie Blue
a3a1bfd5ec
Use the root project name for the project virtual environment prompt (#7021)
Closes https://github.com/astral-sh/uv/issues/7001

Tested with a legacy virtual workspace and a project with a `[project]`
table.
2024-09-04 15:16:31 +00:00
Zanie Blue
1996067f81
Add note to extra and all-extras in uv sync help (#7013) 2024-09-04 15:05:21 +00:00
Charlie Marsh
ae144e05ac
Revert pyproject.toml modifications on Ctrl-C (#7024)
## Summary

Not perfect, but an improvement at least for an interactive experience.

Closes #6818.
2024-09-04 11:04:00 -04:00
konsti
2b294b90f2
Redact packse version in all urls (#7026)
Reduce the diff on packse updates
2024-09-04 14:59:07 +00:00
Andrew Gallant
5b643ced1d uv/tests: filter out link mode warning in one test
In the `lock_redact_https` test specifically, it prompts a link mode
warning from `uv` on my system. Debugging seems to suggest it is
provoked by attempting to hardlink between `/tmp` and `~/.local`. Since
these are on different file systems for me (with `/tmp` being a
ramdisk), it provokes the warning, and this turn spoils the snapshot
when running tests locally.

This PR adds a test specific filter rule to fix this.
2024-09-04 10:45:40 -04:00
Charlie Marsh
e7c9a9c235
Rollback pyproject.toml changes on all errors (#7022)
## Summary

The error handlers now happen one level higher, matching on _any_ `Err`
that's returned from the lock-and-sync operations.

Closes https://github.com/astral-sh/uv/issues/7011.
2024-09-04 10:42:14 -04:00
Charlie Marsh
59dead7201
Fix handling of inline optional dependencies in uv add (#7023)
## Summary

We had test coverage for this, but I missed that the output was
incorrect.
2024-09-04 10:41:59 -04:00
Garth Kidd
7909e9650f
Remove unused import. (#6996)
`_virtualenv.py` doesn't need to import `__future__.annotations`, as it
has none.

Removing the import:

* Restores the action of the VIRTUALENV_PATCH on Python 3.6

* Eliminates 24 lines of error messages displayed by Python 3.6 when it
starts in an environment created by uv:

```plaintext
Error processing line 1 of /tmp/tmp.ENwqZ0oeyb/lib/python3.6/site-packages/_virtualenv.pth:

  Traceback (most recent call last):
    File "~/.pyenv/versions/3.6.15/lib/python3.6/site.py", line 168, in addpackage
      exec(line)
    File "<string>", line 1, in <module>
    File "/tmp/tmp.ENwqZ0oeyb/lib/python3.6/site-packages/_virtualenv.py", line 3
      from __future__ import annotations
                                       ^
  SyntaxError: future feature annotations is not defined

Remainder of file ignored
```

(Python displays the errors above twice.)

I appreciate the Python team no longer support Python 3.6, but
RedHat-style Linux distributions will support Python 3.6 in their
`/usr/libexec/platform-python` until [releasever 8 expires in
2029](https://access.redhat.com/support/policy/updates/errata#RHEL8_Planning_Guide).
I'm happy for the community to move on, in general, but don't see the
harm in helping those who can't.

I'm not yet sure what in the “remainder of file ignored” is necessary
for my project's build, as I haven't yet finished digging that from
under Hatch. I'll follow up on #6426 when I do, so we can concentrate on
getting to the happy cow.

## Test Plan

```sh
( set -eu
  export VIRTUAL_ENV="$(mktemp -d)"
  ./target/release/uv venv "$VIRTUAL_ENV" --python=python3.6
  ./target/release/uv pip install cowsay        
  $VIRTUAL_ENV/bin/python -m cowsay --text 'Look, a talking cow!' )
  ```
  
Happy output:

```plaintext
Using Python 3.6.15 interpreter at: ~/.local/bin/python3.6
Creating virtualenv at: /tmp/tmp.VHl4XNi3oI
Activate with: source /tmp//tmp.VHl4XNi3oI/bin/activate
Resolved 1 package in 929ms
Installed 1 package in 17ms
 + cowsay==6.0
  ____________________
| Look, a talking cow! |
  ====================
                    \
                     \
                       ^__^
                       (oo)\_______
                       (__)\       )\/\
                           ||----w |
                           ||     ||
```

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-09-04 09:40:58 -04:00
Charlie Marsh
14d1c54b77
Reflect exit code in uv tool run and uv run (#6994)
## Summary

Closes https://github.com/astral-sh/uv/issues/6710.
2024-09-04 09:33:26 -04:00
samypr100
66699def2e
fix: adjust close_handles pointer offsets to match distlib cleanup_fds (#6955)
## Summary

Resolves issues mentioned in comments
* https://github.com/astral-sh/uv/issues/6699#issuecomment-2322515962
* https://github.com/astral-sh/uv/issues/6866#issuecomment-2322785906

Further investigation on the comments revealed that the pointer
arithmethic being performed in `let handle_start = unsafe {
crt_magic.offset(1 + handle_count) };` from [posy
trampoline](dda22e6f90/src/trampolines/windows-trampolines/posy-trampoline/src/bounce.rs (L146))
had some slight errors. Since `crt_magic` was a `*const u32`, doing an
offset by `1 + handle_count` would offset by too much, with some
possible out of bounds reads or attempts to call CloseHandle on garbage.

We needed to offset differently since we want to offset by
`handle_count` bytes after the initial offset as seen in
[launcher.c](888c48b568/PC/launcher.c (L578)).
Similarly, we needed to skip the first 3 handles, otherwise we'd still
be attempting to close standard I/O handles of the parent (in this case
the shell from `busybox.exe sh -l`).

I also added a few extra checks available from `launcher.c` which checks
if the handle value is `-2` just to match the distlib implementation
more closely and minimize differences.

## Test Plan

Manually compiled distlib's launcher with additional logging and
replaced `Lib/site-packages/pip/_vendor/distlib/t64.exe` with the
compiled one to log pointers. As a result, I was able to verify the
retrieved handle memory addresses in this function actually match in
both uv and distlib's implementation from within busybox.exe nested
shell where this behavior can be observed and manually tested.

I was also able to confirm this fixes the issues mentioned in the
comments, at least with busybox's shell, but I assume this would fix the
case with cmake.

## Open areas

`launcher.c` also [checks the
size](888c48b568/PC/launcher.c (L573-L576))
of `cbReserved2` before retrieving `handle_start` which this function
currently doesn't do. If we wanted to, we could add the additional check
here as well, but I wasn't fully sure why it wasn't added in the first
place. Thoughts?

```rust
// Verify the buffer is large enough
if si.cbReserved2 < (size_of::<u32>() as isize + handle_count + size_of::<HANDLE>() as isize * handle_count) as u16 {
    return;
}
```

---------

Co-authored-by: konstin <konstin@mailbox.org>
2024-09-04 13:31:57 +02:00
konsti
c9787f9fd8
Prune unreachable wheels from lockfile (#6961)
When a package is included under a platform-specific marker, we know
that wheels that mismatch this marker can never be installed, so we drop
them from the lockfile.
2024-09-04 11:08:37 +02:00
konsti
b9f2bd155a
Prune unreachable packages from lockfile (#6959)
In transformers, we have:

* `tensorflow-text`: `tensorflow-macos; python_full_version >= '3.13'
and platform_machine == 'arm64' and platform_system == 'Darwin'`
* `tensorflow-macos`: `tensorflow-cpu-aws; (python_full_version < '3.10'
and platform_machine == 'aarch64' and platform_system == 'Linux') or
(python_full_version >= '3.13' and platform_machine == 'aarch64' and
platform_system == 'Linux') or (python_full_version >= '3.13' and
platform_machine == 'arm64' and platform_system == 'Linux')`
* `tensorflow-macos`: `tensorflow-intel; python_full_version >= '3.13'
and platform_system == 'Windows'`

This means that `tensorflow-cpu-aws` and `tensorflow-intel` can never be
installed, and we can drop them from the lockfile.
2024-09-04 10:57:42 +02:00
Charlie Marsh
3d75df6ab2
Bump version to v0.4.4 (#6988) 2024-09-04 00:30:38 +00:00
Zanie Blue
2a425152b9
Add warning when VIRTUAL_ENV is set but will not be respected in project commands (#6864)
Following https://github.com/astral-sh/uv/pull/6834
2024-09-03 19:51:43 -04:00
Charlie Marsh
50d7b9c38a
Pin .python-version in uv init (#6869)
## Summary

I'm not convinced that the behavior is correct as-implemented. When the
user passes a `--python >=3.8` or we discover a `requires-python` from
the workspace, we're currently writing that request out to
`.python-version`. I would probably rather that we write the resolved
patch version?

Closes https://github.com/astral-sh/uv/issues/6821.
2024-09-03 19:43:50 -04:00
Zanie Blue
71d9ecd644
Use a consistent pattern for uv add and uv remove tests (#6978)
Noticed during #6976 — I'd rather we just used a consistent pattern
here.

Looks like this was added in 2b68a3d17a
2024-09-03 19:33:35 -04:00
Andrew Gallant
8403a6d102 uv/tests: remove double-escaping
And otherwise make the regexes a little more robust.
2024-09-03 18:41:15 -04:00
Andrew Gallant
95d63120ae uv/tests: add test specific filters
This is to account for slight differences on our Windows CI.
2024-09-03 18:41:15 -04:00
Andrew Gallant
811207cb19 uv/tests: remove double-escaping
The key change here is to use raw strings so that we don't need to
double-escape things like `\d`. And in particular, we rely on the fact
that `"\n"` and `r"\n"` are precisely equivalent when fed to
`Regex::new` in the `regex` crate.
2024-09-03 18:41:15 -04:00
Andrew Gallant
04d35106bf uv/tests: fix windows-only dependency filter
Previously we were using `[+-~]`, but this includes the full range of
characters from `+` to `~`. Incidentally, this does include `-`. We
instead rewrite this as `[-+~]`, which probably matches the intent.
2024-09-03 18:41:15 -04:00
Andrew Gallant
7516b0902a uv/tests: update snapshot for regression test
The `importlib-metadata` is no longer unconditionally repeated in the
output for Python 3.10 (or Python 3.7).

Fixes #6836
2024-09-03 18:41:15 -04:00
Andrew Gallant
7ad5e299cc uv/tests: update snapshot for regression test
The `tomli` dependency is now included for `python_version <= 3.11`,
which is what is expected.

Fixes #6412
2024-09-03 18:41:15 -04:00