Commit graph

3315 commits

Author SHA1 Message Date
Charlie Marsh
f8e2d2f54d
Remove lingering executables after failed installs (#5666)
## Summary

This could still be made more robust, but it's not critical, since you
can always `--force`. It's good to handle this case, though, since we
have an explicit error for it.

Closes https://github.com/astral-sh/uv/issues/5490.
2024-07-31 15:27:24 -04:00
Charlie Marsh
4b8a127c54
Avoid persisting uv add calls that result in resolver errors (#5664)
## Summary

Closes https://github.com/astral-sh/uv/issues/5622.
2024-07-31 13:27:34 -04:00
eth3lbert
54398fa7bc
Show help specific options in uv help (#5516)
## Summary

Resolves #5221 

## Test Plan

Test case included.
2024-07-31 12:10:57 -05:00
Zanie Blue
ef84380954
Add documentation for caching the uv cache in GHA (#5663)
Related to https://github.com/astral-sh/uv/issues/5409
2024-07-31 11:38:54 -05:00
Pavel Dikov
d05f2b258b
fix(venv): make relocatable activation scripts support ksh (#5640)
It transpires that detecting the directory a script was sourced from is
non-trivial across `bash`, `ksh` and `zsh`.

The previous version was a one-liner and supported `bash` and `zsh` but
not `ksh`.

It is possible to keep the one-liner and add `ksh` support, but that is
mutually-exclusive with `zsh`.

Therefore, the only way to square this circle is to add an `if` block. A
silver lining here is that although longer, the script is probably
easier to follow as there is less code-golfing going on.
2024-07-31 12:18:11 -04:00
Charlie Marsh
f266fb711c
Use full requirement when serializing receipt (#5494)
## Summary

The current receipt doesn't capture quite enough information. For
example, it doesn't differentiate between editable and non-editable
requirements. This PR instead uses the full `Requirement` type. I think
we should use a custom representation like we do in the lockfile, but
I'm just using the default representation to demonstrate the idea.
2024-07-31 16:16:39 +00:00
Charlie Marsh
bf8934e3e4
Use intersection rather than union for requires-python (#5644)
## Summary

As-is, if you have a workspace with mixed `requires-python`
requirements, resolution will _never_ succeed, since we'll use the union
as the `requires-python` bound (i.e., take the lowest value), and fail
when we see the package that only supports some more narrow range.

This PR modifies the behavior to take the intersection (i.e., the
highest value), so if you have one package that supports Python 3.12 and
later, and another that supports Python 3.8 and later, we lock for
Python 3.12. If you try to sync or run with Python 3.8, we raise an
error, since the lockfile will be incompatible with that request.

Konsti has a write-up in https://github.com/astral-sh/uv/issues/5594
that outlines what could be a longer-term strategy.

Closes https://github.com/astral-sh/uv/issues/5578.
2024-07-31 16:08:53 +00:00
Charlie Marsh
dfec262586
Capture portable path serialization in a struct (#5652)
## Summary

I need to reuse this in #5494, so want to abstract it out and make it
reusable.
2024-07-31 16:00:37 +00:00
Zanie Blue
8d14a4cb4f
Simplify GHA UV_SYSTEM_PYTHON examples (#5659) 2024-07-31 10:49:40 -05:00
Zanie Blue
22d152192d
Improvements to the dependency concept doc (#5658) 2024-07-31 15:44:25 +00:00
konsti
2247b0f540
Check idempotence in packse lock scenarios (#5485)
Add tests for the instabilities fix.

Part of
https://github.com/astral-sh/uv/issues/5180#issuecomment-2247696198

Closes #5180
2024-07-31 15:39:16 +00:00
konsti
38c6033010
Use fork markers and fork preferences in resolution with lockfile (#5481)
By resolving for each fork from the lockfile individually and by adding
using preferences for the current fork, we solve the instability #5180.
I've tested the locally and will add the packse test scenarios upstack.

Part of
https://github.com/astral-sh/uv/issues/5180#issuecomment-2247696198
2024-07-31 15:18:58 +00:00
Charlie Marsh
176e9c4deb
Add --package to uv sync (#5656)
## Summary

Closes https://github.com/astral-sh/uv/issues/5008.
2024-07-31 15:16:48 +00:00
Zanie Blue
37a60a57e8
Prompt an early jump to the feature overview during first steps (#5655)
Addressing some feedback about the first-steps covering the help and
version commands.

I'm not sure what else to do here since the first steps with uv are very
dependent on the features you need.
2024-07-31 10:13:04 -05:00
Andrew Gallant
5b8ed92f95 uv-client: switch heuristic freshness lifetime to hard-coded value
The comment in the code explains the bulk of this:

```rust
// We previously computed this heuristic freshness lifetime by
// looking at the difference between the last modified header and
// the response's date header. We then asserted that the cached
// response ought to be "fresh" for 10% of that interval.
//
// It turns out that this can result in very long freshness
// lifetimes[1] that lead to uv caching too aggressively.
//
// Since PyPI sets a max-age of 600 seconds and since we're
// principally just interacting with Python package indices here,
// we just assume a freshness lifetime equal to what PyPI has.
//
// Note though that a better solution here is for the index to
// support proper HTTP caching headers (ideally Cache-Control, but
// Expires also works too, as above).
```

We also remove the `heuristic_percent` field on `CacheConfig`. Since
that's actually part of the cache itself, we bump the simple cache
version.

Finally, we add some more `trace!` calls that should hopefully make
diagnosing issues related to the freshness lifetime a bit easier in the
future.

Fixes #5351
2024-07-31 08:12:11 -07:00
Zanie Blue
0c680824ca
Omit the nav bar title when it has no use (#5316)
Turns out this is needed for navigation on mobile, but useless on larger
screens.

Closes #5130

<img width="1551" alt="Screenshot 2024-07-22 at 5 47 49 PM"
src="https://github.com/user-attachments/assets/2173549e-e65d-4691-be83-5e3bf0191dd5">
<img width="1551" alt="Screenshot 2024-07-22 at 5 48 02 PM"
src="https://github.com/user-attachments/assets/81012ba8-ce85-4276-8ffa-5c7ef556c389">
<img width="1551" alt="Screenshot 2024-07-22 at 5 48 08 PM"
src="https://github.com/user-attachments/assets/ecf8fcd7-e5d4-45c4-8d46-d09d91a8bbe9">
2024-07-31 10:08:22 -05:00
Charlie Marsh
c2a6cb391b
Prioritize forks based on upper bounds (#5643)
## Summary

Given a fork like:

```
pylint < 3 ; sys_platform == 'darwin'
pylint > 2 ; sys_platform != 'darwin'
```

Solving the top branch will typically yield a solution that also
satisfies the bottom branch, due to maximum version selection (while the
inverse isn't true).

To quote an example from the docs:

```rust
// If there's no difference, prioritize forks with upper bounds. We'd prefer to solve
// `numpy <= 2` before solving `numpy >= 1`, since the resolution produced by the former
// might work for the latter, but the inverse is unlikely to be true due to maximum
// version selection. (Selecting `numpy==2.0.0` would satisfy both forks, but selecting
// the latest `numpy` would not.)
```

Closes https://github.com/astral-sh/uv/issues/4926 for now.
2024-07-31 11:05:12 -04:00
eth3lbert
89947681d1
Improve copy of console command examples (#5397)
## Summary

This PR improves the copy of the console command example by:

- Preventing the selection of generic prompts and generic output
- Lazily setting copy content by leveraging intersection observer

Most of the changes are inspired by
https://github.com/opensafely/documentation/pull/1461

Some other useful refs:
- https://github.com/squidfunk/mkdocs-material/issues/3647
-
https://mkdocstrings.github.io/recipes/#prevent-selection-of-prompts-and-output-in-python-code-blocks

Resolves #5355

## Test Plan

- 
  ``` shell-session
  mkdocs serve -f mkdocs.public.yml
  ``` 
- Navigate to http://localhost:8000/uv/first-steps/#viewing-the-version
- Try clicking the copy button
- Try copying by selecting the content

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-07-31 14:52:02 +00:00
Zanie Blue
0b8b0e0cbe
Drop badges from docs landing (#5617)
There has been opposition to these, we can have a dedicated community
page instead
2024-07-31 09:36:01 -05:00
Charlie Marsh
f268b7c90a
Prioritize forks based on Python narrowing (#5642)
## Summary

First part of: https://github.com/astral-sh/uv/issues/4926. We should
solve forks that _don't_ expand the world of supported versions (e.g.,
`python_version >= '3.11'` enables us to select new packages, since we
narrow the supported version range).
2024-07-31 10:29:14 -04:00
Vigilans
0dcec9eba8
Detect python version from python project by default in uv venv (#5592)
<!--
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? -->

`uv venv` should support adopting python version specified in
`requires-python` from `pyproject.toml`. This allows customization on
the venv setup when syncing from python project.

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

It also serves as a workaround to close
https://github.com/astral-sh/uv/issues/5258.

## Test Plan

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

1. Run `uv venv` in folder with `pyroject.toml` specifying
`requries-python = "<3.10"`. Python 3.9 is selected for venv.
2. Change to `requries-python = "<3.11"` and run `uv venv` again. Python
3.10 is selected now.
3. Switch to a folder without `pyproject.toml` then run `uv venv`.
Python 3.12 is selected now.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-07-31 13:54:16 +00:00
Zanie Blue
fbff1baf33
Improvements to the Python version concepts documentation (#5638)
Depends on https://github.com/astral-sh/uv/pull/5637
2024-07-31 08:40:50 -05:00
Zanie Blue
7ef830460e
Replace --python-preference installed with managed (#5637)
Collapses the previous default into "managed" and makes the "managed"
behavior match "installed". People should use "only-managed" if they
want that behavior, it seems overly complicated otherwise.
2024-07-31 08:40:39 -05:00
konsti
981661c4af
Update pubgrub (#5649)
We improved the API structure in pubgrub, and also update to generally
keep up with upstream.
2024-07-31 12:54:11 +00:00
Charlie Marsh
2574f5b3fd
Omit transitive development dependencies from workspace lockfile (#5646)
## Summary

Omit development dependencies from (e.g.) path dependencies.

Closes https://github.com/astral-sh/uv/issues/5593.
2024-07-30 22:32:33 -04:00
Zanie Blue
cbb13e6584
Improve the project guide (#5626) 2024-07-30 18:26:23 -05:00
Charlie Marsh
38c232e466
Bump version to v0.2.32 (#5641) 2024-07-30 18:56:39 -04:00
Charlie Marsh
5d727cb0af
Deprecate the --isolated flag (#5466)
## Summary

This PR deprecates the `--isolated` flag. The treatment varies across
the APIs:

- For non-preview APIs, we warn but treat it as equivalent to
`--no-config`.
- For preview APIs, we warn and ignore it, with two exceptions...
- For `tool run` and `run` specifically, we don't even warn, because we
can't differentiate the command-specific `--isolated` from the global
`--isolated`.
2024-07-30 22:40:38 +00:00
Zanie Blue
f971631adf
Wrap documentation at 100 characters (#5635)
Basically sick of dealing with mixed formatting here. Going with the
number at
7c08e61b73/.editorconfig (L20)
2024-07-30 22:17:58 +00:00
Zanie Blue
b081425a77
Improvements to the project concept docs (#5634) 2024-07-30 22:11:52 +00:00
Charlie Marsh
67b3bfa213
Add --isolated support to uv run (#5471)
## Summary

The culmination of #4730. We now have `uv run --isolated` which always
uses a fresh environment (but includes the workspace dependencies as
needed). This enables you to test with strict isolation (e.g., `uv run
--isolated -p foo` will ensure that `foo` is unable to import anything
that isn't an actual dependency).

Closes #5430.
2024-07-30 19:27:47 +00:00
Charlie Marsh
ff3bcbb639
Reframe use of --isolated in tool run (#5470)
## Summary

This PR gets rid of the global `--isolated` flag (which serves a bunch
of independent responsibilities right now) on `uv tool run` in favor of
a dedicated `--isolated` flag, which tells uv to avoid re-using an
existing tool environment for this invocation. We'll add the same thing
to `uv run`, to avoid using the base project environment.

This will become a bit clearer in #5466, when we deprecate the
`--isolated` flag on the preview APIs.
2024-07-30 15:09:53 -04:00
Zanie Blue
8545ae2312
Rename more use of "lock file" to "lockfile" (#5629) 2024-07-30 19:09:43 +00:00
Charlie Marsh
d6c319a368
Suppress resolver output by default in uv run and uv tool run (#5580)
## Summary

The idea here is that we hide all resolver output (the grayed out
resolver messages, plus the list of environment modifications) by
default in `uv run` and `uv tool run`. You can pass `--show-resolution`
to re-enable them.

Closes https://github.com/astral-sh/uv/issues/5458.
2024-07-30 18:11:52 +00:00
Charlie Marsh
f7494f24cf
Remove --isolated usages from the uv python API (#5468) 2024-07-30 17:52:53 +00:00
Zanie Blue
5830a532ef
Add links to documentation footer (#5616) 2024-07-30 12:42:17 -05:00
Charlie Marsh
f1b3d2e1e1
Add --no-workspace and --no-project in lieu of --isolated (#5465)
## Summary

Right now, `--isolated` is read from `uv run` and `uv init` to avoid
discovering the current workspace (or project). This PR moves that
behavior to a dedicated `--no-workspace` flag for `uv init`, and
`--no-project` for `uv run`. They could use the same flag, but
`--no-project` feels confusing for `uv init`, and `--no-workspace` seems
confusing for `uv run` (especially so once you read the documentation,
where we refer to the thing you're omitting as the project).

Closes https://github.com/astral-sh/uv/issues/5429.
2024-07-30 13:40:35 -04:00
eth3lbert
fc78561fa1
Add git-ref group for uv add (#5502)
## Summary

This PR allows us to reject specifying more than one git-ref at the cli
level.

## Test Plan

Test cases included.
2024-07-30 09:40:28 -05:00
Charlie Marsh
3e7b9fb2ee
Add documentation for cache clearing (#5517)
See: https://github.com/astral-sh/uv/pull/5391#issuecomment-2248757705
2024-07-30 09:38:04 -05:00
Charlie Marsh
dfa780d6f5
Re-enable requires-python narrowing in forks (#5583)
See: https://github.com/astral-sh/uv/issues/4669
See: https://github.com/astral-sh/uv/issues/4668
See: https://github.com/astral-sh/uv/pull/4902
2024-07-30 10:06:59 -04:00
Charlie Marsh
3e2ae93d6c
Improve order implementation for Python bound (#5599)
## Summary

We shouldn't unequivocally treat exclusions as greater than
inclusions...
2024-07-30 10:05:54 -04:00
Andrew Gallant
4e748363f8 uv-resolver: fix marker propagation
This PR represents a different approach to marker propagation in an
attempt to unblock #4640. In particular, instead of propagating markers
when forks are created, we wait until resolution is complete to
propagate all markers to all dependencies in each fork. This ends up
being both more robust (we should never miss anything) and simpler to
implement because it doesn't require mutating a `PubGrubPackage` (which
was pretty annoying). I think the main downside here is that this can
sometimes add markers where they aren't needed.

This actually winds up making quite a few snapshot changes. I went
through each of them. Some of them look like legitimate bug fixes. Some
of them look like superfluous additions. And some of them look like they
would be removed if we had perfect marker normalization. But I don't
think any of the changes are _wrong_.
2024-07-30 06:16:03 -07:00
Charlie Marsh
750b3a7c8c
Avoid setting executable permissions on files we might not own (#5582)
## Summary

If we just created an entrypoint script, we can of course set the
permissions (we just created it). However, if we're copying from the
cache, we might _not_ own the file. In that case, if we need to change
the permissions (we shouldn't, since the script is likely already
executable -- we set the permissions when we unzip, but I guess they
could _not_ be properly set in the zip itself), we have to copy it.

Closes https://github.com/astral-sh/uv/issues/5581.
2024-07-30 12:32:52 +00:00
Ben Beasley
dfb4e5bbc8
Add license text to fetch-download-metadata.py (#5587) 2024-07-30 08:15:23 -04:00
konsti
dedd913603
Add forks to lockfile, don't read them yet (#5480)
Add the forks to the lockfile, without using them yet, which we'll add
in the next PR.

Please review commit-by-commit

Part of
https://github.com/astral-sh/uv/issues/5180#issuecomment-2247696198
2024-07-30 11:11:18 +00:00
Maksim Bondarenkov
228a803fde
uv-python: use windows-sys instead of winapi (#5591)
<!--
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

use windows-sys bindings maintained by microsoft devs. winapi didn't has
any updates for more than 3 years

## Test Plan

cargo test. it failed locally because I don't have Python 3.12 installed
2024-07-30 11:43:04 +02:00
Ben Beasley
c0d3da8b6a
Add LICENSE for cloneable_seekable_reader.rs from ripunzip (#5585) 2024-07-29 22:15:48 -04:00
Charlie Marsh
c46adee48d
Make --directory a global argument (#5579)
## Summary

Cargo makes this global (and uses the same technique). It's still hidden
so we can always decide to remove it.
2024-07-29 19:43:55 -04:00
eth3lbert
3e329029bc
List installed tools when no command is provided to uv tool run (#5553)
## Summary

Part of #4024 

## Test Plan

Test cases included.
2024-07-29 22:12:31 +00:00
Charlie Marsh
ecb85c9894
Statically link liblzma (#5577)
## Summary

Found via https://github.com/indygreg/PyOxidizer/issues/585.

Closes https://github.com/astral-sh/uv/issues/5572.
2024-07-29 21:46:43 +00:00