Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow version specifiers to be used in Python version requests #4214

Merged
merged 2 commits into from
Jun 10, 2024

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Jun 10, 2024

In service of #4212 but this is user-facing e.g. Python discovery will support version specifiers everywhere now.

Closes #4212

@zanieb zanieb force-pushed the zb/version-request-range branch from e232add to 7f370c3 Compare June 10, 2024 20:05
zanieb added a commit that referenced this pull request Jun 10, 2024
@zanieb zanieb force-pushed the zb/version-request-range branch 2 times, most recently from fc7e190 to 1321ccf Compare June 10, 2024 20:11
@zanieb zanieb marked this pull request as ready for review June 10, 2024 20:12
@zanieb
Copy link
Member Author

zanieb commented Jun 10, 2024

A little terrifying...

❯ cargo run -q -- pip install --python '>=3.8' anyio -v
DEBUG Searching for Python >=3.8 in all sources
DEBUG Found CPython 3.12.3 at `/Users/zb/workspace/uv/.venv/bin/python3` (virtual environment)
DEBUG Using Python 3.12.3 environment at .venv/bin/python3
DEBUG Acquired lock for `.venv`
DEBUG Requirement satisfied: anyio
DEBUG Requirement satisfied: idna>=2.8
DEBUG Requirement satisfied: sniffio>=1.1
Audited 1 package in 15ms

@zanieb zanieb force-pushed the zb/version-request-range branch from 1321ccf to d19f861 Compare June 10, 2024 20:35
----- stdout -----

----- stderr -----
warning: `uv sync` is experimental and may change without warning.
Removing virtual environment at: [VENV]/
error: Requested Python executable `>=3.12` not found in PATH
Using Python 3.12.3 interpreter at: /opt/homebrew/opt/[email protected]/bin/python3.12
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is problematic, need to add a filter for this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

writeln!(
printer.stderr(),
"Using Python {} interpreter at: {}",
interpreter.python_version(),
interpreter.sys_executable().user_display().cyan()
)?;

crates/uv/tests/lock.rs Outdated Show resolved Hide resolved
@zanieb
Copy link
Member Author

zanieb commented Jun 10, 2024

zanieb added a commit that referenced this pull request Jun 10, 2024
Cherry-picked from #4214

The first commit gets us some context on an IO error during queries:

Previously:

```
failed to canonicalize path `[VENV]/bin/python3`
    Caused by: No such file or directory (os error 2)
```

Now:

```
Failed to query Python interpreter
    Caused by: failed to canonicalize path `[VENV]/bin/python3`
    Caused by: No such file or directory (os error 2)
```

but really we shouldn't attempt to query a missing interpreter during
discovery anyway, so we improve handling of that too.
zanieb added a commit that referenced this pull request Jun 10, 2024
By setting the test search path to an empty path, we avoid accidentally
pulling interpreters from the system during a test case.

Cherry-picked from #4214
@zanieb zanieb force-pushed the zb/version-request-range branch from 1a449ca to 662a4c2 Compare June 10, 2024 22:40
@zanieb zanieb merged commit 5f37395 into main Jun 10, 2024
47 checks passed
@zanieb zanieb deleted the zb/version-request-range branch June 10, 2024 23:20
zanieb added a commit that referenced this pull request Jun 11, 2024
…#4216)

Refactor following #4214 to avoid parsing the specifiers again
zanieb added a commit that referenced this pull request Jun 13, 2024
…ecifiers (#4289)

Before 0.2.10 we would parse `--python=python` as an executable name.
After #4214, we started treating
this as a Python version range request (with an empty version range).
This is not entirely unreasonable, but it was an unexpected regression
and I don't think `VersionRequest` should support empty ranges in its
`from_str` implementation without more consideration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Project environment creation doesn't respect version specifiers in requires-python
2 participants