-
Notifications
You must be signed in to change notification settings - Fork 0
Overhaul Tooling & Setup #5
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| description = "Templatize a new Python repo" | ||
| prompt = """ | ||
| I want you to "templatize" a new Python repository (cloned from a GitHub repo template) by following these steps: | ||
|
|
||
| 1. Run the `templatize` script: | ||
| ```bash | ||
| ./templatize | ||
| ``` | ||
| This updates placeholders like `{{REPO_NAME}}`, so everything is configured with my username, repo name, email, etc. | ||
| 2. Install the package, dev dependencies, and pre-commit hooks (see README). | ||
| 3. Use `pip list` or `uv pip list` to very which package versions were installed, and pin them in `pyproject.toml` for consistency. Do not add any new packages to `pyproject.toml` -- just pin the ones that are already listed. | ||
| 4. Delete: | ||
| - the "usage" section of the README on templatization | ||
| - the `./templatize` script | ||
| - the `Templatize` step in `.github/workflows/test.yaml` | ||
| - the "templatize" slash-command file at `.gemini/commands/templatize.toml` | ||
| 5. Update the README to give a brief description of the project. If you are unable to infer the description based on the repo, please ask me for more details. | ||
| 6. Commit and push the changes. | ||
| ```bash | ||
| # you'll need to re-activate the virtual environment here | ||
| source .venv/bin/activate | ||
| git add . | ||
| git commit -m "Templatize" | ||
| git push | ||
| ``` | ||
| Type checking, linting, and formatting will run automatically on commit. You may fix any issues and recommit as needed. | ||
|
|
||
| Do not add any new files. Only modify or delete existing files. | ||
| """ |
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| .vscode | ||
| uv.lock | ||
| worktrees/ | ||
|
|
||
| # Byte-compiled / optimized / DLL files | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,23 @@ | ||
| repos: | ||
| - repo: local | ||
| hooks: | ||
| - id: black | ||
| name: black | ||
| - id: ruff-format | ||
| name: ruff format | ||
| stages: [pre-commit] | ||
| language: system | ||
| entry: black | ||
| entry: ruff format | ||
| types: [python] | ||
|
|
||
| - id: ruff | ||
| - id: ruff-check | ||
| name: ruff check | ||
| stages: [pre-commit] | ||
| language: system | ||
| entry: ruff check | ||
| types: [python] | ||
|
|
||
| - id: ty-check | ||
| name: ty check | ||
| stages: [pre-commit] | ||
| language: system | ||
| entry: ty check | ||
| types: [python] |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,34 +1,28 @@ | ||||||
| # {{REPO_NAME}} | ||||||
|
|
||||||
| A simple template for Python projects, with CI/CD configured through GitHub Actions. Compatible with any virtual environment manager (e.g. `uv`, `venv`, `pyenv`, `poetry`, `conda`). | ||||||
| A simple template for Python projects, with CI/CD configured through GitHub Actions. | ||||||
|
|
||||||
|
|
||||||
| ## Usage | ||||||
|
|
||||||
| 1. Create a new repository, using this one as a template. | ||||||
| 2. Run the `templatize` script: | ||||||
| 2. Install and open [Gemini CLI](https://github.com/google-gemini/gemini-cli), then run the `/templatize` command: | ||||||
| ```bash | ||||||
| ./templatize | ||||||
| gemini run /templatize | ||||||
| ``` | ||||||
|
|
||||||
| This updates placeholders like `{{REPO_NAME}}`, so everything is configured with your username, repo name, email, etc. | ||||||
| 3. Commit and push the changes. | ||||||
| ```bash | ||||||
| git add . | ||||||
| git commit -m "Templatize" | ||||||
| git push | ||||||
| ``` | ||||||
| 4. (Probably) delete this section of the README. | ||||||
|
|
||||||
| ## Install | ||||||
|
|
||||||
| ```bash | ||||||
| pip install "{{REPO_NAME}} @ git+ssh://git@github.com/{{REPO_OWNER}}/{{REPO_NAME}}.git" | ||||||
| > **Note:** For simplicity, I assume you are using [uv](https://docs.astral.sh/uv/getting-started/installation/), but this project is compatible with any virtual environment or package manager (`pip`, `venv`, `poetry`, `pipenv`, `conda`). | ||||||
|
|
||||||
| # Install all dev dependencies (tests etc.) | ||||||
| pip install "{{REPO_NAME}}[test] @ git+ssh://git@github.com/{{REPO_OWNER}}/{{REPO_NAME}}.git" | ||||||
| ```bash | ||||||
| # Create and activate a new virtual environment | ||||||
| uv venv --python 3.12 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The installation instructions hardcode Python 3.12, while
Suggested change
|
||||||
| source .venv/bin/activate | ||||||
|
|
||||||
| # Setup pre-commit hooks | ||||||
| # Install development dependencies and pre-commit hoooks | ||||||
| uv sync --all-extras | ||||||
| pre-commit install | ||||||
| ``` | ||||||
|
|
||||||
|
|
@@ -37,11 +31,9 @@ pre-commit install | |||||
|
|
||||||
| | Tool | Description | Runs on | | ||||||
| | --- | --- | --- | | ||||||
| | [black](https://github.com/psf/black) | Code formatter | - `git commit` (through `pre-commit`) <br> - `git push` <br> - pull requests | | ||||||
| | [ruff](https://github.com/astral-sh/ruff) | Code linter | - `git commit` (through `pre-commit`) <br> - `git push` <br> - pull requests | | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The description for
Suggested change
|
||||||
| | [ty](https://docs.astral.sh/ty/) | Static type checker | - `git commit` <br> - pull requests | | ||||||
| | [pytest](https://github.com/pytest-dev/pytest) | Unit testing framework | - `git push` <br> - pull requests | | ||||||
| | [mypy](https://github.com/python/mypy) | Static type checker | - `git push` <br> - pull requests | | ||||||
| | [pre-commit](https://github.com/pre-commit/pre-commit) | Pre-commit hooks | - `git commit` | | ||||||
| | [twine](https://github.com/pypa/twine) $\dagger$ | PyPI package uploader | - New release (`git tag`) | | ||||||
|
|
||||||
| > $\dagger$ Requires enabling the `publish.yaml` workflow. To activate, move the file from `.github/disabled-workflows/publish.yaml.disabled` to `.github/workflows/publish.yaml`, and set a valid PyPI token as `PYPI_API_TOKEN` in the repo secrets. | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ description = "{{REPO_NAME}}" | |
| license = {text = "MIT"} | ||
| dynamic = ["version", "readme"] # NOTE: Must be in sync with [tool.setuptools.dynamic] below | ||
| dependencies = [] | ||
| requires-python = ">=3.8" | ||
| requires-python = ">=3.11" | ||
| classifiers = ["Programming Language :: Python :: 3"] | ||
|
|
||
| [tool.setuptools.dynamic] | ||
|
|
@@ -24,12 +24,12 @@ exclude = ["tests"] | |
| # extra packages (e.g. pip install .[test]) | ||
| [project.optional-dependencies] | ||
| test = [ | ||
| "black", | ||
| "mypy", | ||
| "pre-commit", | ||
| "pytest", | ||
| "pytest-cov", | ||
| "ruff", | ||
| "ty", | ||
| ] | ||
|
Comment on lines
26
to
33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +0,0 @@ | ||
| import pytest | ||
|
|
||
|
|
||
| def pytest_addoption(parser): | ||
| parser.addoption("--slow", action="store_true") | ||
|
|
||
|
|
||
| def pytest_configure(config): | ||
| config.addinivalue_line("markers", "slow: slow to run") | ||
|
|
||
|
|
||
| def pytest_collection_modifyitems(config, items): | ||
| run_slow = config.getoption("--slow") | ||
| skip_fast = pytest.mark.skip(reason="remove --slow option to run") | ||
| skip_slow = pytest.mark.skip(reason="need --slow option to run") | ||
|
|
||
| for item in items: | ||
| if ("slow" in item.keywords) and (not run_slow): | ||
| item.add_marker(skip_slow) | ||
| if ("slow" not in item.keywords) and (run_slow): | ||
| item.add_marker(skip_fast) | ||
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.
The
uv.lockfile should not be ignored. Lock files are intended to be checked into version control to ensure reproducible builds for all developers and in CI environments. According to theuvdocumentation,uv.lockshould be committed.