Commit graph

27 commits

Author SHA1 Message Date
John Mumm
e9d5780369
Support transparent Python patch version upgrades (#13954)
> NOTE: The PRs that were merged into this feature branch have all been
independently reviewed. But it's also useful to see all of the changes
in their final form. I've added comments to significant changes
throughout the PR to aid discussion.

This PR introduces transparent Python version upgrades to uv, allowing
for a smoother experience when upgrading to new patch versions.
Previously, upgrading Python patch versions required manual updates to
each virtual environment. Now, virtual environments can transparently
upgrade to newer patch versions.

Due to significant changes in how uv installs and executes managed
Python executables, this functionality is initially available behind a
`--preview` flag. Once an installation has been made upgradeable through
`--preview`, subsequent operations (like `uv venv -p 3.10` or patch
upgrades) will work without requiring the flag again. This is
accomplished by checking for the existence of a minor version symlink
directory (or junction on Windows).

### Features

* New `uv python upgrade` command to upgrade installed Python versions
to the latest available patch release:
``` 
# Upgrade specific minor version 
uv python upgrade 3.12 --preview
# Upgrade all installed minor versions
uv python upgrade --preview
```
* Transparent upgrades also occur when installing newer patch versions: 
```
uv python install 3.10.8 --preview
# Automatically upgrades existing 3.10 environments
uv python install 3.10.18
```
* Support for transparently upgradeable Python `bin` installations via
`--preview` flag
```
uv python install 3.13 --preview
# Automatically upgrades the `bin` installation if there is a newer patch version available
uv python upgrade 3.13 --preview
```
* Virtual environments can still be tied to a patch version if desired
(ignoring patch upgrades):
```
uv venv -p 3.10.8
```

### Implementation

Transparent upgrades are implemented using:
* Minor version symlink directories (Unix) or junctions (Windows)
* On Windows, trampolines simulate paths with junctions
* Symlink directory naming follows Python build standalone format: e.g.,
`cpython-3.10-macos-aarch64-none`
* Upgrades are scoped to the minor version key (as represented in the
naming format: implementation-minor version+variant-os-arch-libc)
* If the context does not provide a patch version request and the
interpreter is from a managed CPython installation, the `Interpreter`
used by `uv python run` will use the full symlink directory executable
path when available, enabling transparently upgradeable environments
created with the `venv` module (`uv run python -m venv`)

New types:
* `PythonMinorVersionLink`: in a sense, the core type for this PR, this
is a representation of a minor version symlink directory (or junction on
Windows) that points to the highest installed managed CPython patch
version for a minor version key.
* `PythonInstallationMinorVersionKey`: provides a view into a
`PythonInstallationKey` that excludes the patch and prerelease. This is
used for grouping installations by minor version key (e.g., to find the
highest available patch installation for that minor version key) and for
minor version directory naming.

### Compatibility

* Supports virtual environments created with:
  * `uv venv`
* `uv run python -m venv` (using managed Python that was installed or
upgraded with `--preview`)
  * Virtual environments created within these environments
* Existing virtual environments from before these changes continue to
work but aren't transparently upgradeable without being recreated
* Supports both standard Python (`python3.10`) and freethreaded Python
(`python3.10t`)
* Support for transparently upgrades is currently only available for
managed CPython installations

Closes #7287
Closes #7325
Closes #7892
Closes #9031
Closes #12977

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2025-06-20 16:17:13 +02:00
John Mumm
f66ce58a09
Simplify managed Python flags (#12246)
Currently, for users to specify at the command line whether to use
uv-managed or system Python interpreters, they use the
`--python-preference` parameter, which takes four possible values. This
is more complex than necessary since the normal case is to either say
"only managed" or "not managed". This PR hides the old
`--python-preference` parameter from help and documentation and adds two
new flags: `--managed-python` and `--no-managed-python` to capture the
"only managed" and "not managed" cases.

I have successfully tested this locally but currently cannot add
snapshot tests because of problems with distinguishing managed vs.
system interpreters in CI (and non-determinism when run on different
developers' machines). The `--python-preference` test in
`tool-install.rs` is currently ignored for this reason. See #5144 and
#7473.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2025-03-18 18:13:14 +01:00
Charlie Marsh
3188d99f39
Use consistent commas around i.e. and e.g. (#12157)
## Summary

Only in user-facing docs -- I didn't bother with the rustdoc. (This is
in the style guide already.)
2025-03-13 23:42:10 +00:00
Zanie Blue
e0a19be825
Touch-ups to the Python install guide (#11116) 2025-01-30 13:56:53 -06:00
Zanie Blue
a3049ecf69
Fix broken link (#11081) 2025-01-29 19:41:18 +00:00
Zanie Blue
2ca51501ed
Shorten "Using existing Python versions" nav item so it fits on one line (#11077) 2025-01-29 19:04:11 +00:00
FishAlchemist
9736868908
Add meta titles to documents in guides, excluding integration documents. (#10539)
## Summary
Add meta titles to documents in guides, excluding integration documents.
<!-- What's the purpose of the change? What does it do, and why? -->

## Test Plan
``uvx --with-requirements docs/requirements.txt -- mkdocs build --strict
-f mkdocs.public.yml``
<details>
 <summary>Build Result</summary>

* ``guides/install-python``
```html
...
<meta name="description" content="Guide to install specific Python versions, manage existing installations, and automate downloads with uv.">
...
<title>Install and Manage Python | uv</title>
...
```
* ``guides/projects``
```html
...
<meta name="description" content="Guide to create, manage, and build Python projects with uv, including dependencies and distributions.">
...
<title>Working on projects | uv</title>
...
```
* ``guides/publish``
```html
...
<meta name="description" content="Guide to build and publish Python packages using uv">
...
<title>Publishing a package | uv</title>
...
```
* ``guides/scripts``
```html
...
<meta name="description" content="Run Python scripts quickly and manage dependencies efficiently using uv. Learn about inline metadata and more.">
...
<title>Run Scripts | uv</title>
...
```
* ``guides/tools``
```html
...
<meta name="description" content="Guide to run, install, and upgrade Python tools using uv.">
...
<title>Using tools | uv</title>
...
```
</details>

---------

Co-authored-by: Charles Tapley Hoyt <cthoyt@gmail.com>
Co-authored-by: Zanie Blue <contact@zanie.dev>
2025-01-15 14:12:55 -06:00
Zanie Blue
8908e26de7
Add uv python install --preview to the documentation (#10010) 2024-12-19 16:07:46 -06:00
Zanie Blue
d70160a57b
Update references to python-build-standalone to reflect the transferred project (#9977) 2024-12-17 20:19:58 +00:00
Jim Kutter
e925787da3
change example so it works as is on powershell and cmd (#9903)
<!--
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

When going through the docs at
https://docs.astral.sh/uv/guides/install-python/#automatic-python-downloads,
when you try to copy and paste the example on Windows, in either
PowerShell or cmd.exe the example won't work.

Inverting the quotes fixes it, and still works on other shells (I only
tried bash under wsl)

## Test Plan

On any windows system, from powershell, running the example yields the
following error:

```
> uv run --python 3.12 python -c 'print("hello world")'
  File "<string>", line 1
    print(hello world)
          ^^^^^^^^^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?
```

on cmd.exe

```
> uv run --python 3.12 python -c 'print("hello world")'

``` 
(there is no output)

Inverting the quotes on powershell
```
> uv run --python 3.12 python -c "print('hello world')"
hello world
```

on cmd.exe
```
> uv run --python 3.12 python -c "print('hello world')"
hello world


```

<!-- How was it tested? -->
2024-12-15 11:19:44 -06:00
Udi Oron
8963de26a7
docs: fix uv python install docs to use an exisigin pypy version (#8845)
The current docs call to install pypy@3.12 that does not exist yet.
Change it to install pypy@3.10
2024-11-05 16:13:58 -06:00
Mathieu Kniewallner
c9e4395322
docs: add missing console highlights (#6900)
## Summary

Spotted a few missing `console` highlights in the documentation.
2024-08-31 19:04:19 -04:00
Mathieu Kniewallner
85be33d719
docs: use stricter validation options (#6096)
## Summary

`mkdocs` supports [validation rules for
links](https://www.mkdocs.org/user-guide/configuration/#validation),
which can be tightened to report more issues than the default
configuration. I used the recommended "maximal strictness" configuration
from the documentation.

Adding the `anchors` rule helped spot 4 errors:
```console
WARNING -  Doc file 'guides/install-python.md' contains a link '../concepts/python-versions.md#python-distributions', but the doc 'concepts/python-versions.md' does not contain an anchor '#python-distributions'.
WARNING -  Doc file 'guides/install-python.md' contains a link '../concepts/python-versions.md#discovery-order', but the doc 'concepts/python-versions.md' does not contain an anchor '#discovery-order'.
WARNING -  Doc file 'guides/projects.md' contains a link '../concepts/projects.md#lock-file', but the doc 'concepts/projects.md' does not contain an anchor '#lock-file'.
WARNING -  Doc file 'pip/environments.md' contains a link '../concepts/python-versions.md#discovery-order', but the doc 'concepts/python-versions.md' does not contain an anchor '#discovery-order'.
```

## Test Plan

Local run of the documentation + `mkdocs build --strict`.
2024-08-14 19:27:22 -05:00
Charlie Marsh
ce30bffaab
Make some minor tweaks to the docs (#5786)
## Summary

Small stuff from a first scan.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-08-05 13:54:06 +00:00
Zanie Blue
44a6dbfa53
Improvements to the documentation (#5718) 2024-08-03 08:41:33 -05:00
konsti
db371560bc
Use prettier to format the documentation (#5708)
To enforce the 100 character line limit in markdown files introduced in
https://github.com/astral-sh/uv/pull/5635, and to automate the
formatting of markdown files, i've added prettier and formatted our
markdown files with it.

I've excluded the changelog and the generated references documentation
from this for having too many changes, but we can also include them.

I'm not particular on which style we use. My main motivations are
(major) not having to reflow markdown files myself anymore and (minor)
consistence between all markdown files. I've chosen prettier for similar
reason as we chose black, it's a single good style that's automated and
shared in the community. I do prefer prettier's style of not breaking
inside of a link name though.

This PR is in two parts, the first adds prettier to CI and documents
using it, while the second actually formats the docs. When merge
conflicts arise, we can drop the last commit and regenerate it with `npx
prettier --prose-wrap always --write BENCHMARKS.md CONTRIBUTING.md
README.md STYLE.md docs/*.md docs/concepts/**/*.md docs/guides/**/*.md
docs/pip/**/*.md`.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-08-02 08:58:31 -05: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
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
Zanie Blue
3581e27cdf
Bundle of docs changes (#5426) 2024-07-24 17:10:33 -05:00
Zanie Blue
6492f1a897
A bundle of documentation changes (#5239)
I just need to iterate on everything and we're not doing a lot of
reviews anyway.

Closes #5234 
Closes #5191
2024-07-22 17:15:11 +00:00
Zanie Blue
67050932fa
We will find your Python (#5145)
https://github.com/astral-sh/uv/pull/5133#discussion_r1681179083
2024-07-17 14:46:12 +00:00
Zanie Blue
b1501e64e2
Touch-ups to the Python installation guide (#5133) 2024-07-17 09:28:55 -05:00
Charlie Marsh
e61a221fef
Migrate from MdBook to MkDocs (#5062)
## Summary

We want to have consistency between the Ruff and uv documentation for
the upcoming release. We don't love the Ruff docs, but we'd rather have
consistency and then work towards improving them both, rather than have
two very-different documentation sites that both have weaknesses.

The setup here is simpler than in Ruff as: (1) we don't yet generate any
docs from Rust and (2) we don't try to reuse the README in the uv
documentation (which adds a lot of complexity in Ruff). So the change
here is mostly a 1-to-1 port to MkDocs.

## Test Plan

![Screenshot 2024-07-14 at 9 49
15 PM](https://github.com/user-attachments/assets/8bfb5b06-08ff-4329-b368-d9087b78996e)
2024-07-15 22:22:07 +00:00
Zanie Blue
067b3ee666
Add some references to more details in the Python install guide (#4962) 2024-07-10 10:37:53 -05:00
Zanie Blue
5b6dffe522
Update "Python versions" documentation (#4943)
Replacing references to toolchains
2024-07-10 01:07:27 +00:00
Zanie Blue
e01022d75b
Add Python installation guide (#4942)
Note some of this behavior does not exist yet.
2024-07-09 20:05:59 -05:00
Zanie Blue
12e12d066d
Restructure documentation sections to focus on new user experience (#4586)
Moving the preview features to top-level concepts and pushing the
pip-compatible interface down.

e.g.

<img width="291" alt="Screenshot 2024-06-27 at 7 03 48 AM"
src="500ad97d-899d-4051-b59d-e74786b3a45f">
2024-07-02 11:44:45 -05:00