Commit graph

364 commits

Author SHA1 Message Date
Zanie Blue
8ef5949294 Discover and respect .python-version files in parent directories (#6370)
Uses #6369 for test coverage.

Updates version file discovery to search up into parent directories.
Also refactors Python request determination to avoid duplicating the
user request / version file / workspace lookup logic in every command
(this supersedes the work started in
https://github.com/astral-sh/uv/pull/6372).

There is a bit of remaining work here, mostly around documentation.
There are some edge-cases where we don't use the refactored request
utility, like `uv build` — I'm not sure how I'm going to handle that yet
as it needs a separate root directory.
2024-11-07 14:29:54 -06:00
Charlie Marsh
633467576b Use base executable to set virtualenv Python path (#8481)
See extensive discussion in
https://github.com/astral-sh/uv/pull/8433#issuecomment-2430472849.

This PR brings us into alignment with the standard library by using
`sys._base_executable` rather than canonicalizing the executable path.

The benefits are primarily for Homebrew, where we'll now resolve to
paths like `/opt/homebrew/opt/python@3.12/bin` instead of the
undesirable
`/opt/homebrew/Cellar/python@3.9/3.9.19_1/Frameworks/Python.framework/Versions/3.9/bin`.

Most other users should see no change, though in some cases, nested
virtual environments now have slightly different behavior -- namely,
they _sometimes_ resolve to the virtual environment Python (at least for
Homebrew; not for rtx or uv Pythons though). See
[here](https://docs.google.com/spreadsheets/d/1Vw5ClYEjgrBJJhQiwa3cCenIA1GbcRyudYN9NwQaEcM/edit?gid=0#gid=0)
for a breakdown.

Closes https://github.com/astral-sh/uv/issues/1640.
Closes https://github.com/astral-sh/uv/issues/1795.
2024-11-07 14:29:54 -06:00
Zanie Blue
8034de7295 Treat the base Conda environment as a system environment (#7691)
Closes https://github.com/astral-sh/uv/issues/7124
Closes https://github.com/astral-sh/uv/issues/7137
2024-11-07 14:29:54 -06:00
Zanie Blue
88331e756e
Improve Python discovery source messages (#8890)
e.g.

```
❯ echo "anyio" |  cargo run -q -- pip compile - -v
DEBUG uv 0.4.30 (107ab3d71 2024-11-07)
DEBUG Starting Python discovery for a default Python
DEBUG Looking for exact match for request a default Python
DEBUG Searching for default Python interpreter in virtual environments, managed installations, or search path
DEBUG Found `cpython-3.12.7-macos-aarch64-none` at `/Users/zb/workspace/uv/.venv/bin/python3` (virtual environment)
```
```
❯ cargo run -q -- pip install anyio -v
DEBUG uv 0.4.30 (107ab3d71 2024-11-07)
DEBUG Searching for default Python interpreter in virtual environments
DEBUG Found `cpython-3.12.7-macos-aarch64-none` at `/Users/zb/workspace/uv/.venv/bin/python3` (virtual environment)
```

vs

```
❯ uv  pip install anyio -v
DEBUG uv 0.4.30 (61ed2a236 2024-11-04)
DEBUG Searching for default Python interpreter in system path
DEBUG Found `cpython-3.12.7-macos-aarch64-none` at `/Users/zb/workspace/uv/.venv/bin/python3` (virtual environment)
```

```
❯ echo "anyio" | uv pip compile - -v
DEBUG uv 0.4.30 (61ed2a236 2024-11-04)
DEBUG Starting Python discovery for a default Python
DEBUG Looking for exact match for request a default Python
DEBUG Searching for default Python interpreter in managed installations or system path
DEBUG Found `cpython-3.12.7-macos-aarch64-none` at `/Users/zb/workspace/uv/.venv/bin/python3` (virtual environment)
```
2024-11-07 14:08:49 -06:00
Zanie Blue
fb1d679f69
Improve interactions with existing Python executables during install (#8733)
Previously, we'd use the `--reinstall` flag to determine if we should
replace existing Python executables in the bin directory during an
install. There are a few problems with this:

- We replace executables we don't manage
- We can replace executables from other uv Python installations during
reinstall (surprising)
- We don't do the "right" thing when installing patch versions e.g.
installing `3.12.4` then `3.12.6` would fail without the reinstall flag

In `uv tool`, we have separate `--force` and `--reinstall` concepts.
Here we separate the flags (`--force` was previously just a
`--reinstall` alias) and add inspection of the existing executables to
inform a decision on replacement.

In brief, we will:

- Replace any executables with `--force`
- Replace executables for the same installation with `--reinstall`
- Replace executables for an older patch version by default
2024-11-04 20:22:44 +00:00
Andrew Gallant
acaed763b7 uv: use ResolverEnvironment instead of ResolverMarkers
This updates the surrounding code to use the new ResolverEnvironment
type. In some cases, this simplifies caller code by removing case
analysis. There *shouldn't* be any behavior changes here. Some test
snapshots were updated to account for some minor tweaks to error
messages.

I didn't split this up into separate commits because it would have been
too difficult/costly.
2024-11-04 11:09:06 -05:00
Zanie Blue
6250b900b7
Allow managed downloads with --python-preference system (#8808)
Closes https://github.com/astral-sh/uv/issues/8804
2024-11-04 07:45:24 -06:00
Zanie Blue
8d3408fe39
Add support for installing versioned Python executables on Windows (#8663)
Some checks are pending
CI / integration test | uv publish (push) Blocked by required conditions
CI / check cache | ubuntu (push) Blocked by required conditions
CI / check cache | macos aarch64 (push) Blocked by required conditions
CI / check system | python on debian (push) Blocked by required conditions
CI / check system | python on fedora (push) Blocked by required conditions
CI / check system | python on ubuntu (push) Blocked by required conditions
CI / check system | python on opensuse (push) Blocked by required conditions
CI / check system | python on rocky linux 8 (push) Blocked by required conditions
CI / check system | python on rocky linux 9 (push) Blocked by required conditions
CI / check system | pypy on ubuntu (push) Blocked by required conditions
CI / check system | pyston (push) Blocked by required conditions
CI / check system | alpine (push) Blocked by required conditions
CI / check system | python on macos aarch64 (push) Blocked by required conditions
CI / check system | homebrew python on macos aarch64 (push) Blocked by required conditions
CI / check system | python on macos x86_64 (push) Blocked by required conditions
CI / check system | python3.10 on windows (push) Blocked by required conditions
CI / check system | python3.10 on windows x86 (push) Blocked by required conditions
CI / check system | python3.13 on windows (push) Blocked by required conditions
CI / check system | python3.12 via chocolatey (push) Blocked by required conditions
CI / check system | python3.9 via pyenv (push) Blocked by required conditions
CI / check system | python3.13 (push) Blocked by required conditions
CI / check system | conda3.11 on linux (push) Blocked by required conditions
CI / check system | conda3.8 on linux (push) Blocked by required conditions
CI / check system | conda3.11 on macos (push) Blocked by required conditions
CI / check system | conda3.8 on macos (push) Blocked by required conditions
CI / check system | conda3.11 on windows (push) Blocked by required conditions
CI / check system | conda3.8 on windows (push) Blocked by required conditions
CI / check system | amazonlinux (push) Blocked by required conditions
CI / check system | embedded python3.10 on windows (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
Incorporating #8637 into #8458 

- Adds `python-managed` feature selection to Windows CI for `python
install` tests
- Adds trampoline sniffing utilities to `uv-trampoline-builder`
- Uses a trampoline to install Python executables into the `PATH` on
Windows
2024-10-31 15:58:35 +00:00
Zanie Blue
893257bb0b
Refactor uv python install (#8701)
Pulling out of https://github.com/astral-sh/uv/pull/8650 for
readability.

Trying to clean this up to simplify extensions in the future. This is
not a strict refactor, there are behavioral changes here.

- Adds some structs for managing state.
- Addresses some likely inconsistent behavior for weird edge-cases. 
- We fill platform information before checking if a request is
satisfied.
- We error earlier if we can't find a download for the request, i.e.,
even if you somehow have it installed.
- Only reports versions as uninstalled if a download actually replaces
them.
- Moves some of the default output to tracing messages.
- Even if an installation was already satisfied, we'll check that it is
setup properly
2024-10-30 21:28:08 +00:00
Zanie Blue
4dd36b799f
Install versioned Python executables into the bin directory during uv python install (#8458)
Some checks are pending
CI / integration test | determine publish changes (push) Blocked by required conditions
CI / integration test | uv publish (push) Blocked by required conditions
CI / check cache | ubuntu (push) Blocked by required conditions
CI / check cache | macos aarch64 (push) Blocked by required conditions
CI / check system | python on debian (push) Blocked by required conditions
CI / check system | python on fedora (push) Blocked by required conditions
CI / check system | python on ubuntu (push) Blocked by required conditions
CI / check system | python on opensuse (push) Blocked by required conditions
CI / check system | homebrew python on macos aarch64 (push) Blocked by required conditions
CI / check system | python on rocky linux 8 (push) Blocked by required conditions
CI / check system | python on rocky linux 9 (push) Blocked by required conditions
CI / check system | pypy on ubuntu (push) Blocked by required conditions
CI / check system | pyston (push) Blocked by required conditions
CI / check system | alpine (push) Blocked by required conditions
CI / check system | python on macos aarch64 (push) Blocked by required conditions
CI / check system | python3.10 on windows (push) Blocked by required conditions
CI / check system | python3.10 on windows x86 (push) Blocked by required conditions
CI / check system | python3.13 on windows (push) Blocked by required conditions
CI / check system | python3.12 via chocolatey (push) Blocked by required conditions
CI / check system | python3.9 via pyenv (push) Blocked by required conditions
CI / check system | python3.13 (push) Blocked by required conditions
CI / check system | conda3.11 on linux (push) Blocked by required conditions
CI / check system | conda3.8 on linux (push) Blocked by required conditions
CI / check system | conda3.11 on macos (push) Blocked by required conditions
CI / check system | conda3.8 on macos (push) Blocked by required conditions
CI / check system | conda3.11 on windows (push) Blocked by required conditions
CI / check system | conda3.8 on windows (push) Blocked by required conditions
CI / check system | amazonlinux (push) Blocked by required conditions
CI / check system | embedded python3.10 on windows (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
Updates `uv python install` to link `python3.x` in the executable
directory (i.e., `~/.local/bin`) to the the managed interpreter path.

Includes

- #8569 
- #8571 

Remaining work

- #8663 
- #8650 
- Add an opt-out setting and flag
- Update documentation
2024-10-30 14:13:20 +00:00
konsti
d0afd10ca4
Update windows-registry to 0.3.0 (#8696) 2024-10-30 12:00:33 +00:00
Pietro Zambelli
2b0e16cb75
Fix hard and soft float libc detection for managed Python distributions on ARM (#8498)
Some checks are pending
CI / integration test | uv publish (push) Blocked by required conditions
CI / check cache | ubuntu (push) Blocked by required conditions
CI / check cache | macos aarch64 (push) Blocked by required conditions
CI / check system | python on debian (push) Blocked by required conditions
CI / check system | python on fedora (push) Blocked by required conditions
CI / check system | python on ubuntu (push) Blocked by required conditions
CI / check system | python on opensuse (push) Blocked by required conditions
CI / check system | python on rocky linux 8 (push) Blocked by required conditions
CI / check system | python on rocky linux 9 (push) Blocked by required conditions
CI / check system | pypy on ubuntu (push) Blocked by required conditions
CI / check system | pyston (push) Blocked by required conditions
CI / check system | alpine (push) Blocked by required conditions
CI / check system | python on macos aarch64 (push) Blocked by required conditions
CI / check system | homebrew python on macos aarch64 (push) Blocked by required conditions
CI / check system | python on macos x86_64 (push) Blocked by required conditions
CI / check system | python3.10 on windows (push) Blocked by required conditions
CI / check system | python3.10 on windows x86 (push) Blocked by required conditions
CI / check system | python3.13 on windows (push) Blocked by required conditions
CI / check system | python3.12 via chocolatey (push) Blocked by required conditions
CI / check system | python3.9 via pyenv (push) Blocked by required conditions
CI / check system | python3.13 (push) Blocked by required conditions
CI / check system | conda3.11 on linux (push) Blocked by required conditions
CI / check system | conda3.8 on linux (push) Blocked by required conditions
CI / check system | conda3.11 on macos (push) Blocked by required conditions
CI / check system | conda3.8 on macos (push) Blocked by required conditions
CI / check system | conda3.11 on windows (push) Blocked by required conditions
CI / check system | conda3.8 on windows (push) Blocked by required conditions
CI / check system | amazonlinux (push) Blocked by required conditions
CI / check system | embedded python3.10 on windows (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
2024-10-29 23:46:21 +00:00
Zanie Blue
94ae79d90d
Add riscv64 to supported Python platform tags (#8660)
Closes #8657
2024-10-29 08:48:19 -05:00
Zanie Blue
dc23a60277
Add support for requesting free-threaded builds via +freethreaded (#8645)
e.g., `uv python install 3.13+freethreaded` which matches the
distribution keys.
2024-10-28 15:22:49 -05:00
konsti
3eda248ef5
Always attach URL to network errors (#8444) 2024-10-25 09:10:18 +00:00
Jo
41462e5987
Fix a typo in fetch-download-metadata.py (#8515)
Fix this typo:

98523e2014/crates/uv-python/fetch-download-metadata.py (L399)

and removed an empty line in the `downloads.inc.mustache" template.
2024-10-24 07:33:14 -05:00
Jo
9540d6ad24
Use reinstall report formatting for uv python install --reinstall (#8487)
## Summary

Resolves #8456

## Test Plan

```console
$ cargo run -- python install 3.13
$ cargo run -- python install --reinstall 3.13
Searching for Python versions matching: Python 3.13
Found existing installation for Python 3.13: cpython-3.13.0-macos-aarch64-none
Installed Python 3.13.0 in 7.39s
 ~ cpython-3.13.0-macos-aarch64-none
```

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-10-23 18:53:33 +00:00
Jo
56f93d9cfc
uv python install: remove the existing version only after the new installation is downloaded successfully (#8485)
## Summary

This PR delays the removal of an existing version after downloading the
new version when running `uv python install --reinstall`.

If the download fails, we can keep the existing version working.

## Test Plan

```console
$ cargo run -- python install 3.13
$ cargo run -- python install --reinstall 3.13 # when downloading, `ctrl-c` to interrupt
$ cargo run -- python list
```
2024-10-23 14:43:09 -04:00
konsti
e7ae0f50d2
Respect allow insecure host in publish (#8440) 2024-10-22 13:36:18 +02:00
Zanie Blue
c8cbd62a30
Patch Python executable name for Windows free-threaded builds (#8310)
A temporary fix for https://github.com/astral-sh/uv/issues/8298 while we
wait for my slower upstream fix at
https://github.com/indygreg/python-build-standalone/pull/373

I think we'll want this machinery anyway to ensure that the various
executable names are available? Otherwise we need to special-case all
the `python` names in `uv run`?

We don't have unit test coverage of managed downloads, so I added an
[integration
test](3170395680)
similar to what we have for Linux.
2024-10-17 18:27:55 -05:00
Zanie Blue
b851ced09e
Fix selection of free-threaded interpreters during default Python discovery (#8239)
Closes https://github.com/astral-sh/uv/issues/8228

e.g., on this branch

```
❯ uv python install 3.13t 3.13
❯ cargo build
❯ cargo run -q --bin uvx -- --from build python -c "import sys; print(sys.base_prefix)"
/Users/zb/.local/share/uv/python/cpython-3.13.0-macos-aarch64-none
❯ cargo run -q --bin uvx -- -p 3.13 --from build python -c "import sys; print(sys.base_prefix)"
/Users/zb/.local/share/uv/python/cpython-3.13.0-macos-aarch64-none
❯ cargo run -q --bin uvx -- -p 3.13t --from build python -c "import sys; print(sys.base_prefix)"
/Users/zb/.local/share/uv/python/cpython-3.13.0+freethreaded-macos-aarch64-none
```

and on main

```
❯ cargo build
❯ cargo run -q --bin uvx -- --from build python -c "import sys; print(sys.base_prefix)"
Installed 3 packages in 12ms
/Users/zb/.local/share/uv/python/cpython-3.13.0+freethreaded-macos-aarch64-none
```

I want to add more test coverage around this, but I've noticed the
free-threaded discovery tests are a bit off as-is and it'll be a bigger
task. I think the recent bugs around discovery indicate we should invest
more into that test framework.
2024-10-16 14:44:32 -05:00
github-actions[bot]
94a2686385
Fix managed distributions of free-threaded Python on Windows (#8268)
See upstream fix at
https://github.com/indygreg/python-build-standalone/pull/368

Co-authored-by: zanieb <2586601+zanieb@users.noreply.github.com>
2024-10-16 14:35:29 -05:00
Zanie Blue
824dedad76
Retain old python-build-standalone releases (#8216)
Closes https://github.com/astral-sh/uv/issues/8213

I didn't mean to remove these when updating the regular expression.
Arguably, they shouldn't be used anymore, but we should make that choice
with intention.
2024-10-15 11:08:46 -05:00
Zanie Blue
b697cee3e1
Prefer optimized builds for freethreaded Python downloads (#8196)
Addresses report in https://github.com/astral-sh/uv/issues/8194
2024-10-15 08:00:02 -04:00
Zanie Blue
b466202305
Do not use free-threaded interpreters without a free-threaded request (#8191)
As mentioned in https://github.com/astral-sh/uv/issues/8189

We only checked if an interpreter was free-threaded _when_ free-threaded
variants were requested. But we should not use free-threaded
interpreters unless explicitly requested.
2024-10-14 22:48:32 +00:00
samypr100
01c44af3c3
chore: unify all env vars used (#8151)
## Summary

This PR declares and documents all environment variables that are used
in one way or another in `uv`, either internally, or externally, or
transitively under a common struct.

I think over time as uv has grown there's been many environment
variables introduced. Its harder to know which ones exists, which ones
are missing, what they're used for, or where are they used across the
code. The docs only documents a handful of them, for others you'd have
to dive into the code and inspect across crates to know which crates
they're used on or where they're relevant.

This PR is a starting attempt to unify them, make it easier to discover
which ones we have, and maybe unlock future posibilities in automating
generating documentation for them.

I think we can split out into multiple structs later to better organize,
but given the high influx of PR's and possibly new environment variables
introduced/re-used, it would be hard to try to organize them all now
into their proper namespaced struct while this is all happening given
merge conflicts and/or keeping up to date.

I don't think this has any impact on performance as they all should
still be inlined, although it may affect local build times on changes to
the environment vars as more crates would likely need a rebuild. Lastly,
some of them are declared but not used in the code, for example those in
`build.rs`. I left them declared because I still think it's useful to at
least have a reference.

Did I miss any? Are their initial docs cohesive?

Note, `uv-static` is a terrible name for a new crate, thoughts? Others
considered `uv-vars`, `uv-consts`.

## Test Plan

Existing tests
2024-10-14 16:48:13 -05:00
Zanie Blue
5f33915e03
Add support for managed installs of free-threaded Python (#8100)
Closes https://github.com/astral-sh/uv/issues/7193

```

❯ cargo run -q -- python uninstall 3.13t
Searching for Python versions matching: Python 3.13t
Uninstalled Python 3.13.0 in 231ms
 - cpython-3.13.0+freethreaded-macos-aarch64-none
❯ cargo run -q -- python install 3.13t
Searching for Python versions matching: Python 3.13t
Installed Python 3.13.0 in 3.54s
 + cpython-3.13.0+freethreaded-macos-aarch64-none
❯ cargo run -q -- python install 3.12t
Searching for Python versions matching: Python 3.12t
error: No download found for request: cpython-3.12t-macos-aarch64-none
❯ cargo run -q -- python install 3.13rc3t
Searching for Python versions matching: Python 3.13rc3t
Found existing installation for Python 3.13rc3t: cpython-3.13.0+freethreaded-macos-aarch64-none
❯ cargo run -q -- run -p 3.13t python -c "import sys; print(sys.base_prefix)"
/Users/zb/.local/share/uv/python/cpython-3.13.0+freethreaded-macos-aarch64-none
```
2024-10-14 15:18:52 -05:00
Zanie Blue
da7ffd3357
Fix error message consistency for broken virtual environments due to pyvenv.cfg (#8180) 2024-10-14 13:22:30 -05:00
Amos Wenger
715f28fd39
chore: Move all integration tests to a single binary (#8093)
As per
https://matklad.github.io/2021/02/27/delete-cargo-integration-tests.html

Before that, there were 91 separate integration tests binary.

(As discussed on Discord — I've done the `uv` crate, there's still a few
more commits coming before this is mergeable, and I want to see how it
performs in CI and locally).
2024-10-11 16:41:35 +02:00
Zanie Blue
82708944a3
Fix uv python pin 3.13t failure when parsing version for project requires check (#8056)
Closes https://github.com/astral-sh/uv/issues/7964

We can probably do some restructuring to avoid unwrapping here in the
future, but this just fixes the bug quick.
2024-10-10 00:17:20 +00:00
trag1c
37273cb4bc
Add prerelease compatibility check (#8020)
## Summary

Closes #7977. Makes `PythonDownloadRequest` account for the prerelease
part if allowed. Also stores the prerelease in `PythonInstallationKey`
directly as a `Prerelease` rather than a string.

## Test Plan

Correctly picks the relevant prerelease (rather than picking the most
recent one):
```
λ cargo run python install 3.13.0rc2
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.17s
     Running `target/debug/uv python install 3.13.0rc2`
Searching for Python versions matching: Python 3.13rc2
cpython-3.13.0rc2-macos-aarch64-none ------------------------------ 457.81 KiB/14.73 MiB                                                                                                                    ^C

λ cargo run python install 3.13.0rc3                 
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.17s
     Running `target/debug/uv python install 3.13.0rc3`
Searching for Python versions matching: Python 3.13rc3
Found existing installation for Python 3.13rc3: cpython-3.13.0rc3-macos-aarch64-none
```
2024-10-08 16:20:58 -05:00
Kemal Akkoyun
1a39ffe391
uv run: List available scripts when a script is not specified (#7687)
Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
## Summary

This PR adds the ability to list available scripts in the environment
when `uv run` is invoked without any arguments.
It somewhat mimics the behavior of `rye run` command
(See https://rye.astral.sh/guide/commands/run).

This is an attempt to fix #4024.

## Test Plan

I added test cases. The CI pipeline should pass.

### Manuel Tests

```shell
❯ uv run
Provide a command or script to invoke with `uv run <command>` or `uv run script.py`.

The following scripts are available:

normalizer
python
python3
python3.12

See `uv run --help` for more information.
```

---------

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-10-08 19:34:50 +00:00
Zanie Blue
f6fd849f2c
Add managed downloads for CPython 3.13.0 final (#8010) 2024-10-08 12:53:09 -05:00
Zanie Blue
46ff220508
Remove PythonPreference toggle based on UV_TEST_PYTHON_PATH (#7989)
Needed for https://github.com/astral-sh/uv/pull/7934

This is some legacy logic, I think.
2024-10-07 21:13:19 +00:00
Zanie Blue
e479e8b4b3
Show interpreter source during Python discovery query errors (#7928)
Closes https://github.com/astral-sh/uv/issues/4154

e.g.

```
❯ UV_PYTHON=/dev/null cargo run -q -- pip install anyio
error: Failed to inspect Python interpreter from provided path at `/dev/null` 
  Caused by: Failed to query Python interpreter at `/dev/null`
  Caused by: Permission denied (os error 13)
  
❯ VIRTUAL_ENV=/dev/null cargo run -q -- pip install anyio
error: Failed to inspect Python interpreter from active virtual environment at `/dev/null/bin/python3` 
  Caused by: Failed to query Python interpreter
  Caused by: failed to canonicalize path `/dev/null/bin/python3`
  Caused by: Not a directory (os error 20)
```
2024-10-07 12:57:18 -05:00
Zanie Blue
c69b808e43
Fix parsing of gnueabi libc variants in Python version requests (#7975)
```
❯ cargo run -q -- python install cpython-3.12.6-linux-armv7-gnueabihf
Searching for Python versions matching: cpython-3.12.6-linux-armv7-gnueabihf
Installed Python 3.12.6 in 2.10s
 + cpython-3.12.6-linux-armv7-gnueabihf

❯ uv python install cpython-3.12.6-linux-armv7-gnueabihf
error: Cannot download managed Python for request: executable name `cpython-3.12.6-linux-armv7-gnueabihf`
```
2024-10-07 15:49:21 +00:00
Jo
172bff4aec
Organize downloads by prioritizing the platform, then the architecture. (#7900)
## Summary

PythonDownloadKey (cpython-3.13.0rc3-darwin-aarch64-none) and
PlatformTriple in `fetch-download-metadata.py` have a slight
inconsistency in the ordering of `os` and `arch`. In PythonDownloadKey,
`os` precedes `arch`, while in PlatformTriple, `arch` comes before
`platform` (equivalent to os). This difference in ordering affects the
sorting logic, giving arch higher priority than platform in the
`download-metadata.json` file, leading to a little bit of unexpected
order of entries.

Before:
<img width="676" alt="image"
src="https://github.com/user-attachments/assets/adb24a2e-da70-4a09-a702-4b5d71600b2c">
After:
<img width="725" alt="image"
src="https://github.com/user-attachments/assets/c6c76e6a-d3fd-43dc-bfb0-b3a4a3fe2b6b">
2024-10-03 10:51:21 -05:00
Jo
32ab2a5a95
Fix Python prerelease sorting (#7884)
## Summary

Observed from #7880, `rc3` should be sorted before `rc2`.
2024-10-03 13:03:19 +01:00
github-actions[bot]
1635f6da0c
Add CPython 3.13.0rc3 and 3.12.7 downloads (#7880)
Automated update for Python releases.

Co-authored-by: zanieb <2586601+zanieb@users.noreply.github.com>
2024-10-02 17:20:48 -05:00
Zanie Blue
891c91dd3a
Use an enum for free-threaded Python requests (#7871)
Follow-up to #7431 improving readability
2024-10-02 13:10:45 -05:00
Charlie Marsh
f0659e76cf
Rename install-wheel-rs library (#7855)
## Summary

I missed this one in the rename (the crate was renamed, but not the
library).
2024-10-01 20:45:39 -04:00
Charlie Marsh
14507a1793
Add uv- prefix to all internal crates (#7853)
## Summary

Brings more consistency to the repo and ensures that all crates
automatically show up in `--verbose` logging.
2024-10-01 20:15:32 -04:00
Aarni Koskela
ed940300f7
Don't create Python bytecode files during interpreter discovery (#7707) 2024-09-26 13:52:10 +00:00
tfsingh
106633a5e5
Add support for upgrading Python in tool environments (#7605)
This PR adds support for upgrading the build environment of tools with
the addition of a ```--python``` argument to ```uv upgrade```, as
specified in #7471.

Some things to note:
- I added support for individual packages — I didn't think there was a
good reason for ```--python``` to only apply to all packages
- Upgrading with ```--python``` also upgrades the package itself — I
think this is fair as if a user wants to _strictly_ switch the version
of Python being used to build a tool's environment they can use ```uv
install```. This behavior can of course be modified if others don't
agree!

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

Closes https://github.com/astral-sh/uv/issues/7471.
2024-09-25 17:40:28 +00:00
Zanie Blue
bef72a8880
Display skipped managed interpreters during Python discovery (#7668)
e.g.

```
❯ cargo run -- python find 3.11rc2 -v
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.14s
     Running `target/debug/uv python find 3.11rc2 -v`
DEBUG uv 0.4.15
DEBUG Searching for Python 3.11rc2 in managed installations or system path
DEBUG Found `cpython-3.12.1-macos-aarch64-none` at `/Users/zb/workspace/uv/.venv/bin/python3` (active virtual environment)
DEBUG Found `cpython-3.12.1-macos-aarch64-none` at `/Users/zb/workspace/uv/.venv/bin/python3` (virtual environment)
DEBUG Searching for managed installations at `/Users/zb/.local/share/uv/python`
DEBUG Skipping incompatible managed installation `cpython-3.13.0rc2-macos-aarch64-none`
DEBUG Skipping incompatible managed installation `cpython-3.12.1-macos-aarch64-none`
DEBUG Skipping incompatible managed installation `cpython-3.11.7-macos-aarch64-none`
DEBUG Skipping incompatible managed installation `cpython-3.10.13-macos-aarch64-none`
DEBUG Skipping incompatible managed installation `cpython-3.9.18-macos-aarch64-none`
DEBUG Skipping incompatible managed installation `cpython-3.8.18-macos-aarch64-none`
DEBUG Skipping incompatible managed installation `cpython-3.8.12-macos-aarch64-none`
DEBUG Skipping incompatible managed installation `pypy-3.9.19-macos-aarch64-none`
DEBUG Found `cpython-3.12.1-macos-aarch64-none` at `/Users/zb/workspace/uv/.venv/bin/python` (search path)
DEBUG Found `cpython-3.12.1-macos-aarch64-none` at `/Users/zb/workspace/uv/.venv/bin/python3` (search path)
DEBUG Found `cpython-3.12.6-macos-aarch64-none` at `/opt/homebrew/bin/python3` (search path)
DEBUG Found `cpython-3.11.10-macos-aarch64-none` at `/opt/homebrew/bin/python3.11` (search path)
DEBUG Found `cpython-3.9.6-macos-aarch64-none` at `/usr/bin/python3` (search path)
error: No interpreter found for Python 3.11rc2 in virtual environments, managed installations, or system path
```
2024-09-24 14:41:41 -05:00
Zanie Blue
e6cd6c9b01
Use the first pre-release discovered when only pre-release Python versions are available (#7666) 2024-09-24 18:00:28 +00:00
Zanie Blue
a53ddaa24a
Require opt-in to use alternative Python implementations (#7650)
Closes #7118 

This only really affects managed interpreters, as we exclude alternative
Python implementations from the search path during the
`VersionRequest::executable_names` part of discovery.
2024-09-24 12:52:15 -05:00
Bas Schoenmaeckers
77c2496f47
Allow creating venv with free-threaded python builds (#7431)
<!--
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

closes #4828

First iteration for an implementation. I need to add more tests but
wanted your opinion on the implementation first.

<!-- What's the purpose of the change? What does it do, and why? -->

## Test Plan
Currently tested using the following command but will add tests shortly:

```console
D:\repo\uv> cargo run venv -p 3.13t && .venv\Scripts\python.exe
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.52s
     Running `target\debug\uv.exe venv -p 3.13t`
Using Python 3.13.0rc1 interpreter at: C:\Users\bschoen\AppData\Local\Programs\Python\Python313\python3.13t.exe
Creating virtualenv at: .venv
Activate with: .venv\Scripts\activate
Python 3.13.0rc1 experimental free-threading build (tags/v3.13.0rc1:e4a3e78, Jul 31 2024, 21:06:58) [MSC v.1940 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> 
```

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-09-23 17:36:16 -05:00
Zanie Blue
0dea932d83
Improve Python executable name discovery when using alternative implementations (#7649)
There are two parts to this. 

The first is a restructuring and refactoring. We had some debt around
expected executable name generation, which we address here by
consolidating into a single function that generates a combination of
names. This includes a bit of extra code around free-threaded variants
because this was written on top of #7431 — I'll rebase that on top of
this.

The second addresses some bugs around alternative implementations.
Notably, `uv python list` does not discovery executables with
alternative implementation names. Now, we properly generate all of the
executable names for `VersionRequest::Any` (originally implemented in
https://github.com/astral-sh/uv/pull/7508) to properly show all the
implementations we can find:

```
❯ cargo run -q -- python list --no-python-downloads
cpython-3.12.6-macos-aarch64-none     /opt/homebrew/opt/python@3.12/bin/python3.12 -> ../Frameworks/Python.framework/Versions/3.12/bin/python3.12
cpython-3.11.10-macos-aarch64-none    /opt/homebrew/opt/python@3.11/bin/python3.11 -> ../Frameworks/Python.framework/Versions/3.11/bin/python3.11
cpython-3.9.6-macos-aarch64-none      /Library/Developer/CommandLineTools/usr/bin/python3 -> ../../Library/Frameworks/Python3.framework/Versions/3.9/bin/python3
pypy-3.10.14-macos-aarch64-none       /opt/homebrew/bin/pypy3 -> ../Cellar/pypy3.10/7.3.17/bin/pypy3
```

While doing both of these changes, I ended up changing the priority of
interpreter discovery slightly. For example, given that the executables
are in the same directory, do we query `python` or `python3.10` first
when you request `--python 3.10`? Previously, we'd check `python3.10`
but I think that was an incorrect optimization. I think we should always
prefer the bare name (i.e. `python`) first. Similarly, this applies to
`python` and an executable for an alternative implementation like
`pypy`. If it's not compatible with the request, we'll skip it anyway.
We might have to query more interpreters with this approach but it seems
rare.


Closes https://github.com/astral-sh/uv/issues/7286 superseding
https://github.com/astral-sh/uv/pull/7508
2024-09-23 17:17:55 -05:00
Zanie Blue
bbb1d3f85a
Determine if pre-release Python downloads should be allowed using the version specifiers (#7638)
Closes #7637

```
❯ uv python install '>=3.11'
Installed Python 3.12.6 in 1.70s
 + cpython-3.12.6-macos-aarch64-none

❯ uv python install 3.13
Installed Python 3.13.0rc2 in 1.89s
 + cpython-3.13.0rc2-macos-aarch64-none

❯ uv python uninstall --all
Searching for Python installations
Uninstalled 2 versions in 94ms
 - cpython-3.12.6-macos-aarch64-none
 - cpython-3.13.0rc2-macos-aarch64-none

❯ uv python install '>=3.11a1'
Installed Python 3.13.0rc2 in 1.89s
 + cpython-3.13.0rc2-macos-aarch64-none
```
2024-09-23 14:08:59 -05:00