Commit graph

4903 commits

Author SHA1 Message Date
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
Charlie Marsh
51a03738a2
Use cached current directory everywhere (#5574) 2024-07-29 17:03:45 -04:00
Charlie Marsh
37388f0987
Make directory a required argument (#5573) 2024-07-29 20:47:34 +00:00
bluss
e46c24d3cf
Implement uv run --directory (#5566)
## Summary

uv run --directory <path> means that one doesn't have to change to a
project's directory to run programs from it. It makes it possible to use
projects as if they are tool installations.

To support this, first the code reading .python-version was updated so
that
it can read such markers outside the current directory. Note the minor
change this causes (if I'm right), described in the commit.

## Test Plan

One test has been added.

## --directory

Not sure what the name of the argument should be, but it's following uv
sync's directory for now.

Other alternatives could be "--project". Uv run and uv tool run should
probably find common agreement on this (relevant for project-locked
tools).

I've implemented this same change in Rye, some time ago, and then we
went
with --pyproject `<`path to pyproject.toml file`>`. I think using
pyproject.toml file path and not directory was probably a mistake, an
overgeneralization one doesn't need.
2024-07-29 15:53:10 -04:00
Charlie Marsh
cf94a10054
Skip copying to empty entries in seekable zip (#5571)
## Summary

We cannot do this when streaming, since we may not have the metadata for
the entry.

Closes https://github.com/astral-sh/uv/issues/5565.
2024-07-29 19:00:19 +00:00
Charlie Marsh
f70501a22e
Use a consistent buffer size when writing out zip files (#5570) 2024-07-29 14:45:33 -04:00
Charlie Marsh
05b1f51aa1
Use a consistent buffer size for downloads (#5569) 2024-07-29 14:31:39 -04:00
Charlie Marsh
48162de974
Bump version to v0.2.31 (#5568) 2024-07-29 14:06:20 -04:00
konsti
194904b340
Redact packse version in snapshots follow-up (#5563)
I thought i had this included in #5483 but i had it on the wrong branch.
2024-07-29 15:22:20 +00:00
konsti
0f87d174b9
Redact packse version in snapshots (#5483)
Every packse version update is currently causing a huge diff (the size
of the `lock_scenarios.rs` diff in this PR). By redacting the version
from the snapshots, we will only have the actual change in the diff and
not the redundant version change noise.

The second commit moves all remaining packse url arg values to
`common/mod.rs`, which acts as a single source of truth for the packse
version.
2024-07-29 17:04:46 +02:00
Charlie Marsh
a346d257cb
Update rs-async-zip fork commit (#5560)
## Summary

Closes https://github.com/astral-sh/uv/issues/5556.
2024-07-29 14:42:53 +00:00
Charlie Marsh
e6ad0cd2f9
Remove PyO3 updates from renovate (#5559) 2024-07-29 14:38:12 +00:00
Charlie Marsh
a5866f44c4
Add a no-op resolution benchmark (#5558) 2024-07-29 10:37:12 -04:00