Skip to content

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

Merged
zanieb merged 2 commits into
mainfrom
zb/version-request-range
Jun 10, 2024
Merged

zanieb merged 2 commits into
mainfrom
zb/version-request-range

Conversation

@zanieb

@zanieb zanieb commented Jun 10, 2024 •

Copy link
Copy Markdown
Member

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

zanieb commented Jun 10, 2024

Copy link
Copy Markdown
Member Author

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
Comment thread crates/uv/tests/lock.rs Outdated

Copy link
Copy Markdown
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
Copy Markdown
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()
)?;

Comment thread crates/uv/tests/lock.rs Outdated
@zanieb

zanieb commented Jun 10, 2024

Copy link
Copy Markdown
Member Author

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
@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