Commit graph

4903 commits

Author SHA1 Message Date
Andrew Gallant
7fce59e4bc pep508: some simplification in 'and' and 'or'
Basically, and'ing or or'ing the same expression can be entire
skipped. And we try harder to avoid singleton conjunctions or
disjunctions, as these are considered unequal otherwise. (Thus
defeating our attempts to avoid and'ing or or'ing a superfluous
marker.)
2024-07-26 07:28:20 -07:00
Charlie Marsh
8b8f34ac21
Avoid canonicalizing executables on Windows (#5446)
## Summary

If you have an executable path on a network share path (like
`\\some-host\some-share\...\python.exe`), canonicalizing it adds the
`\\?` prefix, but dunce cannot safely strip it.

This PR changes the Windows logic to avoid canonicalizing altogether. We
don't really expect symlinks on Windows, so it seems unimportant to
resolve them.

Closes: https://github.com/astral-sh/uv/issues/5440.
2024-07-26 08:57:33 -04:00
Charlie Marsh
967fcdbb83
Update bundled Pythons to include stripped variants (#5469)
## Summary

The previous update used a slightly botched release.
2024-07-26 00:34:45 +00:00
Charlie Marsh
d51b429837
Add --no-config to replace --isolated (#5463)
## Summary

I'll deprecate `--isolated` separately, since it _is_ still used for
some other behaviors.

Closes #5428.
2024-07-25 19:58:36 -04:00
Charlie Marsh
8cb22f5500
Gate FromStr to pep508 feature (#5464)
## Summary

This is triggering when you run without `--all-features` (but we always
use `--all-features` in CI, so it went unnoticed).
2024-07-25 23:54:07 +00:00
Charlie Marsh
e4d1039f49
Use sitecustomize.py to implement environment layering (#5462)
## Summary

After consultation with @carljm, we learned that modifying `PYTHONPATH`
is insufficient, because Python won't resolve `.pth` files (editables)
in the base environment. We also saw in
https://github.com/astral-sh/uv/issues/5459 that continuously appending
to `PYTHONPATH` can have some unintended effects.

This PR instead uses a `sitecustomize.py` in the ephemeral environment
to add the base environment's `site-packages`.

Closes https://github.com/astral-sh/uv/issues/5459.
2024-07-25 19:32:44 -04:00
Charlie Marsh
6f45403d31
Infer missing .exe in Windows Python discovery (#5456)
## Summary

Closes https://github.com/astral-sh/uv/issues/5445.
2024-07-25 16:57:38 -04:00
Charlie Marsh
1e965b47c3
Set standard permissions for temporary files (#5457)
## Summary

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

## Test Plan

Before:

```
❯ ls -l .venv/lib/python3.12/site-packages/httpx-0.27.0.dist-info
total 48
-rw-------  1 crmarsh  staff     2 Jul 25 14:21 INSTALLER
-rw-r--r--  1 crmarsh  staff  7184 Jul 23 23:20 METADATA
-rw-r--r--  1 crmarsh  staff  2541 Jul 25 14:21 RECORD
-rw-------  1 crmarsh  staff     0 Jul 25 14:21 REQUESTED
-rw-r--r--  1 crmarsh  staff    87 Jul 23 23:20 WHEEL
-rw-r--r--  1 crmarsh  staff    37 Jul 23 23:20 entry_points.txt
drwxr-xr-x  3 crmarsh  staff    96 Jul 25 14:21 licenses
```

After:

```
❯ ls -l .venv/lib/python3.12/site-packages/flask-3.0.3.dist-info/
total 48
-rw-r--r--  1 crmarsh  staff     2 Jul 25 14:21 INSTALLER
-rw-r--r--  1 crmarsh  staff  1475 Jul 25 14:21 LICENSE.txt
-rw-r--r--  1 crmarsh  staff  3177 Jul 25 14:21 METADATA
-rw-r--r--  1 crmarsh  staff  2565 Jul 25 14:21 RECORD
-rw-r--r--  1 crmarsh  staff     0 Jul 25 14:21 REQUESTED
-rw-r--r--  1 crmarsh  staff    81 Jul 25 14:21 WHEEL
-rw-r--r--  1 crmarsh  staff    40 Jul 25 14:21 entry_points.txt
```
2024-07-25 20:50:30 +00:00
Charlie Marsh
75a042d5ff
Allow distributions to be absent in deserialization (#5453)
## Summary

Closes https://github.com/astral-sh/uv/issues/5434.
2024-07-25 18:01:41 +00:00
Zanie Blue
6eb8f85668
Update documentation sections (#5452)
Reframes "the low-level interface" as "the pip interface"
Adds indexes to all sections
Renames "commercial indexes" to "alternative indexes"
2024-07-25 12:37:22 -05:00
Charlie Marsh
a089e20a35
Use stripped variants by default in Python install (#5451)
## Summary

Will file a separate ticket to support `--debug`.

Closes https://github.com/astral-sh/uv/issues/5447.
2024-07-25 17:29:31 +00:00
Ibraheem Ahmed
4da34a6e2e
Reorganize pep508 marker module (#5433)
## Summary

Just moves some code around into separate modules, the current file is a
bit too large to navigate.
2024-07-25 15:22:46 +00:00
Andrew Gallant
7dff3d7dfe uv/tests: updates snapshots for main
It looks like we had a bad merge where the result caused some test
failures. This commit just updates the snapshots to the new reality. I
haven't found the root cause of the bad merge yet.
2024-07-25 07:42:26 -07:00
InSync
d17b18ee1e
Minor consistency fixes for code blocks (#5437)
...as well as some typo fixes. I verified the changes manually.
2024-07-25 09:23:22 -05:00
Zanie Blue
42e76e2545
Prefer "lockfile" to "lock file" (#5427)
Closes https://github.com/astral-sh/uv/issues/5415
2024-07-25 09:22:36 -05:00
Charlie Marsh
d0919329fd
Make --reinstall imply --refresh (#5425)
## Summary

It's hard for me to imagine a scenario in which a user passed
`--reinstall`, but wanted us to keep respecting cached data for a
package. For example, to actually "rebuild and reinstall" an editable
today, you have to pass both `--reinstall` and `--refresh`.

This PR makes `--reinstall` imply `--refresh`, so we always validate
that the cached data is fresh.

Closes https://github.com/astral-sh/uv/issues/5424.
2024-07-25 09:45:58 -04:00
Charlie Marsh
4d9098a1d7
Cache metadata for source tree dependencies (#5423)
## Summary

This PR re-introduces caching for source trees. In short, we treat the
metadata as cached unless the `pyproject.toml`, `setup.py`, or
`setup.cfg` file changes. This is a heuristic and not a good one,
especially for extension modules, but without it, we have to rebuild
every project every time (unless you have static metadata, like a
`pyproject.toml` that we can read directly).

Now that we support persistent configuration, users should add:

```toml
[tool.uv]
reinstall = ["foo"]
```

If they want a package to always be refreshed (ignore cache) and
reinstalled (ignore environment).

Closes https://github.com/astral-sh/uv/issues/5420.
2024-07-25 09:45:52 -04:00
konsti
375a4152fa
Split ResolutionGraph::from_state into methods (#5439)
Two changes split out from the instability work:

* Break `ResolutionGraph::from_state` into methods before adding new
logic to it.
* `ResolutionGraph`: Convert `NodeKey` type to `PackageRef` struct:
Another small refactoring to make subsequent changes easier.

No functional changes.

@BurntSushi I hope this doesn't interfere with your work too much, the
`PackageRef` should at least make debugging panics here easier.
2024-07-25 14:40:09 +02:00
konsti
f1dadbe3c6
Restructure CandidateSelector methods (#5438)
In preparation for the preferences changes with forking, change the
method structure in `CandidateSelector`. Split out into its own PR to
avoid merge conflicts with main. No functional changes.
2024-07-25 10:26:15 +00:00
konsti
93fb28fd2c
Merge identical forks (#5405)
Consider these requirements from pylint 3.2.5:

```
Requires-Dist: dill >=0.3.6 ; python_version >= "3.11"
Requires-Dist: dill >=0.3.7 ; python_version >= "3.12"
```

We will split on the python version, but then we may pick a version of
`dill` that's `>=0.3.7` in both branches and also have an otherwise
identical resolution in both forks. In this case, we merge both forks
and store only their conjoined markers.
2024-07-25 11:54:54 +02:00
Ibraheem Ahmed
39be71f403
Normalize marker expression order (#5422)
## Summary

Normalize the order of marker expressions on construction. This removes
the distinction between expressions like `os_name == 'Linux'` vs.
`'Linux' == os_name` throughout the codebase. One caveat here is that
the `in` operator does not have a direct inverse, so we introduce
`MarkerOperator::Contains` to handle that case.

I wanted to land this smaller change before some more intrusive changes
as it simplifies the existing code quite a bit.
2024-07-24 18:28:34 -04:00
Zanie Blue
35b6726df5
Bump version to 0.2.29 (#5431) 2024-07-24 22:23:34 +00:00
Zanie Blue
3581e27cdf
Bundle of docs changes (#5426) 2024-07-24 17:10:33 -05:00
Zanie Blue
ac81036aa9
Use logo in documentation (#5421)
Before
<img width="728" alt="Screenshot 2024-07-24 at 3 12 28 PM"
src="https://github.com/user-attachments/assets/2ad83857-a2a5-4c33-9fb2-f2580ccb10af">

After
<img width="728" alt="Screenshot 2024-07-24 at 3 11 07 PM"
src="https://github.com/user-attachments/assets/dd209d37-3761-4b28-8ca9-9bf7546236a8">

Alternatively
<img width="728" alt="Screenshot 2024-07-24 at 3 10 45 PM"
src="https://github.com/user-attachments/assets/88f9cc62-71ec-457c-b946-3168502d46c3">
2024-07-24 15:45:10 -05:00
Charlie Marsh
d11d11ef88
Validate successful metadata fetch for direct dependencies (#5392)
## Summary

Prior to this change, the resolver would panic if we ran with
`--offline` and `--no-deps` and we had cached metadata for a _package_
(i.e., the versions) but no cached metadata for the _distribution_
(i.e., the specific wheel), since we weren't validating that the
returned metadata in the `--no-deps` case was actually successful. (We
need metadata, even for `--no-deps`, so that we can validate extras.)

## Test Plan

The added test panics on the previous branch.
2024-07-24 19:44:41 +00:00
Ahmed Ilyas
b304d66719
Use env variables in Github Actions docs (#5411)
## Summary

Use [Github
Actions](https://docs.github.com/en/actions/learn-github-actions/variables#defining-environment-variables-for-a-single-workflow)
`env` to define environment variables.

After:
<img width="751" alt="Screenshot 2024-07-24 at 17 24 23"
src="https://github.com/user-attachments/assets/9c7861f0-e95d-4778-96c0-261df539a0bd">
2024-07-24 14:37:52 -05:00
Charlie Marsh
4bc04f91e9
Add --ci mode to uv cache prune (#5391)
## Summary

Users can now run `uv cache prune --ci` (open to feedback on the name of
that flag) to remove all pre-built wheels from the cache, leaving behind
zipped, built wheels (which tend to be the most expensive assets to
re-create). This should greatly increase cache performance in CI
environments, since uploading unzipped wheels can actually hurt
performance if you're persisting the uv cache.

Closes https://github.com/astral-sh/uv/issues/5282.
2024-07-24 19:34:19 +00:00
Charlie Marsh
fff3a7d8f9
Always accept already-installed pre-releases (#5419)
## Summary

If a pre-release is already installed, we should allow it to be used
even if it doesn't match the strategy.

Closes https://github.com/astral-sh/uv/issues/5418.
2024-07-24 19:23:14 +00:00
Jo
7bcafec778
Add uv init --virtual (#5396)
## Summary

Add `uv init --virtual` to create an explicit virtual workspace.

Relates to #5338
2024-07-24 18:52:33 +00:00
Andrew Gallant
ac614ee70f uv/tests: tweak cache clean all test
The test asserts that 28 files were removed. But on my system, 27 files
are removed.

This PR is first about debugging what the difference is (since CI
presumably passes with the status quo snapshot). And then I'm thinking
the right way to fix the test failure is with a filter that replaces the
specific number of files removed (limited to what we know to be
correct) with a placeholder.
2024-07-24 10:41:33 -07:00
Charlie Marsh
9c9510c9ef
Ignore hidden directories in workspace discovery (#5408)
## Summary

This is surprisingly complex because we need to decide what happens if
you run `uv run` from within a hidden folder, etc. For now, I did the
simplest thing: we just ignore workspace members that are hidden
directories if they lack a `pyproject.toml`, so you can still include
hidden members, they're just ignored if they don't seem to be projects.

Closes https://github.com/astral-sh/uv/issues/5403.
2024-07-24 16:21:34 +00:00
Charlie Marsh
22db997240
Always show lock updates in uv lock (#5413)
## Summary

Closes https://github.com/astral-sh/uv/issues/5412.
2024-07-24 15:54:18 +00:00
Charlie Marsh
3d36b71ab1
Show additions and removals in uv lock updates (#5410)
## Summary

Closes https://github.com/astral-sh/uv/issues/5401.
2024-07-24 15:33:09 +00:00
Zanie Blue
eef7a78d7e
Omit interpreter path from output when using managed Python (#5313)
Extending https://github.com/astral-sh/uv/pull/5311 to the project API
2024-07-24 10:19:12 -05:00
Trevor Manz
d642705104
Omit empty uv.tool.dev-dependencies on uv init (#5406)
<!--
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

Implements #5340

## Test Plan

<!-- How was it tested? -->
2024-07-24 09:53:49 -05:00
Charlie Marsh
cf971a86d7
Remove resolved TODO in uv run (#5407) 2024-07-24 09:54:16 -04:00
konsti
9b12fcb90d
Remove outdated DistributionWire serde annotations (#5400)
This struct doesn't implement `serde::Serialize`, the annotations are
dead.
2024-07-24 15:30:58 +02:00
Charlie Marsh
82f4864386
Ignore Ctrl-C signals in uv run and uv tool run (#5395)
## Summary

This is a bit simpler than #5333, but seems to work in my testing on
macOS and Windows. It's based on implementations that I found in
[Pixi](36f1bb297d/src/cli/exec.rs (L99))
and
[Wasmer](49e60af8df/lib/wasix/src/state/builder.rs (L1058)).

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

## Test Plan

On both macOS and Windows:

- `cargo run -- tool run --from jupyterlab jupyter-lab` -- hit Ctrl-C;
verify that the process exits and the terminal is left in a good state.
- `cargo run -- run python` -- hit Ctrl-C; verify that the process does
_not_ exit, but does on Ctrl-D.
2024-07-24 08:33:10 -04:00
konsti
20018cd0fc
Add two ForkState methods (#5404)
Small refactoring split out of the instability work. No functional
changes.
2024-07-24 12:09:33 +00:00
konsti
6d34f53ee5
Update Resolution docs (#5402)
They didn't reflect the recent nodes/edges changes.
2024-07-24 11:39:48 +00:00
Jo
62e72f51ff
Remove an extra quote in sync-python-releaes.yml (#5393) 2024-07-24 02:53:00 +00:00
Jo
17d63b0e07
Update python-build-standalone workflow (#5390)
## Summary

After #5337, `fetch-download-metadata.py` fetches not just from
`python-build-standalone`, so updates the workflow to
`sync-python-releases.yml`.

Also includes `crates/uv-python/download-metadata.json` in `add-paths`.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-07-24 02:11:52 +00:00
Charlie Marsh
41b699e7ac
Add warning to --link-mode=symlink documentation (#5387) 2024-07-23 22:35:56 +00:00
Zanie Blue
3822a43560
Fix blurring from nav title box shadow (#5374)
Fixes blur noted in https://github.com/astral-sh/uv/pull/5316 but
doesn't drop the title entirely.
https://github.com/astral-sh/uv/pull/5316 is my preferred design, if the
implementation was cost-free.


<img width="1259" alt="Screenshot 2024-07-23 at 3 53 48 PM"
src="https://github.com/user-attachments/assets/6f9b828b-884f-447d-8508-ba4023152e2f">

(nothing to see at the rest of the breakpoints >1220)

<img width="1259" alt="Screenshot 2024-07-23 at 3 53 56 PM"
src="https://github.com/user-attachments/assets/b892cd76-cd91-4e78-b8c8-58e16a8b1130">
2024-07-23 17:33:57 -05:00
Zanie Blue
499b035c8e
Increase padding between each nav section (#5373)
<img width="1259" alt="Screenshot 2024-07-23 at 3 46 45 PM"
src="https://github.com/user-attachments/assets/dae4df4e-cea3-41a2-842c-652b4f9ca014">
<img width="1259" alt="Screenshot 2024-07-23 at 3 46 53 PM"
src="https://github.com/user-attachments/assets/b0751c4b-80bb-4344-816c-e23d5e45f0e4">
<img width="1259" alt="Screenshot 2024-07-23 at 3 46 57 PM"
src="https://github.com/user-attachments/assets/1cea6223-2757-49a0-9b87-1961f9bbd17b">
<img width="1259" alt="Screenshot 2024-07-23 at 3 47 10 PM"
src="https://github.com/user-attachments/assets/a41061c6-f198-45ca-91b6-423f46375089">
2024-07-23 17:31:12 -05:00
Charlie Marsh
2271486e0e
Skip 'Nothing to uninstall' message when removing dangling environments (#5382)
## Summary

Closes https://github.com/astral-sh/uv/issues/5379.
2024-07-23 18:28:22 -04:00
Charlie Marsh
ad4a15d0c2
Allow symlinks to files in scripts directory (#5380)
## Summary

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

## Test Plan

Unfortunately, the only packages I know of that use this are Ruff and
uv, and both are too heavy to install in a recurring test, so:

`uv tool install hatch==1.12.0 --with uv==0.2.27 --force
--link-mode=symlink`
2024-07-23 22:24:43 +00:00
Charlie Marsh
8942ec36c0
Mark --raw-sources as conflicting with sources-specific arguments (#5378)
## Summary

We should error on, e.g., `--raw-sources --tag 0.0.1`.
2024-07-23 22:03:01 +00:00
Charlie Marsh
76566b09be
Reject Git CLI arguments with non-Git sources (#5377)
## Summary

Closes https://github.com/astral-sh/uv/issues/5335.
2024-07-23 21:48:50 +00:00
Zanie Blue
aced05d427
Use the docs bot email for docs publish commits (#5369) 2024-07-23 16:04:12 -05:00