[PR #1265] tools: one cached work_root() per shader instead of nine realpath() calls (OLD-9777) #1296

Open
opened 2026-11-26 20:20:46 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1265
Author: @ambroseautomation
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: carry/old-9777-work-root-cache


📝 Commits (3)

  • a1c1e4c tools: one cached work_root() instead of nine repeated realpath() calls per shader
  • e3bb670 report_paths: resolve a relative work_root every time, never from the cache
  • 74cc3eb tests: compare work_root with the resolved temporary folder, as the function returns it

📊 Changes

4 files changed (+65 additions, -10 deletions)

View changed files

📝 tests/test_report_paths.py (+28 -0)
📝 tools/rdna2spirv.py (+6 -6)
📝 tools/report_paths.py (+25 -0)
📝 tools/shader_meta.py (+6 -4)

📄 Description

Claimed in the coordination issue as: OLD-9777 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7144385534)

What and why

Carries forward old-pr/9777 (draft #55, original commit author pes7 preserved across all 3 commits; indexed in #17), rebased cleanly onto current main (0b45fdc21).

Replaces repeated os.path.realpath calls per shader in tools/rdna2spirv.py and tools/shader_meta.py with a cached work_root() helper in tools/report_paths.py:

  • Caches os.path.realpath for absolute paths so translating a shader resolves its work root once instead of nine times (byte-identical output).
  • Resolves relative paths on every call (never from the cache), so changing working directory between calls still resolves accurately.
  • Adds WorkRootTests in tests/test_report_paths.py verifying absolute-path caching, relative-path re-resolution after os.chdir, and 8.3 short-path compatibility on Windows.

Tested

  • python -I tests/test_report_paths.py -v: 24 tests, OK (1 skipped: Windows symlink privilege).
  • python -m compileall -q make_game.py tools tests: exit 0.
  • python -I scripts/check_no_game_data.py tools/report_paths.py tools/rdna2spirv.py tools/shader_meta.py tests/test_report_paths.py: exit 0 (no game data).

GPUs tested: n/a (Python path resolution helper + stdlib unit tests on Windows 11 Pro 64-bit, Python 3.12.10)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a — path-resolution caching only, no codegen changes)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1265 **Author:** [@ambroseautomation](https://github.com/ambroseautomation) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `carry/old-9777-work-root-cache` --- ### 📝 Commits (3) - [`a1c1e4c`](https://github.com/ubiquitarianism/leonida/commit/a1c1e4cd6ddb4d2bfd68b522f42872f5b29e5688) tools: one cached work_root() instead of nine repeated realpath() calls per shader - [`e3bb670`](https://github.com/ubiquitarianism/leonida/commit/e3bb670ae8e235e9a52827d0e2a708eb416744b8) report_paths: resolve a relative work_root every time, never from the cache - [`74cc3eb`](https://github.com/ubiquitarianism/leonida/commit/74cc3eb3efe603626570f2f52cdcd8f7c8ca1e12) tests: compare work_root with the resolved temporary folder, as the function returns it ### 📊 Changes **4 files changed** (+65 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_report_paths.py` (+28 -0) 📝 `tools/rdna2spirv.py` (+6 -6) 📝 `tools/report_paths.py` (+25 -0) 📝 `tools/shader_meta.py` (+6 -4) </details> ### 📄 Description Claimed in the coordination issue as: OLD-9777 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7144385534) ### What and why Carries forward `old-pr/9777` (draft #55, original commit author `pes7` preserved across all 3 commits; indexed in #17), rebased cleanly onto current `main` (`0b45fdc21`). Replaces repeated `os.path.realpath` calls per shader in `tools/rdna2spirv.py` and `tools/shader_meta.py` with a cached `work_root()` helper in `tools/report_paths.py`: - Caches `os.path.realpath` for absolute paths so translating a shader resolves its work root once instead of nine times (byte-identical output). - Resolves relative paths on every call (never from the cache), so changing working directory between calls still resolves accurately. - Adds `WorkRootTests` in `tests/test_report_paths.py` verifying absolute-path caching, relative-path re-resolution after `os.chdir`, and 8.3 short-path compatibility on Windows. ### Tested - `python -I tests/test_report_paths.py -v`: 24 tests, OK (1 skipped: Windows symlink privilege). - `python -m compileall -q make_game.py tools tests`: exit 0. - `python -I scripts/check_no_game_data.py tools/report_paths.py tools/rdna2spirv.py tools/shader_meta.py tests/test_report_paths.py`: exit 0 (no game data). GPUs tested: n/a (Python path resolution helper + stdlib unit tests on Windows 11 Pro 64-bit, Python 3.12.10) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a — path-resolution caching only, no codegen changes) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1296
No description provided.