-
Notifications
You must be signed in to change notification settings - Fork 738
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
Use windows registry to discover python #6761
Conversation
Our current strategy of parsing the output of `py --list-paths` to get the installed python versions on windows is brittle (#6524, missing `py`, etc.) and it's slow (10ms last time i measured). Instead, we should behave spec-compliant and read the python versions from the registry following PEP 514. We're using the official rust-for-windows crates for accessing the registry. Fixes #1521 Fixes #6524
e950624
to
211815f
Compare
Awesome! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As PEP 514 author, I'm happy to see this!
Do note that Store installs don't always show up properly in the registry due to how Windows handles its redirection (and it changes over time as Python chooses different redirection settings). For the py.exe
launcher, we also do a specific search for known package IDs to locate Store installs. Not sure whether you want to copy that or not.
Thank you for taking a look @zooba! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you double check the documentation is updated? e.g.,
uv/docs/concepts/python-versions.md
Line 172 in ae57d85
- On Windows, the Python interpreter returned by `py --list-paths` that matches the requested |
Thanks for the reminder! |
docs/concepts/python-versions.md
Outdated
[ | ||
`python-build-standalone` quirks](https://gregoryszorc.com/docs/python-build-standalone/main/quirks.html) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks wrong
[ | |
`python-build-standalone` quirks](https://gregoryszorc.com/docs/python-build-standalone/main/quirks.html) | |
[`python-build-standalone` quirks](https://gregoryszorc.com/docs/python-build-standalone/main/quirks.html) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran prettier now
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [astral-sh/uv](https://github.com/astral-sh/uv) | patch | `0.4.0` -> `0.4.4` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>astral-sh/uv (astral-sh/uv)</summary> ### [`v0.4.4`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#044) [Compare Source](astral-sh/uv@0.4.3...0.4.4) ##### Enhancements - Allow customizing the project environment path with `UV_PROJECT_ENVIRONMENT` ([#​6834](astral-sh/uv#6834)) - Warn when `VIRTUAL_ENV` is set but will not be respected in project commands ([#​6864](astral-sh/uv#6864)) - Add `--no-hashes` to `uv export` ([#​6954](astral-sh/uv#6954)) - Make HTTP headers title case for backward compatibility ([#​6887](astral-sh/uv#6887)) - Pin `.python-version` in `uv init` ([#​6869](astral-sh/uv#6869)) - Support `file://` URLs for `UV_PYTHON_INSTALL_MIRROR` ([#​6950](astral-sh/uv#6950)) - Introduce more docker tags for uv ([#​6053](astral-sh/uv#6053)) ##### Bug fixes - Avoid canonicalizing the cache directory ([#​6949](astral-sh/uv#6949)) - Show all PyPy versions in `uv python list --all-versions` ([#​6917](astral-sh/uv#6917)) - Avoid incorrect `requires-python` marker simplifications ([#​6268](astral-sh/uv#6268)) ##### Documentation - Add documentation for `UV_PROJECT_ENVIRONMENT` ([#​6987](astral-sh/uv#6987)) - Add optional dependencies section to the lockfile document ([#​6982](astral-sh/uv#6982)) - Document use of the `file://` scheme in Python installation mirrors ([#​6984](astral-sh/uv#6984)) - Fix outdated references to the help menu documentation in the first steps page ([#​6980](astral-sh/uv#6980)) - Show env option in CLI reference documentation ([#​6863](astral-sh/uv#6863)) - Add bind mount example to `docker.md` ([#​6921](astral-sh/uv#6921)) ### [`v0.4.3`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#043) [Compare Source](astral-sh/uv@0.4.2...0.4.3) ##### Enhancements - Show build backend output when `--verbose` is provided ([#​6903](astral-sh/uv#6903)) - Allow `uv sync --frozen --package` without copying member `pyproject.toml` ([#​6943](astral-sh/uv#6943)) ##### Bug fixes - Avoid panic with missing temporary directory ([#​6929](astral-sh/uv#6929)) - Avoid updating incorrect dependencies for sorted `uv add` ([#​6939](astral-sh/uv#6939)) - Use lower-bound semantics for all Python compatibility comparisons ([#​6882](astral-sh/uv#6882)) ### [`v0.4.2`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#042) [Compare Source](astral-sh/uv@0.4.1...0.4.2) ##### Enhancements - Adding support for `.pyc` files in `uv run` ([#​6886](astral-sh/uv#6886)) - Treat missing `top_level.txt` as non-fatal ([#​6881](astral-sh/uv#6881)) ##### Bug fixes - Fix `is_disjoint` check for supported environments ([#​6902](astral-sh/uv#6902)) - Remove dangling archives in `uv cache clean ${package}` ([#​6915](astral-sh/uv#6915)) - Error when discovered Python is incompatible with `--isolated` workspace ([#​6885](astral-sh/uv#6885)) - Warn when discovered Python is incompatible with PEP 723 script ([#​6884](astral-sh/uv#6884)) ### [`v0.4.1`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#041) [Compare Source](astral-sh/uv@0.4.0...0.4.1) ##### Enhancements - Add `uv export --format requirements-txt` ([#​6778](astral-sh/uv#6778)) - Allow `@` references in `uv tool install --from` ([#​6842](astral-sh/uv#6842)) - Normalize version specifiers by sorting ([#​6333](astral-sh/uv#6333)) - Respect the user's upper-bound in `requires-python` ([#​6824](astral-sh/uv#6824)) - Use Windows registry to discover Python on Windows directly ([#​6761](astral-sh/uv#6761)) - Hint at `--no-workspace` in `uv init` failures ([#​6815](astral-sh/uv#6815)) - Update to last PyPy releases ([#​6784](astral-sh/uv#6784)) ##### Bug fixes - Avoid deadlocks when multiple uv processes lock resources ([#​6790](astral-sh/uv#6790)) - Expand tildes when matching against `PATH` ([#​6829](astral-sh/uv#6829)) - Fix `uv init --no-project` alias ([#​6837](astral-sh/uv#6837)) - Ignore pre-release segments when discovering via `requires-python` ([#​6813](astral-sh/uv#6813)) - Support inline optional tables in `uv add` and `uv remove` ([#​6787](astral-sh/uv#6787)) - Update default `hello.py` to pass `ruff format` ([#​6811](astral-sh/uv#6811)) - Avoid stripping root for user path display ([#​6865](astral-sh/uv#6865)) - Error when user-provided environments are disjoint with Python ([#​6841](astral-sh/uv#6841)) - Retain alphabetical sorting for `pyproject.toml` in `uv add` operations ([#​6388](astral-sh/uv#6388)))) ##### Documentation - Add a link to the multiple index docs in the alternative index guide ([#​6826](astral-sh/uv#6826)) - Add docs for inline exclude newer in PEP 723 scripts ([#​6831](astral-sh/uv#6831)) - Enumerate available Docker tags ([#​6768](astral-sh/uv#6768)) - Omit `[pip]` section from configuration file docs ([#​6814](astral-sh/uv#6814)) - Update `project.urls` in `pyproject.toml` ([#​6844](astral-sh/uv#6844)) - Add docs for AWS CodeArtifact usage ([#​6816](astral-sh/uv#6816)) ##### Other changes </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
Our current strategy of parsing the output of
py --list-paths
to get the installed python versions on windows is brittle (#6524, missingpy
, etc.) and it's slow (10ms last time i measured).Instead, we should behave spec-compliant and read the python versions from the registry following PEP 514.
It's not fully clear which errors we should ignore and which ones we need to raise.
We're using the official rust-for-windows crates for accessing the registry.
Fixes #1521
Fixes #6524