Skip to content

Commit 34b2d47

Browse files
authored
fix(winpython): narrow search paths and add discovery cache (#456)
Fixes #453. The WinPython locator was scanning `C:\`, `D:\`, `E:\`, `Program Files`, `~/Downloads`, `~/Desktop`, and `~/Documents` on every refresh — all Windows Defender hot-spots — to find a niche portable distribution. That inflated p90 refresh latency for every Windows user, regardless of whether WinPython was installed. ## Changes - Restrict default search to `%USERPROFILE%\WinPython`. - Add opt-in `WINPYTHON_HOME` env var (single path or `;`-separated list; each entry can *be* or *contain* a WinPython install). - Add a per-process discovery cache (`Arc<Mutex<Option<Arc<Vec<...>>>>>`), mirroring `WindowsStore` and `WindowsRegistry`, with `SyncedDiscoveryState` refresh persistence. - Extract `build_search_paths(userprofile, winpython_home)` as a pure helper so tests don't have to mutate process env. - New regression tests pinning the search-path policy and `WINPYTHON_HOME` parsing on both Windows and Unix. - README: document `WINPYTHON_HOME` and the new search-path policy. `try_from()` behavior on a real WinPython executable is unchanged — it still walks parent directories looking for marker files / `WPy*` directory names.
1 parent ab6d1d2 commit 34b2d47

4 files changed

Lines changed: 642 additions & 122 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ tmp/
1818
temp/
1919
docs/node_modules/
2020
docs/package.json
21-
docs/package-lock.json
21+
docs/package-lock.jsonpr-status.json

crates/pet-winpython/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,26 @@ WPy64-31300/ # Top-level WinPython directory
3030
## Platform Support
3131

3232
This locator only works on Windows, as WinPython is a Windows-only distribution.
33+
34+
## Search Paths
35+
36+
By default, the locator only looks for WinPython installations under
37+
`%USERPROFILE%\WinPython`. Earlier versions also scanned drive roots
38+
(`C:\`, `D:\`, `E:\`), `Program Files`, `Downloads`, `Desktop`, and
39+
`Documents` on every refresh — those scans were a Windows Defender
40+
hot-spot and inflated refresh latency, so they have been removed.
41+
42+
If your WinPython installation lives elsewhere, point the locator at it
43+
with the `WINPYTHON_HOME` environment variable. The value can be a
44+
single path or a `;`-separated list of paths. Each entry can either:
45+
46+
- _be_ a WinPython installation (e.g. `D:\WPy64-31300`), or
47+
- _contain_ one or more WinPython installations (e.g. `D:\python-tools`
48+
with `D:\python-tools\WPy64-31300` inside).
49+
50+
Examples:
51+
52+
```
53+
set WINPYTHON_HOME=D:\WPy64-31300
54+
set WINPYTHON_HOME=D:\WPy64-31300;E:\portable-python
55+
```

0 commit comments

Comments
 (0)