recipe-tester: support test-only deps via tests/requirements.txt#98
Merged
Conversation
The tester app installs flet + pytest + the recipe's Requires-Dist only, so a zero-runtime-dep recipe (safetensors) can't exercise integration paths on-device — its numpy test could only ever skip. stage_recipe.sh now expands an optional recipes/<name>/tests/requirements.txt (one PEP 508 spec per line, comments/blanks skipped) into the generated pyproject via a __TEST_DEPS__ token line in the template. Template expansion is a bash line loop with printf rather than sed: specs legitimately contain double quotes in markers, which have no safe portable sed-RHS escaping. Deps are emitted as TOML literal strings, so single quotes inside a spec are rejected with an error. Token matches are exact-line, so comments mentioning a token pass through verbatim. Empty-array expansion is guarded for macOS bash 3.2 under set -u.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The recipe-tester app installs
flet + pytest + <recipe>, so the only third-party packages available on-device are the recipe's ownRequires-Dist. That's fine for most recipes (numpy etc. come in transitively), but a zero-runtime-dep recipe can't exercise its integration paths on-device at all.What changed
stage_recipe.sh: after staging tests, an optionalrecipes/<name>/tests/requirements.txt(one PEP 508 spec per line; blanks and#-comments skipped) is expanded into the generatedpyproject.toml.pyproject.toml.tpl: new__TEST_DEPS__token line inside thedependenciesarray (replaced with zero or more dep lines — absent file emits nothing).README.md: documents the convention, incl. the constraint that each test dep must be installable for the mobile target (pure-Python from PyPI, or a recipe already published on pypi.flet.dev / seeded viaprebuild_recipes) — the same constraint a real app faces — and the guidance to preferimportorskipfor genuinely-optional integrations.Implementation notes
printf '%s'rather thansed: PEP 508 markers legitimately contain double quotes (numpy; python_version >= "3.10"), which have no safe portable sed-RHS escaping (BSD vs GNU).::error::.${arr[@]+...}) for macOS bash 3.2 underset -u, so the script keeps working for local devs on the system bash.