tools: hash files without hashlib.file_digest so the checks run on Python 3.10 #366

Merged
snoozedDev merged 1 commit from upstream-pr/366 into main 2026-11-28 11:10:24 +00:00
snoozedDev commented 2026-11-28 04:03:19 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by snoozedDev on 2026-11-28T04:03:19Z.


Summary

CONTRIBUTING asks for Python 3.10 or newer, but tools/check_d3d12_regressions.py and tools/check_frame_profile.py call hashlib.file_digest, which was added in Python 3.11. On 3.10 the D3D12 regression controls build everything and then stop with AttributeError: module 'hashlib' has no attribute 'file_digest'. The Python suite fails the same way: 2 errors in test_d3d12_regressions. CI runs only 3.12, so it never sees this.

  • check_d3d12_regressions.py now uses project_tuxbox.inspect.digest, the streamed SHA-256 helper the launcher already uses in nine modules. Its local sha() is removed.
  • check_frame_profile.py does not import the launcher package, so it streams into hashlib.sha256 itself.
  • The hashes don't change. On a 5 MB random file, digest, hashlib.file_digest and sha256sum agree.
  • A new test, tests/test_frame_profile.py, checks that check_frame_profile.inspect refuses an executable whose hash doesn't match. On 3.10 without this change it fails with the same AttributeError.
  • The CI Python job runs as a matrix on 3.10 and 3.12 with fail-fast: false. The Rust job is unchanged. CONTRIBUTING now says CI uses both versions.

tools/reference/xg-proxy/prepare.py has the same call. I left it alone because tools/reference/ is part of the audit in #359.

Tested

Run the checks relevant to this change.

  • The checks relevant to this change passed: check --no-gpu and the Python suite on 3.10 and 3.12. The D3D12 regression controls were not run: this machine doesn't have the Windows dxcompiler.dll/dxil.dll they need. The only change in that tool is the function that computes the artifact fingerprints. The control logic is the same.
  • Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below: nothing runs differently in the guest. This change is to the check tooling and CI.
  • Where the table calls for AMD and NVIDIA, they passed on both. Otherwise, say which vendor still needs to run them: both, AMD and NVIDIA. A run of the D3D12 controls on any card would exercise the changed fingerprint path.

GPU, driver and backend: none used.

Commands run and their results:

python -m unittest discover -s tests -q
  main (e5c17a4), Python 3.10.21:  Ran 521 tests  FAILED (errors=2, skipped=29)
  this branch,    Python 3.10.21:  Ran 522 tests  OK (skipped=29)
  this branch,    Python 3.12.13:  Ran 522 tests  OK (skipped=29)

python tuxbox.py check --no-gpu   (Python 3.10.21 and 3.12.13, Rust 1.95.0)
  passed   Build the shader compiler
  passed   Python tests
  passed   Shader compiler tests
  passed   DXBC tests
  passed   XG layout tests
  passed   Storage codec tests
  passed   D3D12 Windows typecheck

Checks

No evidence JSON changed.

AI use: This contribution was written by an AI agent (Claude Opus 5.5) operating under my supervision. I am accountable for it and will respond to review.

<!-- greyfinch-sync:brcly/TuxBox:issue:5536483361 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/366). Originally posted by [snoozedDev](https://github.com/snoozedDev) on 2026-11-28T04:03:19Z. --- ## Summary CONTRIBUTING asks for Python 3.10 or newer, but `tools/check_d3d12_regressions.py` and `tools/check_frame_profile.py` call `hashlib.file_digest`, which was added in Python 3.11. On 3.10 the D3D12 regression controls build everything and then stop with `AttributeError: module 'hashlib' has no attribute 'file_digest'`. The Python suite fails the same way: 2 errors in `test_d3d12_regressions`. CI runs only 3.12, so it never sees this. - `check_d3d12_regressions.py` now uses `project_tuxbox.inspect.digest`, the streamed SHA-256 helper the launcher already uses in nine modules. Its local `sha()` is removed. - `check_frame_profile.py` does not import the launcher package, so it streams into `hashlib.sha256` itself. - The hashes don't change. On a 5 MB random file, `digest`, `hashlib.file_digest` and `sha256sum` agree. - A new test, `tests/test_frame_profile.py`, checks that `check_frame_profile.inspect` refuses an executable whose hash doesn't match. On 3.10 without this change it fails with the same `AttributeError`. - The CI Python job runs as a matrix on 3.10 and 3.12 with `fail-fast: false`. The Rust job is unchanged. CONTRIBUTING now says CI uses both versions. `tools/reference/xg-proxy/prepare.py` has the same call. I left it alone because `tools/reference/` is part of the audit in #359. ## Tested Run the [checks relevant to this change](../CONTRIBUTING.md#test-what-your-change-touches). - [x] The checks relevant to this change passed: `check --no-gpu` and the Python suite on 3.10 and 3.12. The D3D12 regression controls were **not** run: this machine doesn't have the Windows `dxcompiler.dll`/`dxil.dll` they need. The only change in that tool is the function that computes the artifact fingerprints. The control logic is the same. - [x] Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below: nothing runs differently in the guest. This change is to the check tooling and CI. - [ ] Where the table calls for AMD and NVIDIA, they passed on both. Otherwise, say which vendor still needs to run them: both, AMD and NVIDIA. A run of the D3D12 controls on any card would exercise the changed fingerprint path. GPU, driver and backend: none used. Commands run and their results: ```text python -m unittest discover -s tests -q main (e5c17a4), Python 3.10.21: Ran 521 tests FAILED (errors=2, skipped=29) this branch, Python 3.10.21: Ran 522 tests OK (skipped=29) this branch, Python 3.12.13: Ran 522 tests OK (skipped=29) python tuxbox.py check --no-gpu (Python 3.10.21 and 3.12.13, Rust 1.95.0) passed Build the shader compiler passed Python tests passed Shader compiler tests passed DXBC tests passed XG layout tests passed Storage codec tests passed D3D12 Windows typecheck ``` ## Checks No evidence JSON changed. _AI use: This contribution was written by an AI agent (Claude Opus 5.5) operating under my supervision. I am accountable for it and will respond to review._
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
brcly/TuxBox!366
No description provided.