uv/crates/uv-python/src
konsti db4ab9dc8a
Install and remove managed Python to and from the Windows Registry (PEP 514) (#10634)
## Summary

In preview mode on windows, register und un-register the managed python build standalone installations in the Windows registry following PEP 514.

We write the values defined in the PEP plus the download URL and hash. We add an entry when installing a version, remove an entry when uninstalling and removing all values when uninstalling with `--all`. We update entries only by overwriting existing values, there is no "syncing" involved.

Since they are not official builds, pbs gets a prefix. `py -V:Astral/CPython3.13.1` works, `py -3.13` doesn't.

```
$ py --list-paths                                            
 -V:3.12 *        C:\Users\Konsti\AppData\Local\Programs\Python\Python312\python.exe
 -V:3.11.9        C:\Users\Konsti\.pyenv\pyenv-win\versions\3.11.9\python.exe
 -V:3.11          C:\Users\micro\AppData\Local\Programs\Python\Python311\python.exe
 -V:3.8           C:\Users\micro\AppData\Local\Programs\Python\Python38\python.exe
 -V:Astral/CPython3.13.1 C:\Users\Konsti\AppData\Roaming\uv\data\python\cpython-3.13.1-windows-x86_64-none\python.exe
```

Registry errors are reported but not fatal, except for operations on the company key since it's not bound to any specific python interpreter.

On uninstallation, we prune registry entries that have no matching Python installation (i.e. broken entries).

The code uses the official `windows_registry` crate of the `winreg` crate.

Best reviewed commit-by-commit.

## Test Plan

We're reusing an existing system check to test different (un)installation scenarios.
2025-01-23 14:13:41 +00:00
..
sysconfig Remove trailing commas before brackets (#10740) 2025-01-18 19:56:46 +00:00
cpuinfo.rs Fix hard and soft float libc detection for managed Python distributions on ARM (#8498) 2024-10-29 23:46:21 +00:00
discovery.rs Install and remove managed Python to and from the Windows Registry (PEP 514) (#10634) 2025-01-23 14:13:41 +00:00
downloads.inc Sync latest Python releases (#10637) 2025-01-15 12:55:31 -06:00
downloads.inc.mustache Allow download of Python distribution variants with newer CPU instruction sets (#9781) 2024-12-10 14:26:45 -06:00
downloads.rs Install and remove managed Python to and from the Windows Registry (PEP 514) (#10634) 2025-01-23 14:13:41 +00:00
environment.rs Remove unnecessary prefixes (#10158) 2024-12-25 14:18:01 -05:00
implementation.rs Prefer Python executable names that match the request over default names (#9066) 2024-11-13 10:00:23 -06:00
installation.rs Install and remove managed Python to and from the Windows Registry (PEP 514) (#10634) 2025-01-23 14:13:41 +00:00
interpreter.rs fix(#10717): Omit stdout and stderr sections when empty in errors (#10746) 2025-01-21 21:45:29 +00:00
lib.rs Install and remove managed Python to and from the Windows Registry (PEP 514) (#10634) 2025-01-23 14:13:41 +00:00
libc.rs Remove separate test files in favor of same-file mod tests (#9199) 2024-11-18 20:11:46 +00:00
macos_dylib.rs Install and remove managed Python to and from the Windows Registry (PEP 514) (#10634) 2025-01-23 14:13:41 +00:00
managed.rs Install and remove managed Python to and from the Windows Registry (PEP 514) (#10634) 2025-01-23 14:13:41 +00:00
microsoft_store.rs Install and remove managed Python to and from the Windows Registry (PEP 514) (#10634) 2025-01-23 14:13:41 +00:00
platform.rs Install and remove managed Python to and from the Windows Registry (PEP 514) (#10634) 2025-01-23 14:13:41 +00:00
pointer_size.rs Change "toolchain" to "python" (#4735) 2024-07-03 07:44:29 -05:00
prefix.rs Add uv- prefix to all internal crates (#7853) 2024-10-01 20:15:32 -04:00
python_version.rs Introduce a --fork-strategy preference mode (#9868) 2024-12-13 16:05:07 -05:00
target.rs Add uv- prefix to all internal crates (#7853) 2024-10-01 20:15:32 -04:00
version_files.rs Discover and respect .python-version files in parent directories (#6370) 2024-11-07 14:29:54 -06:00
virtualenv.rs Treat the base Conda environment as a system environment (#7691) 2024-11-07 14:29:54 -06:00
windows_registry.rs Install and remove managed Python to and from the Windows Registry (PEP 514) (#10634) 2025-01-23 14:13:41 +00:00