Skip to content

gallery: validate declared installable deps; add pygraphics to apollo deps; refresh requirements and tests - #122

Merged
bdbarnett merged 1 commit into
mainfrom
codex/create-plan-for-issues-119-and-120-lwwbnr
Sep 6, 2026
Merged

gallery: validate declared installable deps; add pygraphics to apollo deps; refresh requirements and tests#122
bdbarnett merged 1 commit into
mainfrom
codex/create-plan-for-issues-119-and-120-lwwbnr

Conversation

@bdbarnett

@bdbarnett bdbarnett commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

Motivation

  • Ensure gallery examples declare any installable top-level PyDevices deps they actually import so missing runtime packages are detected early.
  • Keep requirements.txt and refresh-requirements.py in sync with packages that publish from the audio components repo.
  • Fix the Apollo example metadata to list pygraphics as a dependency.

Description

  • Add INSTALLABLE_DEPS and an AST-based imported_top_level_modules helper plus validate_example_deps to detect missing or unused declared installable deps, and call it from main in scripts/gallery_generator.py.
  • Import ast where needed and wire dependency validation into the discovery flow.
  • Update lib/examples/apollo/apollo.py header comment to include pygraphics in the # deps: line.
  • Adjust requirements.txt ordering to include pydevices-audioinstruments and pydevices-audioeffects in the installation order.
  • Update scripts/refresh-requirements.py PACKAGE_ORDER with comments and the two audio component entries so the refresh script keeps them.
  • Add a unit test in tests/test_gallery_screenshots.py that exercises validate_example_deps for missing/unused-dep detection.
  • Refactor tests/test_peterhinch_page.py into a unittest.TestCase class and make it runnable as a script with a if __name__ == "__main__": unittest.main() entry.

Testing

  • Ran the updated gallery unit tests via python -m unittest tests.test_gallery_screenshots and the new dependency checks passed.
  • Ran python -m unittest tests.test_peterhinch_page and the refactored page tests passed.
  • Ran the modified tests as part of the local unit test run (python -m unittest) and observed no failures for the changed files.

Codex Task


Verification by the reviewer (2026-09-06)

The branch was fetched and run on the maintainer's machine beside the pydevices sibling checkout, which tests/test_browser_url.py needs.

Command Result
python -m unittest tests.test_peterhinch_page Ran 17 tests … OK (0 collected before this PR)
python -m unittest discover -s tests Ran 60 tests … OK (43 before)
scripts/gallery_generator.py --check exit 0; 55 gallery demo(s) (47 module, 8 manifest; 5 featured; 2 in a new window); 17 local-only; three reverse-check warnings (tiny_toasters declares palettes, touch_gui_simpletest declares pygraphics, widgets_locker_kiosk declares audioif; none imported)
Planted fault: pygraphics removed from lib/examples/apollo/apollo.py's # deps: header, then --check exit 1: gallery dependency errors: lib/examples/apollo/apollo.py: missing # deps: pygraphics — header restored afterwards

The apollo header change is a real undeclared dependency the new guard found: on main the file declares # deps: palettes and imports pygraphics, so the Apollo DSKY demo has been failing on the deployed gallery the same way drum_machine did before #120 was filed.

The requirements.txt / refresh-requirements.py lines in this diff are identical to what main already carries in 8268d3aa; the branch re-applied them on the older base, and the merge resolves them as one change.

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

Labels

Development

Successfully merging this pull request may close these issues.

1 participant