Commit graph

254 commits

Author SHA1 Message Date
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
Zanie Blue
9164999f23
Allow system environments during project environment validity check (#7585) 2024-09-20 12:28:17 -05:00
Zanie Blue
6b08aaecad
Avoid warning about bad Python interpreter links for empty project environment directories (#7527)
Someone reported this a while back (will try to find the issue), and I
ran into it working on #7522
2024-09-19 06:49:35 -05:00
Zanie Blue
09a2ebca8b
Add new PythonRequest::Any and VersionRequest::Any variants (#7517)
Follow-up to https://github.com/astral-sh/uv/pull/7514 and #7526 adding
the `Any` variants again with slightly different semantics (i.e., they
allow pre-releases)

We'll be able to use this in https://github.com/astral-sh/uv/pull/7508
to avoid querying a bunch of alternative interpreters unnecessarily in
the non-list case.
2024-09-19 11:19:13 +00:00
Zanie Blue
0f9a2e3870
Rename VersionRequest::Any -> VersionRequest::Default (#7526)
As in https://github.com/astral-sh/uv/pull/7514
2024-09-19 11:05:09 +00:00
Zanie Blue
5941709e55
Rename PythonRequest::Any -> PythonRequest::Default (#7514)
As we support more complex Python discovery behaviors such as:

- #7431 
- #7335 
- #7300 

`Any` is no longer accurate, we actually are looking for a reasonable
default Python version to use which may exclude the first one we find.
Separately, we need the idea of `Any` to improve behavior when listing
versions (e.g., #7286) where we do actually want to match _any_ Python
version. As a first step, we'll rename `Any` to `Default`. Then, we'll
introduce a new `Any` that actually behaves as we'd expect.
2024-09-19 05:56:05 -05:00
Zanie Blue
4611412757
Allow Python pre-releases to be used if they are first on the PATH (#7470)
Closes https://github.com/astral-sh/uv/issues/7469
2024-09-18 10:19:10 -05:00
Zanie Blue
08a7c708d1
Do not allow local versions in Python version requests either (#7468)
Accidentally squashed https://github.com/astral-sh/uv/pull/7465 into the
wrong target.
2024-09-17 16:10:38 +00:00
Zanie Blue
8d7925026d
Add VersionRequest test cases for post and dev segments (#7464) 2024-09-17 10:59:41 -05:00
Mikko Leppänen
bb0ffa32e4
Support pre-releases in Python version requests - command --python <major.minor.pre-release> (#7335)
## Summary

This PR adds support to include Python pre-releases when requesting
versions.
Check out the docs for commands that support the `Python` option: 
```text
--python, -p python
The Python interpreter to use for the virtual environment.
```
At least the following scenarios are supported:
```bash
3.13.0a1
3.13b2
3.13rc4
313rc1
```

## Test Plan

I added a basic unit test to `uv/crates/uv-python/src/discovery.rs`. I
could have added more, but I have not discovered any relevant places.

CI passes

Note: I was unable to execute the entire test set locally. There were at
least some timeout issues (some tests took over 60 seconds).

========== output ===========
beta version
```bash
cargo run -- venv --python 3.13.0b3                                                                                                           ░▒▓ 94% 󰁹
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.20s
     Running `target/debug/uv venv --python 3.13.0b3`
Using Python 3.13.0b3 interpreter at: /home/mikko/.pyenv/versions/3.13.0b3/bin/python3
Creating virtualenv at: .venv
Activate with: source .venv/bin/activate
````
release candidate
```bash
 cargo run -- venv --python 3.13.0rc2                                                                                                          ░▒▓ 94% 󰁹
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.83s
     Running `target/debug/uv venv --python 3.13.0rc2`
Using Python 3.13.0rc2 interpreter at: /home/mikko/.pyenv/versions/3.13.0rc2/bin/python3
Creating virtualenv at: .venv
Activate with: source .venv/bin/activate
```

```bash
cargo run -- venv --python 313rc2                                                                                                             ░▒▓ 94% 󰁹
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.31s
     Running `target/debug/uv venv --python 313rc2`
Using Python 3.13.0rc2 interpreter at: /home/mikko/.pyenv/versions/3.13.0rc2/bin/python3
Creating virtualenv at: .venv
Activate with: source .venv/bin/activate
```

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-09-17 09:46:46 -05:00
Charlie Marsh
c87ce7aaf8
Run cargo upgrade (#7448)
Co-authored-by: konstin <konstin@mailbox.org>
2024-09-17 12:39:58 +02:00