uv/scripts
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
..
benchmark Upgrade to the latest Ruff version (#10433) 2025-01-09 10:47:25 -05:00
links Add test coverage for build tag prioritization (#9680) 2024-12-06 09:32:19 -05:00
packages Build backend: Add integration test for scripts (#9635) 2024-12-04 10:57:08 +00:00
popular_packages Upgrade to the latest Ruff version (#10433) 2025-01-09 10:47:25 -05:00
publish Use script locking for publish test script (#10611) 2025-01-14 21:10:35 +01:00
requirements Add second apache airflow test case (#10463) 2025-01-10 15:42:03 +01:00
scenarios Filter wheels from lockfile based on architecture (#10584) 2025-01-14 14:39:21 +00:00
workspaces Skip files when detecting workspace members (#5735) 2024-08-02 19:44:43 +00:00
check_cache_compat.py Set absolute URLs prior to uploading to PyPI (#5038) 2024-07-13 17:29:21 +00:00
check_embedded_python.py Set absolute URLs prior to uploading to PyPI (#5038) 2024-07-13 17:29:21 +00:00
check_registry.py Install and remove managed Python to and from the Windows Registry (PEP 514) (#10634) 2025-01-23 14:13:41 +00:00
check_system_python.py Allow explicitly requesting an system interpreter version in check_system_python (#7306) 2024-09-11 19:41:42 +00:00
create-python-mirror.py Add additional version filter to mirror script. (#10055) 2024-12-20 12:50:59 -06:00
release.sh Remove the preview changelog (#6259) 2024-08-20 16:47:46 +00:00
sync_scenarios.sh Update packse to 0.3.42 for backtracking test (#10009) 2024-12-18 19:53:34 +00:00
transform_readme.py Fix benchmark image in documentation (#5102) 2024-07-16 13:54:06 +00:00
update_schemastore.py Update SchemaStore script (#5024) 2024-07-12 17:49:38 -04:00
uv-run-remote-script-test.py Pin rich==13.7.1 for --exclude-newer in tests (#7713) 2024-09-26 11:54:50 -04:00