Repository navigation
Conversation
Author
|
Closing as a duplicate: same fix as #122768, #123149, #123550 and #122805 for issue #122183. Leaving it to the existing PRs to avoid adding noise. (Unique evidence kept: cp311 pywin32 in the pre-PM in-tree venv fails to load under the 3.14 store Python -> ImportError: DLL load failed while importing _win32sysloader.) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes the Windows gateway bootstrap so it loads Python dependencies from PM's committed environment instead of the hardcoded pre-PM in-tree
venv/.gateway/run.py::_ensure_windows_gateway_venv_imports()always appendedproject_root / "venv"to its candidate list before asking PM. On a migrated (PM-managed) install that in-tree tree is the pre-migration venv — built by whichever interpreter created it — so it was prepended ahead of the committed generation and its compiled modules shadowed the correct ones.Related Issue
Behavioural regression on PM-migrated Windows installs (no issue filed; described below).
Observed before the fix
ModuleNotFoundError: No module named 'pydantic_core._pydantic_core'importing from the pre-PM tree, surfacing as:gateway.run: Supervised task hosted_room_worker died 5 times in rapid succession (each within 300s of restart) - giving up restartsImportError: DLL load failed while importing _win32sysloader.PYTHONPATH/VIRTUAL_ENVpointed at<repo>/venv(a 3.11 tree) even though the process runs the 3.14 store Python with a committed 3.14 generation available.Root cause: the helper
returns after the first candidate whoseLib/site-packagesexists, and that candidate was the hardcoded<repo>/venv.Type of Change
Changes Made
gateway/run.py:_ensure_windows_gateway_venv_imports()now resolves the committed generation viapm.environments.committed_venv(project_root)and uses it as the candidate. It falls back to the in-treevenv/only when PM has no committed generation (legacy installs), preserving existing behaviour for pre-PM trees. Failure to import PM degrades to the old path.tests/gateway/test_windows_gateway_venv_imports.py:@pytest.mark.platforms("windows")regression test asserting the committed venv becomesVIRTUAL_ENV, reachessys.path, hasaddsitedirsemantics applied (a.pthentry is processed — pywin32 needs this), and is advertised inPYTHONPATH.The test is red on the previous code (it selects
<repo>/venv) and green with the fix.How to Test
scripts/run_tests.sh tests/gateway/test_windows_gateway_venv_imports.py.VIRTUAL_ENVends up as<repo>/venvinstead of the injected committed generation.PYTHONPATH/VIRTUAL_ENVpoint at the PM generation, and thatgateway.logno longer showshosted_room_workerdying with apydantic_core._pydantic_coreModuleNotFoundError.pywintypesthen resolves to the PM environment'spywin32_system32\pywintypes314.dll.Checklist
Code
fix(scope):,feat(scope):, etc.)scripts/run_tests.sh, not bare pytest) for the affected file, plusruff checkandpython scripts/check-windows-footguns.py --allDocumentation & Housekeeping
docs/, docstrings) - or N/A (code comment added explaining the PM preference)cli-config.yaml.exampleif I added/changed config keys - or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows - or N/Asys.platform == "win32"early-return helper, so non-Windows behaviour is untouchedScreenshots / Logs
Live verification on the affected Windows host (PID values redacted):
PYTHONPATH = <repo> ; <pm>\Lib\site-packages ; <repo> ; <pm>\Lib\site-packages(PM env only — the pre-PM tree is gone),VIRTUAL_ENV = <pm>.import pywintypes→<pm>\Lib\site-packages\pywin32_system32\pywintypes314.dllimport pydantic_core._pydantic_core→<pm>\Lib\site-packages\pydantic_core\_pydantic_core.cp314-win_amd64.pydgateway.log: lastERRORpredates the fix; zeroERRORlines after the restart.GET /health→200 {"status":"ok","platform":"hermes-agent","version":"0.21.5"}