Windows: daemon via the #4466 base-interpreter trampoline skips venv .pth — import pywintypes fails on uv-managed venvs
Summary
On Windows with a uv-managed venv, a daemon launched through the #4466 base-interpreter trampoline can't import pywintypes because the venv's site-packages .pth files are never processed.
Environment
- Windows 10, uv-managed venv (
pyvenv.cfgcarriesuv =) hindsight_embeddriving the local-embedded daemon
What happens
DaemonEmbedManager._windows_gui_interpreter()findsvenv/Scripts/pythonw.exe.- That
pythonw.exeis a uv trampoline (uv doesn't put a real interpreter in the venv Scripts dir — it CreateProcess's the base interpreter recorded inpyvenv.cfg). - Per the
#4466fix, the code bypasses the trampoline and launches the basepythonw.exewithPYTHONPATH=<venv>/Lib/site-packages. - A base interpreter given site-packages via
PYTHONPATHdoes not process that directory's.pthfiles. Sopywin32.pth(which addspywin32_system32viaos.add_dll_directory/sys.path) is never applied. - The daemon then fails on
import pywintypes(e.g. throughmcp/os/win32), aborting startup.
Observed
Daemon dead on start with ModuleNotFoundError/DLL-load failure for pywintypes; pywin32_system32 absent from the DLL search path.
Workaround (current)
A sitecustomize.py in the venv's site-packages that replicates pywin32.pth (adds win32, win32/lib, Pythonwin, pywin32_system32 to sys.path and os.add_dll_directory(...) for pywin32_system32). Base python auto-imports sitecustomize found via PYTHONPATH, so this works — but it's a per-venv manual patch that's lost on every venv rebuild.
Suggested fix
When the #4466 trampoline path hands the base interpreter the venv's site-packages via PYTHONPATH, also honor that directory's .pth entries for the child (e.g. ship a small .pth-replicating bootstrap the child can import), so pywin32_system32 lands on the DLL search path without a manual sitecustomize.py.
Source: vectorize-io/hindsight