-
Notifications
You must be signed in to change notification settings - Fork 0
docs: local dev runner (dev.py) + README install/dev sections #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| #!/usr/bin/env python3 | ||
| """Local dev runner for fp-py — stdlib only, no third-party task runner. | ||
|
|
||
| Run the tight dev loop on your own machine (free) instead of via paid agents: | ||
|
|
||
| python -m pip install -e ".[dev]" # one-time setup | ||
| python dev.py check # guard + tests (what CI runs) | ||
| python dev.py test # unittest suite | ||
| python dev.py cov # tests + coverage report | ||
| python dev.py guard # zero-dependency guard | ||
| """ | ||
| from __future__ import annotations | ||
|
|
||
| import subprocess | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| ROOT = Path(__file__).resolve().parent | ||
| PY = sys.executable | ||
|
|
||
|
|
||
| def run(*args: str) -> int: | ||
| print(f"$ {' '.join(args)}") | ||
| return subprocess.call(args, cwd=str(ROOT)) | ||
|
|
||
|
|
||
| def test() -> int: | ||
| return run(PY, "-m", "unittest", "discover", "-s", "tests", "-t", ".") | ||
|
|
||
|
|
||
| def cov() -> int: | ||
| rc = run(PY, "-m", "coverage", "run", "--source=fp", | ||
| "-m", "unittest", "discover", "-s", "tests", "-t", ".") | ||
| return rc or run(PY, "-m", "coverage", "report", "-m") | ||
|
|
||
|
|
||
| def guard() -> int: | ||
| return run(PY, "tools/dep_guard.py") | ||
|
|
||
|
|
||
| def check() -> int: | ||
| return guard() or test() | ||
|
|
||
|
|
||
| COMMANDS = {"test": test, "cov": cov, "guard": guard, "check": check} | ||
|
|
||
|
|
||
| def main(argv: list[str]) -> int: | ||
| cmd = argv[1] if len(argv) > 1 else "check" | ||
| fn = COMMANDS.get(cmd) | ||
| if fn is None: | ||
| print(f"unknown command {cmd!r}; choose from: {', '.join(COMMANDS)}") | ||
| return 2 | ||
| return fn() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| raise SystemExit(main(sys.argv)) | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
dev.py checkis run under supported Python 3.9/3.10 interpreters (requires-python = ">=3.9"), this delegates the guard to the same interpreter, buttools/dep_guard.pyimportstomllib, which is only in the stdlib from Python 3.11 onward. I reproduced this withPYENV_VERSION=3.10.20 python dev.py guard, which exits withModuleNotFoundError: No module named 'tomllib', so developers on supported Python versions cannot use the newly documentedcheckloop.Useful? React with 👍 / 👎.