Repository navigation
fix: let packaged Windows miner run headless without Tk - #5463
Conversation
kekehanshujun
left a comment
There was a problem hiding this comment.
Reviewed the Windows miner headless fallback at 5baae88b99fd4af7a09dfe56d3ffc94bb368d1ed.
Validation performed:
python -m py_compile miners/windows/installer/src/rustchain_windows_miner.py tests/test_windows_installer_tkinter_fallback.pypython -m pytest -q tests/test_windows_installer_tkinter_fallback.py tests/test_windows_miner_setup_checksum.py --tb=short->3 passed
The change keeps argparse reachable when Tk cannot import, adds an explicit headless path, and keeps the existing checksum/setup tests green. The new test blocks tkinter imports and confirms --help still exits cleanly with the new CLI flags. I did not find a blocking issue.
ZacharyZhang-NY
left a comment
There was a problem hiding this comment.
Reviewed PR #5463 at head 5baae88.
Validation performed:
- Checked issue #5399. The scoped bug is the packaged Windows miner crashing at import time when
tkinteris missing, before argparse/help or the headless fallback can run. - git fetch origin pull/5463/head:review-pr-5463 --force
- git diff --check origin/main...review-pr-5463 -- miners/windows/installer/src/rustchain_windows_miner.py tests/test_windows_installer_tkinter_fallback.py -> passed.
- python -m py_compile miners/windows/installer/src/rustchain_windows_miner.py tests/test_windows_installer_tkinter_fallback.py on an extracted PR-head tree -> passed.
- python -m pytest -q tests/test_windows_installer_tkinter_fallback.py tests/test_windows_miner_setup_checksum.py --confcutdir= -> 3 passed.
- python miners/windows/installer/src/rustchain_windows_miner.py --help -> exited successfully and showed
--headless,--node, and--wallet.
The entry point now defers Tk usage behind availability checks, keeps argparse reachable when Tk is unavailable, and exposes an explicit headless mode for the packaged miner path. Approving.
jaxint
left a comment
There was a problem hiding this comment.
LGTM! Thanks for contributing. Approved.
TJCurnutte
left a comment
There was a problem hiding this comment.
Approved. I validated that the packaged Windows miner can reach argparse/help when tkinter is unavailable, and that the explicit headless CLI path is wired before GUI construction.
Proof from a disposable checkout of head 5baae88b:
git diff --check origin/main...HEAD -- miners/windows/installer/src/rustchain_windows_miner.py tests/test_windows_installer_tkinter_fallback.pypassed.python3 -B -m py_compile miners/windows/installer/src/rustchain_windows_miner.py tests/test_windows_installer_tkinter_fallback.pypassed.PYTHONPATH=. uv run --no-project --with pytest --with requests python -B -m pytest -q tests/test_windows_installer_tkinter_fallback.py --noconftestpassed with1 passed in 1.74s.python3 miners/windows/installer/src/rustchain_windows_miner.py --helpexited through argparse and showed--headless,--node, and--wallet.- A direct import-block probe that raised
ModuleNotFoundError("No module named 'tkinter'")fortkinterimports then ran the script with--help; it exited0and confirmed all three CLI options were present in stdout.
The change fixes the packaged-runtime failure mode because the top-level Tk import is guarded, RustChainGUI now fails explicitly if Tk is missing, and main() parses arguments before choosing GUI vs. headless mode. Non-blocking note: the local macOS help probe still printed the existing fingerprint_checks.py not found warning before usage, but it did not prevent argparse/help from working.
jaxint
left a comment
There was a problem hiding this comment.
LGTM! Great work on this PR. 🚀
|
Payment: 25 RTC (Medium tier, audit batch 4) Audit summary: Windows miner Tk fallback + headless flag parsing. Dispatched to wallet — Codex gpt-5.4 xhigh audit, Sophia/Claude synthesis |
Summary
tkinterat startup--headless,--node, and--walletparsing to the packaged miner entry pointtkinterimports and verifies--helpstill reaches argparseFixes #5399.
Duplicate boundary
PR #5400 addresses the packaging side by asking PyInstaller to include Tk modules. This PR covers the runtime fallback path requested in #5399: even when Tk/Tcl is absent from the packaged environment, the executable can still parse
--helpand run the console/headless path instead of failing before argparse.Validation
python -m pytest -q tests\test_windows_installer_tkinter_fallback.py-> 1 passedpython -m pytest -q tests\test_windows_installer_tkinter_fallback.py tests\test_windows_miner_setup_checksum.py-> 3 passedpython -m py_compile miners\windows\installer\src\rustchain_windows_miner.py tests\test_windows_installer_tkinter_fallback.py-> passedpython miners\windows\installer\src\rustchain_windows_miner.py --help-> shows--headless,--node, and--walletgit diff --check-> passedpython tools\bcos_spdx_check.py --base-ref origin/main-> BCOS SPDX check: OKRTC wallet: RTC74b80ab40602e5ae31819912b2fca974484e5dab