Commit graph

2522 commits

Author SHA1 Message Date
Charlie Marsh
097acb628d
Remove Simple API cache files for alternative indexes in cache clean (#5353)
## Summary

The `simple-v9` directory was missing the `index` segment. See before:


![Screenshot 2024-07-23 at 1 29
18 PM](https://github.com/user-attachments/assets/3af9ccbf-ba45-4910-ad3b-4f52806dc8c9)

And after:

![Screenshot 2024-07-23 at 1 29
38 PM](https://github.com/user-attachments/assets/15535534-3304-4209-93e8-7f5e572929f0)

Every other bucket has this `index` segment for non-PyPI indexes, e.g.:

![Screenshot 2024-07-23 at 1 29
24 PM](https://github.com/user-attachments/assets/7354c9ad-7757-4a5f-a7b8-ff987a100e39)

Closes https://github.com/astral-sh/uv/issues/5352.
2024-07-23 13:42:51 -04:00
Zanie Blue
5f1f9c8293
Add support for requirements files in uv run (#4973)
Closes https://github.com/astral-sh/uv/issues/4824.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-07-23 12:51:09 -04:00
Charlie Marsh
8ebc0d56c7
Fix failing prerelease tests (#5346)
## Summary

Likely due to simultaneous merge.
2024-07-23 12:45:55 -04:00
eth3lbert
e05d653a71
Show symbolic links in uv python list (#5343)
## Summary

This PR displays symbolic links in `uv python list` and produces output
similar to the following:

```
:) uv python list --preview
cpython-3.12.1-macos-aarch64-none     /Users/eth/workspace/astral-sh/uv/bin/python3.12 -> versions/cpython@3.12.1/install/bin/python3
cpython-3.12.1-macos-aarch64-none     /Users/eth/workspace/astral-sh/uv/bin/python3 -> versions/cpython@3.12.1/install/bin/python3
cpython-3.12.1-macos-aarch64-none     /Users/eth/workspace/astral-sh/uv/bin/python -> versions/cpython@3.12.1/install/bin/python3
cpython-3.11.7-macos-aarch64-none     /Users/eth/workspace/astral-sh/uv/bin/python3.11 -> versions/cpython@3.11.7/install/bin/python3
cpython-3.10.13-macos-aarch64-none    /Users/eth/workspace/astral-sh/uv/bin/python3.10 -> versions/cpython@3.10.13/install/bin/python3
cpython-3.9.18-macos-aarch64-none     /Users/eth/workspace/astral-sh/uv/bin/python3.9 -> versions/cpython@3.9.18/install/bin/python3
cpython-3.8.18-macos-aarch64-none     /Users/eth/workspace/astral-sh/uv/bin/python3.8 -> versions/cpython@3.8.18/install/bin/python3

```


Resolves #5308 

## Test Plan

```
$ cargo run python list
```
2024-07-23 11:41:29 -05:00
Charlie Marsh
0f8186d9ad
Add requires-python to uv init (#5322)
## Summary

Prefers, in order:

- The major-minor version of an interpreter discovered via `--python`.
- The `requires-python` from the workspace.
- The major-minor version of the default interpreter.

If the `--python` request is a version or a version range, we use that
without fetching an interpreter.

Closes https://github.com/astral-sh/uv/issues/5299.
2024-07-23 16:02:40 +00:00
Ibraheem Ahmed
c8ac8ee57a
Allow conflicting prerelease strategies when forking (#5150)
## Summary

Similar to https://github.com/astral-sh/uv/pull/5232, we should also
track prerelease strategies per-fork, instead of globally per package.
The common functionality for tracking locals and prerelease versions
across forks is extracted into the `ForkMap` type.

Resolves https://github.com/astral-sh/uv/issues/4579. This doesn't quite
solve https://github.com/astral-sh/uv/issues/4959, as that issue relies
on overlapping markers.
2024-07-23 11:57:14 -04:00
konsti
bea8bc6c61
Stable sorting of requirements.txt in universal mode (#5334)
The `RequirementsTxtComparator` was written assuming there is one
distribution per package name. This changed with the universal
resolution, which allows multiple versions or urls for the same package
name. The sorting we emitted for these new entries was incidental.

With this change, we properly sort these entries by name, version and
then url in universal mode.

This is an output format change for `--universal` users.
2024-07-23 16:46:32 +02:00
Jo
43084249ee
Add mypy type check for uv-python scripts (#5332)
## Summary

Per https://github.com/astral-sh/uv/pull/4853#issuecomment-2212505407

> If we're going to aim for full type coverage, we should probably
follow this by adding type checking in CI too otherwise it seems too
easy for it to become out of date.
2024-07-23 09:14:05 -05:00
Jo
025f2f3162
Fix python-build-standalone workflow (#5327)
## Summary

The script reads `GITHUB_TOKEN` instead. And since #4853 merged, there
is no need to use `uv run --with`.
2024-07-23 08:20:36 -04:00
eth3lbert
df7a733e51
Fix uv init . (#5330)
## Summary

This PR avoids an `Invalid package name` error that occurs when using
`uv init .`. This is achieved by slightly reorganizing the code block to
determine the name after the path is canonicalized. The dot path is
expanded to the current directory, and the `file_name` then works as
expected.

Resolve #5329 .

---------

Co-authored-by: konstin <konstin@mailbox.org>
2024-07-23 08:20:13 -04:00
samypr100
166fe85bb7
feat: fix uv-trampoline renovate issues (#5204)
## Summary

1. Fixes errors from https://github.com/astral-sh/uv/pull/4878
2. More cleanup. Removed the need for `MaybeUninit` and `SizeOf`
helpers. Renamed main entrypoint to expected default in windows
`mainCRTStartup` to avoid re-declaring /ENTRY in build.rs.
3. Adds a small basic test harness that >>on windows<< will generate
both types of launchers and run them. I've had been using this locally
to test changes and edge cases, but it might be useful for others. It's
based on core parts of install-wheel-rs.

## Test Plan

Tested locally on a couple of script/gui apps.

---------

Co-authored-by: konsti <konstin@mailbox.org>
2024-07-23 10:12:28 +02:00
Charlie Marsh
e61fcbd7af
Improve consistency of tool CLI (#5326)
## Summary

More consistent colors, etc.
2024-07-23 03:10:47 +00:00
Jo
0a6efe4d26
Refactor fetch-download-metadata.py script (#4853)
## Summary

Similiar to https://github.com/astral-sh/rye/pull/680, I have made a
major refactor to the `fetch-download-metadata.py` script.

Some notable changes:

- Use PEP 723 inline scripts
- Fully type annotated the script
- Implemented async HTTP fetching
- Introduced a `Finder` base class and move finder logic under
`CPythonFinder` subclass, which will make it easier to add a
`PyPyFinder` later.
- Instead of fetching `xxx.sha256` for each file, the script now fetches
a single `SHA256SUMS` file containing checksums for all files in the
release.

As a result, the script now takes around 10 seconds instead of 10+
minutes.

## Plan for Future PRs

- [ ] Implement the `PyPyFinder`
- [ ] Add an GitHub Action to run `fetch-download-metadata.py` daily and
create PR automatically

## Test Plan

```sh
cargo run -- run --isolated -- ./crates/uv-python/fetch-download-metadata.py
```
2024-07-23 03:06:25 +00:00
Zack Elia
f371195536
Allow symlinks with --find-links (#5323)
## Summary

In my setup, I have a directory of wheels symlinked from different
directories. I can point `--find-links` at it with `pip` and it works
but not `uv`.

Currently, `uv` checks if a candidate file `is_file` which is for
regular files. By also checking `is_symlink` I was able to install a
symlinked wheel. I'm not *exactly* sure where, but some other place is
eventually resolving the absolute path of the wheel. (`uv`? The OS?)

## Test Plan

Manually tested - I didn't see any tests for `FlatIndexClient` in the
`uv-client` crate.

```
mkdir /tmp/a /tmp/b                               # Create a directory of wheels (/tmp/a) and a directory of symlinked wheels (/tmp/b)
cp test-0.0.1-py3-none-any.whl /tmp/a             # Add a wheel to the directory of wheels
ln -s /tmp/a/test-0.0.1-py3-none-any.whl /tmp/b/  # Create a symlink to that wheel
uv pip install test --find-links /tmp/b           # Install pointing at the symlinked wheels directory
```
2024-07-23 02:53:39 +00:00
Charlie Marsh
41ca3572ab
Avoid redundant members update in uv init (#5321)
## Summary

If the path is already covered by `members`, we don't need to update it.

Closes https://github.com/astral-sh/uv/issues/5320.
2024-07-23 00:25:20 +00:00
Charlie Marsh
2f768b8bb0
Respect exclusions in uv init (#5318)
## Summary

Avoid adding to the workspace.

Closes https://github.com/astral-sh/uv/issues/5254.
2024-07-23 00:15:17 +00:00
Charlie Marsh
13dd8853d9
Create member pyproject.toml prior to workspace discovery (#5317)
## Summary

Otherwise, if the path is already a member, discovery fails.

Also adds a failing test for "adding members that are already covered by
`members`".
2024-07-23 00:03:53 +00:00
Jo
d232bfea00
uv init should not create nested workspace (#5293)
## Summary

Resolves #5251
2024-07-22 19:48:40 -04:00
Charlie Marsh
26e042a794
Include URLs on graph edges (#5312)
## Summary

Excellent find from @konstin. If we have a package that's included in
two forks at the same version, but with different URLs, we need to avoid
collapsing them in the lockfile.

Closes https://github.com/astral-sh/uv/issues/5294.
2024-07-22 22:41:03 +00:00
Zanie Blue
4f9ac3b61d
Fix test snapshot (#5314)
Fixes failure on `main` from merge conflict
2024-07-22 21:32:16 +00:00
Charlie Marsh
84b351a289
Avoid including empty extras in resolution (#5306)
## Summary

You can still generate instabilities, but at least it's consistent
between including and excluding the extra.

For example, this resolves to 54 and then 52 packages on re-run:

```toml
[project]
name = "transformers"
version = "4.39.0.dev0"
description = "State-of-the-art Machine Learning for JAX, PyTorch and TensorFlow"
requires-python = ">=3.9.0"

dependencies = []

[project.optional-dependencies]
flax = ["jaxlib>=0.4.1,<=0.4.13"]
onnxruntime = ["onnxruntime>=1.4.0"]
ray = ["ray[tune]>=2.7.0"]
deepspeed-testing = [
  "dill<0.3.5",
  "datasets!=2.5.0",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
```

I think the difference is just somewhere in PubGrub -- like, we add an
extra dependency, so the iteration order gets changed, and we end up
with a different resolution at the end.

Closes https://github.com/astral-sh/uv/issues/5285.
2024-07-22 15:57:53 -04:00
Jo
f00c3f26a2
uv init ignores workspace when --isolated flag is used (#5290)
## Summary

Per https://github.com/astral-sh/uv/pull/5250#issuecomment-2242137762

> It would also be great to have an argument (perhaps leveraging the
global isolated option) that allows us to disable workspace discovery
when we don't want to add a project as a member.


## Test Plan

```sh

$cargo run -- init work
$ cargo run -- init work/pkg-a --isolated
warning: `uv init` is experimental and may change without warning
Initialized project sub-c in /tmp/work
```
2024-07-22 15:13:05 -04:00
konsti
0a95b7abcd
Simplify Resolution type (#5301)
Looking at how to merge identical forks, i found that the `Resolution`
can be simplified by treating it as a nodes and edges store (plus pins,
they are separate since they are per name-version, not per
(virtual-)package-version). This should also make #5294 more apparent,
which i didn't touch here.

I additionally added some doc comments to the `Resolution` types.
2024-07-22 15:10:30 -04:00
konsti
e207a909ad
Slim down solve (#5300)
Our everything-method `solve` tends to grow large, so before i'm adding
more logic, i'm moving some code and some logging statements around to
keep it manageable.

I made minor changes to the logging, otherwise no logic changes, only
refactoring.
2024-07-22 20:52:45 +02:00
Charlie Marsh
613f16abd4
Make tool install robust to malformed receipts (#5305)
## Summary

Closes https://github.com/astral-sh/uv/issues/5295
2024-07-22 18:46:57 +00:00
Charlie Marsh
ca46ce2791
Remove extraneous are from wheel tag error messages (#5303)
## Summary

Closes #5297.
2024-07-22 18:42:58 +00:00
Charlie Marsh
2d9df488ef
Use tag error rather than requires-python error for ABI filtering (#5296)
## Summary

`dearpygui==1.9.1 has no wheels are available with a matching Python
ABI` is way better than `he requested Python version (>=3.12.3) does not
satisfy Python>=3.12.3`.

Closes https://github.com/astral-sh/uv/issues/5284.
2024-07-22 18:31:08 +00:00
Zanie Blue
8d12a660c4
Use backticks in project init message (#5302) 2024-07-22 18:18:37 +00:00
Yorick
0c4627e2f2
If multiple indices contain the same version, use the first index (#5288)
This fixes resolving packages that publish an invalid stub to pypi, such
as tensorrt-llm.

## Summary

In https://github.com/astral-sh/uv/pull/3138 , we implemented
`unsafe-best-match`. However, it seems to not quite work as expected.
When multiple indices contain the same version, it's not clear which
index the current code uses. This PR fixes that to use the first index
the package is in.

## Test Plan

```console
$ echo 'tensorrt-llm==0.11.0' | ./target/debug/uv pip compile - --extra-index-url https://pypi.nvidia.com --python-version=3.10 --index-strategy=unsafe-best-match --annotation-style=line
```
2024-07-22 14:03:30 -04:00
Jo
c52b767474
uv init normalize directory name (#5292)
## Summary

Resolves #5255
2024-07-22 16:09:24 +00:00
Charlie Marsh
b6f470416e
Match wheel tags against Requires-Python major-minor (#5289)
## Summary

Given `Requires-Python: ">=3.12.3"`, we were rejecting wheels like
`dearpygui-1.11.1-cp312-cp312-win_amd64.whl`, since `3.12.0` is not
included in `>=3.12.3`. We instead need to test against the major-minor
version of `Requires-Python`.

The easiest way to do this, I think, is the use the `RequiresPython`
struct, which has a single bound that we can truncate the major-minor.
This also means that we now allow
`dearpygui-1.11.1-cp312-cp312-win_amd64.whl` for specifiers like
`Requires-Python: "==3.10.*"`. This is incorrect on the surface, but it
does match our semantics for `Requires-Python` elsewhere: we treat it as
a lower bound.

Closes https://github.com/astral-sh/uv/issues/5287.
2024-07-22 14:33:53 +00:00
Pavel Dikov
8f26f379d1
fix(pip.install.wheel): support variations on pythonw.exe (#5259)
Emulate `pip`'s behaviour and find `pythonw` executable by doing an
`s/python/pythonw/g` style transformation, as opposed to assuming a
constant `pythonw.exe` path.

See #5256 for more detail e.g. why this is a useful behaviour to
emulate.

Fixes: #5256
2024-07-22 10:28:20 -04:00
Charlie Marsh
479725920d
Avoid cache prune failure due to removed interpreter (#5286)
## Summary

`uv cache prune` can fail if an ephemeral environment includes a
non-existent interpreter, since we then fail to read the symlink.
2024-07-22 13:46:24 +00:00
Charlie Marsh
5a23f05799
Store resolution options in lockfile (#5264)
## Summary

This PR modifies the lockfile to include the impactful resolution
settings, like the resolution and pre-release mode. If any of those
values change, we want to ignore the existing lockfile. Otherwise,
`--resolution lowest-direct` will typically have no effect, which is
really unintuitive.

Closes https://github.com/astral-sh/uv/issues/5226.
2024-07-22 08:28:22 -04:00
Jo
178300d16b
uv init discovers workspace from the target path (#5250)
## Summary

Resolves #5249

## Test Plan
2024-07-22 13:43:04 +02:00
Charlie Marsh
d798bb3973
Avoid always rebuilding dynamic metadata (#5206)
## Summary

I don't think that "always reinstall" is tenable for `uv run`. My
perspective on this is that if you want "always reinstall", you can now
set it persistently in your `pyproject.toml` or `uv.toml`.

As a smaller change, we could instead disable this _only_ for the
Project API.

Closes https://github.com/astral-sh/uv/issues/4946.
2024-07-22 00:04:03 +00:00
Di-Is
32ad3323a1
Add constraint dependencies to pyproject.toml (#5248)
Resolves #4467.

## Summary

This PR implements the following

1. Add `tool.uv.constraint-dependencies` to pyproject.toml
1. Support to refer `tool.uv.constraint-dependencies` in `uv lock`
1. Support to refer `tool.uv.constraint-dependencies` in `uv pip
compile/install`

These are analogues of the override features implemented in #3839 and
#4369.

## Test Plan

Add test.
2024-07-21 19:45:04 -04:00
Charlie Marsh
a917cdba51
Fix colors in uv tool run suggestion (#5267)
## Summary

More consistent with other commands.

Before:

![Screenshot 2024-07-21 at 2 22
18 PM](https://github.com/user-attachments/assets/9f6dfc7d-3c54-47a4-9b9f-bdf3794ae06d)

Now: all cyan, and green command, following the style guide.
2024-07-21 23:43:27 +00:00
Charlie Marsh
5c3d55afa8
Remove unused error variant (#5266) 2024-07-21 23:38:45 +00:00
Chan Kang
12518a01a4
Implement --show-version-specifiers for tree (#5240)
## Summary
resolves https://github.com/astral-sh/uv/issues/5217

## Test Plan
existing tests pass (should be perfectly backwards compatible) + added a
few tests to cover the new functionality. in particular, in addition to
the simple use of `--show-version-specifiers`, its interaction with
`--invert` and `--package` flags are tested.
2024-07-20 18:31:16 +00:00
Jo
48921f9455
Fix uv init a sub-package by path (#5247)
## Summary

Resolves #5242

## Test Plan

See the [CI
failure](2769863030)
for the new failing test.
2024-07-20 10:47:11 -05:00
Jo
0611c7b59e
Add uv add --no-editable (#5246)
## Summary

Resolves #5241

## Test Plan

```sh
# create a workspace with sub-packages `pkg-a` and `pkg-b`

$ cd ./pkg-b
$ cargo run -- add ./pkg-a --no-editable

$ cat ./pyproject.toml
[project]
name = "pkg-b"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
dependencies = [
    "pkg-a",
]

[tool.uv]
dev-dependencies = []

[tool.uv.sources]
pkg-a = { workspace = true, editable = false }
```
2024-07-20 09:11:34 -04:00
Charlie Marsh
841edc3718
Move workspace abstractions to uv-workspace crate (#5236)
## Summary

These are really different from the rest of the existing crate as
evidenced by the bifurcation in the requirements.
2024-07-20 02:15:32 +00:00
Charlie Marsh
1243c5e28c
Avoid URL parsing when deserializing wheels (#5235)
## Summary

This PR slots in `UrlString` for `WheelWire`, which IIUC should avoid
parsing URLs during deserialization?
2024-07-20 02:11:26 +00:00
Zanie Blue
833097b93f
Bump version to 0.2.27 (#5230) 2024-07-19 22:06:49 +00:00
Ibraheem Ahmed
bb73edb03b
Respect local versions for all user requirements (#5232)
## Summary

This fixes a few bugs introduced by
https://github.com/astral-sh/uv/pull/5104. I previously thought we could
track conflicting locals the same way we track conflicting URLs in
forks, but it turns out that ends up being very tricky. URL forks work
because we prioritize directly URL requirements. We can't prioritize
locals in the same way without conflicting with the URL prioritization
(this may be possible but it's not trivial), so we run into issues where
a correct resolution depends on the order in which dependencies are
traversed.

Instead, we track local versions across all forks in `Locals`. When
applying a local version, we apply all locals with markers that
intersect with the current fork. This way we end up applying some local
versions without creating a fork. For example, given:
```
// pyproject.toml
dependencies = [
    "torch==2.0.0+cu118 ; platform_machine == 'x86_64'",
]

// requirements.in
torch==2.0.0
.
```

We choose `2.0.0+cu118` in all cases. However, if a disjoint fork is
created based on local versions, the resolver will choose the most
compatible local when it narrows to a specific fork. Thus we correctly
respect local versions when forking:
```
// pyproject.toml
dependencies = [
    "torch==2.0.0+cu118 ; platform_machine == 'x86_64'",
    "torch==2.0.0+cpu ; platform_machine != 'x86_64'"
]

// requirements.in
torch==2.0.0
.
``` 

We should also be able to use a similar strategy for
https://github.com/astral-sh/uv/pull/5150.

## Test Plan

This fixes https://github.com/astral-sh/uv/issues/5220 locally for me,
as well as a few other bugs that were not reported yet.
2024-07-19 16:56:09 -05:00
Charlie Marsh
a253913288
Don't apply irrelevant constraints when validating site-packages (#5231)
## Summary

The current code was checking every constraint against every
requirement, regardless of whether they were applicable. In general,
this isn't a big deal, because this method is only used as a fast-path
to skip resolution -- so we just had way more false-negatives than we
should've when constraints were applied. But it's clearly wrong :)

## Test Plan

- `uv venv`
- `uv pip install flask`
- `uv pip install --verbose flask -c constraints.txt` (with `numpy<1.0`)

Prior to this change, Flask was reported as not satisfied.
2024-07-19 20:49:22 +00:00
Ahmed Ilyas
3ee3db23d6
Check python pin compatibility with Requires-Python (#4989)
## Summary

Resolves #4969 

## Test Plan

`cargo test` and manual tests.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-07-19 18:17:41 +00:00
Charlie Marsh
7762d78281
Add color to python pin CLI (#5215)
## Summary

![Screenshot 2024-07-19 at 9 03
10 AM](https://github.com/user-attachments/assets/5668bd23-3f09-4964-bc09-9f3788f5a841)
2024-07-19 13:19:28 -04:00
Ibraheem Ahmed
12dd450a8e
Implement uv init (#4791)
## Summary

Implements the `uv init` command, which initializes a project
(`pyproject.toml`, `README.md`, `src/__init__.py`) in the current
directory, or in the given path. `uv init` also does workspace
discovery.

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

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-07-19 15:11:48 +00:00