Skip to content

build(windows): embed PE version info in PyInstaller executables - #1559

Open
TimeToBuildBob wants to merge 4 commits into
ActivityWatch:masterfrom
TimeToBuildBob:feat/windows-exe-version-info
Open

TimeToBuildBob wants to merge 4 commits into
ActivityWatch:masterfrom
TimeToBuildBob:feat/windows-exe-version-info

Conversation

@TimeToBuildBob

@TimeToBuildBob TimeToBuildBob commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Prerequisite for signing Windows releases through SignPath Foundation (#632), made more urgent by the Smart App Control block in #1558.

Windows make package builds the subprojects with their own PyInstaller specs and copies them into dist/activitywatch; the root aw.spec is used only for the macOS app. This PR now stamps the assembled Windows Python executables in scripts/package/package-all.sh, before creating either the zip or Inno Setup installer. It does not change the subproject builds or macOS/Linux packaging.

  • Adds ProductName ActivityWatch, CompanyName ActivityWatch Contributors, and module-specific FileDescription/InternalName/OriginalFilename.
  • Uses the same version string as the archive/installer (getversion.sh), retaining beta/RC/dev suffixes in string fields. Numeric PE fields use the leading dotted components, padded to four integers (0.14.0b5 → 0.14.0.0).
  • Uses PyInstaller's version-resource writer, which preserves the appended executable archive, then reads the resource back and fails packaging if it does not match.
  • Targets only aw-qt, aw-server, and the Python AFK/window/input watchers. Cargo/Tauri binaries and third-party helpers are untouched. aw-notify is now Rust, so it is excluded too.

Verification:

  • Local packaging tests: 29 passed, 2 Windows-only tests skipped; Ruff and bash -n pass.
  • Regression coverage executes the packaging script with archive/resource stubs and checks that stamping happens before archiving, with the installer/archive version. Linux never invokes the stamp step.
  • The existing packaging test workflow now also runs on Windows, exercising a real PE resource write/read roundtrip and checking that appended overlay bytes survive. Native Windows CI and release artifact verification remain pending; local Linux tests do not prove the PE resource was written.

Not included: Cargo executable resources, Authenticode signing, certificate/application setup, or a claim that Smart App Control is resolved.

Gives every bundled exe a ProductName/ProductVersion/FileVersion resource
derived from the release tag. Code-signing services (SignPath Foundation)
require consistent product metadata; see ActivityWatch#632 / ActivityWatch#1558.

No-op on Linux/macOS: PyInstaller's versioninfo module only imports on Windows.

Git-Session-Id: ee739f7c-b2fa-4f0d-b3a5-15e7b341e7df
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

Review guide (auto-posted)

Structured warm-up for reviewers — what changed, what to run, where to look.

Key files

  • aw.spec (+50/-0, Δ50)

Suggested verification

  • Run the repo's usual CI-equivalent checks locally

Known risks / watch points

  • No automatic high-risk tags; use file list + diff for judgment.

Suggested review focus

  • Confirm behavior matches the PR description acceptance criteria.
  • Skim the largest diffs first (listed above).
  • If CI is green, spot-check the highest-risk paths called out here.

Generated by scripts/github/pr-warmup-review-guide.py for #1559.

@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new blocking issues were found.

Summary

Windows packaging now adds and checks version information on the bundled Python executables before creating the zip or installer.

  • Windows packages now include version details in ActivityWatch's Python executables.

Reviews (5) · Last reviewed commit: "fix(windows): use venv Python for the ar..." · Reviewed by Greptile

Comment thread aw.spec Resolved
Git-Session-Id: c91cae29-4f6a-510a-8986-b41d7f75441b
@TimeToBuildBob

This comment has been minimized.

@TimeToBuildBob

TimeToBuildBob commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 AI code review

Adds a new script scripts/package/windows-version-info.py that stamps PE version resources onto the bundled Python executables (aw-qt, aw-server, and the Python watchers) before Windows zip/Inno Setup creation. Updates package-all.sh to invoke this script on Windows using python instead of python3, and adds Windows to the packaging-arch-tests CI matrix with a venv-based PyInstaller install. Expands the packaging tests to stub the new stamping step and adds unit/PE roundtrip tests for the new script.

Safe to merge — no P0/P1 findings

Confidence 5/5

✅ No findings. The diff looks correct to me on this pass.

Files changed (5) — the diff as I read it
  • .github/workflows/packaging-arch-tests.yml — Adds a Windows matrix entry, installs pytest/pyinstaller into a venv on Windows, and runs only the version-info tests on Windows while running all three test files on Linux.
  • scripts/package/package-all.sh — Adds a Windows-only invocation of windows-version-info.py before build_zip and changes the assert-windows-pe-arch.py call from python3 to python.
  • scripts/package/windows-version-info.py — New script that parses a numeric version, locates targeted Python .exe files recursively, writes PE version resources via PyInstaller, and verifies the write by roundtrip comparison.
  • scripts/tests/test_get_arch.py — Adds a python/python3 interpreter stub set, a windows-version-info.py stub, and assertions that the stamp step runs only on Windows with expected arguments before archiving.
  • scripts/tests/test_windows_version_info.py — New test module covering numeric_version parsing, executable targeting, the package-all.sh invocation ordering, and a real PE resource write/read roundtrip on Windows.
Previous review passes
commit score findings engine when
a8bfbb7c75a1 5/5 0 subscription 2026-11-14 17:02 UTC
45727d04991e 3/5 5 llm 2026-11-17 03:22 UTC

Reviewed 81f975270a42 · openrouter/deepseek/deepseek-v4-flash-0731 · llm engine · 81s · about this reviewer

Maintainer commands

@TimeToBuildBob review (own line) — fresh review · @TimeToBuildBob fix — a worker acts on the findings. Once per comment; 👀 = received.

Comment thread scripts/package/package-all.sh Resolved
Git-Session-Id: 643fbc0c-eccc-54f8-89a0-1e3caf0a9393
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

@greptileai review

Comment thread scripts/package/package-all.sh Resolved
Comment thread scripts/package/windows-version-info.py Resolved
Comment thread scripts/tests/test_get_arch.py Resolved
Git-Session-Id: 3b0ad55c-84e1-59bf-af04-b43356c9ccb2
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

Review-findings adjudication

Recommendation: the reported findings are disposed; leave merge to the maintainer after current-head CI and automatic review complete. No manual Greptile re-review requested, and no merge performed.

Fixed

  • Blocking packaging bug (d475ce3ec89b): pushed 81f9752. The post-archive PE architecture check now uses the activated venv's python, matching the stamping step. The regression now makes every python3 invocation exit 127: it failed on the reviewed head after zip creation, then passed with this fix.
  • Resolved the two older Greptile threads, which already had inline fix replies: metadata is stamped in the actual Windows packaging path, and stamping uses the venv interpreter. Their latest summary explicitly confirms both previous findings are addressed.

Remaining — non-blocking dispositions

Each finding has one inline explanation and is resolved:

  • Case-sensitive entrypoint selection (f96b32aca699), accepted input-contract limitation: all five specs at this PR's pinned submodule revisions explicitly emit the lowercase names in the allowlist. The proposed uppercase output is not produced by the current release build; a future spec-name change must update its packaging contract.
  • Source-text ordering check (35933c330adb), false positive: matching the call is intentional; removing/renaming it fails the assertion. The executed packaging regression independently asserts no zip exists at stamping and that the zip exists at the architecture check.
  • Missing pefile install (6f75beb8044c), false positive: the actual Windows CI log installs pefile>=2022.5.30 as a PyInstaller dependency. The real resource/overlay test imports it successfully. See Windows packaging tests, 13 passed.
  • Stub/empty-bundle coverage (7e5b8e446506), false positive: the stub explicitly rejects stamping after archive creation. Real empty-bundle failure and PE resource write/read/overlay behavior have separate Windows CLI tests, both included in that passing job.

The summary-only numeric-version-prefix and exact-resource-roundtrip advisories remain non-blocking: leading numeric components are the documented contract for prerelease/dev strings, and the real Windows roundtrip passed. No unsupported parser generalization or speculative serializer workaround added.

Verified against

  • Initial freshness gate passed: both the newest bob-ai-review marker and Greptile's “Last reviewed commit” covered 45727d0.
  • All classifications were checked against that reviewed head and the local fix 81f9752, which is now verified on the PR's fork branch. The fix head is newer than those review passes; this is not a claim of fresh independent review on the new head. The automatic review sweep handles that.
  • Local fix-head tests: 29 passed, 2 Windows-only skipped. Ruff check/format, bash -n, and diff whitespace checks pass.

CI

At the post-push snapshot, Ubuntu packaging tests and Research Edition packaging smoke tests pass; Windows packaging tests, CodeQL analysis and release builds are still pending. The preceding reviewed head passed all 13 native Windows resource tests; that result does not substitute for new-head CI.

Domain risk

Before release, inspect version properties and launch the actual stamped Windows bundle/installer (including Python watchers). The Windows resource roundtrip covers a copied interpreter with overlay bytes, not a complete frozen release app or Authenticode signing. This PR does not claim to resolve Smart App Control or complete signing.

Convergence

Detector reports no unresolved Greptile P1/P2 findings; our reviewer also reports zero open finding threads. Its historical round_convergence.stable_rounds is 0 (required: 2; historical status: new_blocking). Resolving already-addressed findings does not manufacture stable review rounds, and I have not requested another round to chase that counter.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant