Use windows registry to discover python (#6761)

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.

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
This commit is contained in:
konsti 2024-08-29 22:48:22 +02:00 committed by GitHub
parent 57cb9c2957
commit a39eb61ade
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 156 additions and 124 deletions

View file

@ -29,6 +29,7 @@ pub mod managed;
pub mod platform;
mod pointer_size;
mod prefix;
#[cfg(windows)]
mod py_launcher;
mod python_version;
mod target;
@ -60,9 +61,6 @@ pub enum Error {
#[error(transparent)]
Discovery(#[from] discovery::Error),
#[error(transparent)]
PyLauncher(#[from] py_launcher::Error),
#[error(transparent)]
ManagedPython(#[from] managed::Error),