Make scripts/run_demo.py and scripts/check.py run on Windows - #2
Open
FormosaMCN wants to merge 2 commits into
Open
Make scripts/run_demo.py and scripts/check.py run on Windows#2FormosaMCN wants to merge 2 commits into
FormosaMCN wants to merge 2 commits into
Conversation
run_demo.py assumed a POSIX host and failed before any web app started. - `node_modules/.bin/next` is a shell shim on Windows, not something CreateProcess can execute; starting the storefront raised OSError: [WinError 193]. Point NEXT at `next.cmd` there, and use `npm.cmd` for the first-run workspace install for the same reason. - Shutdown called os.killpg/os.getpgid, which do not exist on Windows, so the failure above surfaced as AttributeError from the finally block and left the API process orphaned on its port. Route termination through a `terminate()` helper that uses `taskkill /T /F` on Windows and keeps the existing SIGTERM-then-SIGKILL process-group path elsewhere. Verified on Windows 11: `python scripts/run_demo.py retail --all` now boots the API (:8000), storefront (:3000), and merchant portal (:3100), and Ctrl-C takes the whole tree down. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Follow-ups found by running all four verticals on a cp950 console. - run_demo.py: main() defines a local `terminate(signum, frame)` signal handler, which shadowed the module-level helper added in the previous commit, including in main()'s own finally block. Shutdown therefore raised `TypeError: terminate() missing 1 required positional argument: 'frame'` and left child servers holding their ports. Rename the helper to `stop_process`. - run_demo.py and check.py both print check marks. On a Windows console in a non-UTF-8 code page these die with UnicodeEncodeError: the log relay threads and the "demo is up" line in run_demo.py, and the first ok() in check.py. Reconfigure stdout to UTF-8 in both. Verified on Windows 11 (cp950): all four verticals boot with `run_demo.py <vertical> --all`, `stop_process` takes down a spawned process tree, and `scripts/check.py` reports clean with no environment overrides. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
stop_process(..., force=False) still passes /F to taskkill, so the first Windows shutdown pass is already a forced kill. The 10-second wait and later force=True escalation therefore have no effect, unlike the POSIX SIGTERM→SIGKILL flow. Could /F be added only when force is true, with a graceful-first shutdown regression?
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.
scripts/run_demo.pyassumes a POSIX host and fails before any web app starts, so the demos cannot be run on Windows at all.scripts/check.pyfails on the first result line for an unrelated reason on the same platform.What was broken
node_modules/.bin/nextis a shell shim on Windows, not somethingCreateProcesscan execute. Starting the storefront raisedOSError: [WinError 193] %1 is not a valid Win32 application.os.killpg/os.getpgid, which do not exist on Windows, so the failure above surfaced as anAttributeErrorfrom thefinallyblock and left uvicorn orphaned on its port.run_demo.py's log-relay threads and its "demo is up" line, andcheck.py's firstok(), all die withUnicodeEncodeError.What changed
NEXTatnext.cmdon Windows, and usenpm.cmdfor the first-run workspace install for the same reason.stop_process()helper:taskkill /T /Fon Windows, and the existing SIGTERM-then-SIGKILL process-group path everywhere else.No behaviour change on POSIX.
Note on the second commit
The helper was originally named
terminate(). That was wrong:main()already defines a localterminate(signum, frame)signal handler, which shadowed it throughoutmain()'s body — including thefinallyblock that calls it. Shutdown raisedTypeError: terminate() missing 1 required positional argument: 'frame'and left the child servers running. The second commit renames it and adds the encoding fixes; both are worth reading together.Verification
On Windows 11, Python 3.11, Node 24, cp950 console:
python scripts/run_demo.py <vertical> --all— API, storefront, and merchant portal each answer, and the✓ ... demo is upbanner renders.stop_process()takes down a spawned process tree (checked directly against a live child).ruff check .andruff format --check .pass;scripts/check.pyreports clean with no environment overrides.pytest: 1103 passed, 1 skipped, 1 failed — see below.Notes for a reviewer
Two Windows findings are not addressed here, because neither is a bug in these scripts:
commerce-common/tests/test_memory_stores.py::test_the_file_store_is_owner_only_and_keeps_purge_generations_across_instancesfails on Windows: it asserts mode0o600and gets0o666. NTFS has no POSIX mode bits, soos.chmodcannot express owner-only there. That is a real gap for a Windows deployment, not just a test artifact, and it probably deserves either a skip with a reason or a note indocs/safety.md.tzdatais not inrequirements.txt. Windows ships no system IANA database, so without it four timezone tests fail withunknown IANA timezone: 'Europe/Lisbon'. Atzdata; sys_platform == "win32"marker would cover it.🤖 Generated with Claude Code