Skip to content

fix: let packaged Windows miner run headless without Tk - #5463

Merged
Scottcjn merged 1 commit into
Scottcjn:mainfrom
galanime:codex/windows-miner-lazy-tkinter
May 18, 2026
Merged

Scottcjn merged 1 commit into
Scottcjn:mainfrom
galanime:codex/windows-miner-lazy-tkinter

Conversation

@galanime

Copy link
Copy Markdown
Contributor

Summary

  • make the packaged Windows miner tolerate missing tkinter at startup
  • add --headless, --node, and --wallet parsing to the packaged miner entry point
  • add a regression test that blocks tkinter imports and verifies --help still reaches argparse

Fixes #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 --help and run the console/headless path instead of failing before argparse.

Validation

  • python -m pytest -q tests\test_windows_installer_tkinter_fallback.py -> 1 passed
  • python -m pytest -q tests\test_windows_installer_tkinter_fallback.py tests\test_windows_miner_setup_checksum.py -> 3 passed
  • python -m py_compile miners\windows\installer\src\rustchain_windows_miner.py tests\test_windows_installer_tkinter_fallback.py -> passed
  • python miners\windows\installer\src\rustchain_windows_miner.py --help -> shows --headless, --node, and --wallet
  • git diff --check -> passed
  • python tools\bcos_spdx_check.py --base-ref origin/main -> BCOS SPDX check: OK

RTC wallet: RTC74b80ab40602e5ae31819912b2fca974484e5dab

@github-actions github-actions Bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) tests Test suite changes size/M PR: 51-200 lines labels May 16, 2026

@HCIE2054 HCIE2054 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kekehanshujun kekehanshujun left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py
  • python -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.

@HCIE2054 HCIE2054 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@HCIE2054 HCIE2054 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@HCIE2054 HCIE2054 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@HCIE2054 HCIE2054 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ZacharyZhang-NY ZacharyZhang-NY left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed PR #5463 at head 5baae88.

Validation performed:

  • Checked issue #5399. The scoped bug is the packaged Windows miner crashing at import time when tkinter is 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 jaxint left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for contributing. Approved.

@HCIE2054 HCIE2054 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@TJCurnutte TJCurnutte left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py passed.
  • python3 -B -m py_compile miners/windows/installer/src/rustchain_windows_miner.py tests/test_windows_installer_tkinter_fallback.py passed.
  • PYTHONPATH=. uv run --no-project --with pytest --with requests python -B -m pytest -q tests/test_windows_installer_tkinter_fallback.py --noconftest passed with 1 passed in 1.74s.
  • python3 miners/windows/installer/src/rustchain_windows_miner.py --help exited through argparse and showed --headless, --node, and --wallet.
  • A direct import-block probe that raised ModuleNotFoundError("No module named 'tkinter'") for tkinter imports then ran the script with --help; it exited 0 and 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.

@HCIE2054 HCIE2054 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@HCIE2054 HCIE2054 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@HCIE2054 HCIE2054 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@HCIE2054 HCIE2054 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@HCIE2054 HCIE2054 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@HCIE2054 HCIE2054 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@HCIE2054 HCIE2054 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@HCIE2054 HCIE2054 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jaxint jaxint left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Great work on this PR. 🚀

@Scottcjn
Scottcjn merged commit fcdfabf into Scottcjn:main May 18, 2026
12 of 13 checks passed
@Scottcjn

Copy link
Copy Markdown
Owner

Payment: 25 RTC (Medium tier, audit batch 4)

Audit summary: Windows miner Tk fallback + headless flag parsing.

Dispatched to wallet RTC74b80ab40602e5ae31819912b2fca974484e5dab as part of a combined 60 RTC transfer (pending_id 1591, tx 9ad7d63e529bd2a493e81a7d780f7454) covering all three of your batch 4 merged PRs. Confirms in ~24 hours.

— Codex gpt-5.4 xhigh audit, Sophia/Claude synthesis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) size/M PR: 51-200 lines tests Test suite changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows miner release exe crashes before headless fallback when tkinter is missing

7 participants