Commit graph

3331 commits

Author SHA1 Message Date
Zanie Blue
159108b728
Move --python and --python-version into the "Python options" help (#5691)
Part of #4454 

e.g. for `uv help pip compile`

```
Python options:
      --python <PYTHON>
          The Python interpreter against which to compile the requirements.
          
          By default, uv uses the virtual environment in the current working directory or any parent
          directory, falling back to searching for a Python executable in `PATH`. The `--python`
          option allows you to specify a different interpreter.
          
          Supported formats:
          - `3.10` looks for an installed Python 3.10 using `py --list-paths` on Windows, or
            `python3.10` on Linux and macOS.
          - `python3.10` or `python.exe` looks for a binary with the given name in `PATH`.
          - `/home/ferris/.local/bin/python3.10` uses the exact Python at the given path.

  -p, --python-version <PYTHON_VERSION>
          The minimum Python version that should be supported by the resolved requirements (e.g., `3.8` or `3.8.17`).
          
          If a patch version is omitted, the minimum patch version is assumed. For example, `3.8` is mapped to `3.8.0`.

      --python-preference <PYTHON_PREFERENCE>
          Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv

          Possible values:
          - only-managed: Only use managed Python installations; never use system Python installations
          - managed:      Prefer managed Python installations over system Python installations
          - system:       Prefer system Python installations over managed Python installations
          - only-system:  Only use system Python installations; never use managed Python installations

      --python-fetch <PYTHON_FETCH>
          Whether to automatically download Python when required

          Possible values:
          - automatic: Automatically fetch managed Python installations when needed
          - manual:    Do not automatically fetch managed Python installations; require explicit installation
 ```
2024-08-01 11:55:11 -05:00
Charlie Marsh
ff2e1fcec0
Support legacy tool receipts with PEP 508 requirements (#5679)
## Summary

In #5494, I made breaking changes to the tool receipt format. This would
break existing tools for all users. This PR makes the change
backwards-compatible by supporting deserialization for the deprecated
format.

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

## Test Plan

Beyond the automated tests, you can run `cargo run tool list` on your
existing machine.

Before:

```
warning: `uv tool list` is experimental and may change without warning
warning: Ignoring malformed tool `black` (run `uv tool uninstall black` to remove)
warning: Ignoring malformed tool `poetry` (run `uv tool uninstall poetry` to remove)
warning: Ignoring malformed tool `ruff` (run `uv tool uninstall ruff` to remove)
```

After:

```
warning: `uv tool list` is experimental and may change without warning
black v0.1.0
- black
poetry v1.8.3
- poetry
ruff v0.0.60
- ruff
```
2024-08-01 12:43:29 -04:00
Charlie Marsh
b9b41d4a38
Include newly-added optional dependencies in lockfile (#5686)
## Summary

When we add a new optional group in `uv add`, we never to update the
`pyproject.toml` before locking. Otherwise, we use the stale
`pyproject.toml` and omit the optional group.

Closes https://github.com/astral-sh/uv/issues/5687.
2024-08-01 12:41:37 -04:00
Zanie Blue
64c6caa57b
Fixup settings reference (#5694)
Fixes #5689
2024-08-01 16:41:26 +00:00
Zanie Blue
0f30c69624
Move settings reference to reference section (#5689)
Joining #5685 in a dedicated reference section
2024-08-01 16:20:30 +00:00
Zanie Blue
f107406727
Generate CLI reference for documentation (#5685)
Loosely based on [Cargo's
format](https://github.com/rust-lang/cargo/blob/master/src/doc/src/commands/cargo-build.md)

<img width="896" alt="Screenshot 2024-08-01 at 9 44 03 AM"
src="https://github.com/user-attachments/assets/7c016bb3-2b54-46af-8ea8-ce82e07a0e30">

Future work includes:

- Grouping options
- Enforcing some sort of specific command ordering
- Showing possible values for enums
- Adding "long_about" to commands for more context
2024-08-01 16:04:16 +00:00
eth3lbert
9788496c51
Grouping GlobalArgs to dedicated heading (#5665)
## Summary

Part of #4454 .

## Test Plan

test cases included.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-08-01 10:01:22 -05:00
konsti
9a1a2118e1
Add transformers pyproject.toml to test requirements (#5657)
This `pyproject.toml`, translated from
0e4a1c3401/setup.py,
has found a number of bugs in blue jay, so i'm adding it to uv as a
development test case. (The file is too large to make it a test by
itself.)
2024-08-01 13:25:20 +02:00
Charlie Marsh
b9866b3ee8
Avoid unwrap when serializing receipts (#5678) 2024-07-31 22:57:16 -04:00
Zanie Blue
df6106f5bf
Use "uv" for title of index instead of "Introduction" (#5677)
<img width="807" alt="Screenshot 2024-07-31 at 5 12 48 PM"
src="https://github.com/user-attachments/assets/8a3cc824-c242-4688-a7d9-5b88198a6b94">
vs
<img width="807" alt="Screenshot 2024-07-31 at 5 13 21 PM"
src="https://github.com/user-attachments/assets/04f77771-94c3-4d2e-81d2-2db63aa649bd">
2024-07-31 18:24:55 -05:00
Ahmed Ilyas
5bded73c48
uvx warn when no executables are available (#5675)
## Summary

Resolves #5623 

## Test Plan

`cargo test`
2024-07-31 17:27:41 -05:00
Zanie Blue
ed520580a1
Remove breadcrumbs for navigation (#5676)
Closes https://github.com/astral-sh/uv/issues/5671

These are effectively worthless since it never displays more than one
level.
2024-07-31 17:10:31 -05:00
Zanie Blue
b0e37859ed
Bold active nav links for accessibility (#5673)
Before
<img width="412" alt="Screenshot 2024-07-31 at 3 47 38 PM"
src="https://github.com/user-attachments/assets/d95ebb62-079b-4e20-964c-9876b5978e4c">
After
<img width="412" alt="Screenshot 2024-07-31 at 3 47 21 PM"
src="https://github.com/user-attachments/assets/a658d46a-3eeb-4f00-8952-d4c1dd91afe6">
2024-07-31 16:16:48 -05:00
Charlie Marsh
ff2b810fdf
Fix non-registry serialization for receipts (#5668)
## Summary

Fixes a bug in #5494. The `RequirementSourceWire` representation was
ambiguous, and so the order of the fields meant that all variants were
mapped to `Registry` when deserializing. (So the snapshots were right,
but behaviors were wrong.)
2024-07-31 21:09:54 +00:00
Zanie Blue
9e4fbd2111
Move pip-compatibility doc into pip interface section (#5670) 2024-07-31 20:30:10 +00:00
Charlie Marsh
2b9a4f673e
Initialize the cache in uv init (#5669)
## Summary

We now query the Python interpreter here, which means we need cache
access.
2024-07-31 19:46:12 +00:00
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