Skip to content

Commit c2543a0

Browse files
committed
Rename template to drc-python
1 parent c8f10ab commit c2543a0

26 files changed

Lines changed: 2236 additions & 2 deletions

.github/workflows/ci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
ci:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Check out repository
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.12"
21+
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install -e ".[dev]"
26+
27+
- name: Run local CI gate
28+
run: make ci

.github/workflows/docs-pages.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Docs
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
9+
permissions:
10+
contents: read
11+
id-token: write
12+
pages: write
13+
14+
concurrency:
15+
group: pages
16+
cancel-in-progress: true
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Check out repository
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Python
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: "3.12"
30+
31+
- name: Install dependencies
32+
run: |
33+
python -m pip install --upgrade pip
34+
pip install -e ".[dev]"
35+
36+
- name: Build docs
37+
run: make docs
38+
39+
- name: Upload Pages artifact
40+
uses: actions/upload-pages-artifact@v3
41+
with:
42+
path: docs/_build/html
43+
44+
deploy:
45+
needs: build
46+
runs-on: ubuntu-latest
47+
environment:
48+
name: github-pages
49+
url: ${{ steps.deployment.outputs.page_url }}
50+
51+
steps:
52+
- name: Deploy to GitHub Pages
53+
id: deployment
54+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ cython_debug/
173173
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174174
# and can be added to the global gitignore or merged into this file. For a more nuclear
175175
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
176-
#.idea/
176+
.idea/
177177

178178
# Abstra
179179
# Abstra is an AI-powered process automation framework.
@@ -191,6 +191,9 @@ cython_debug/
191191
# Ruff stuff:
192192
.ruff_cache/
193193

194+
# Project-local generated artifacts
195+
artifacts/
196+
194197
# PyPI configuration file
195198
.pypirc
196199

.pre-commit-config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Pre-commit configuration
2+
3+
default_stages: [pre-commit]
4+
5+
repos:
6+
- repo: local
7+
hooks:
8+
- id: make-ci
9+
name: make ci
10+
entry: make ci
11+
language: system
12+
pass_filenames: false

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12.12

AGENTS.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# AGENTS.md
2+
3+
## Purpose
4+
5+
This repository is a reusable Python 3.12+ package template for small,
6+
well-tested libraries. Keep changes focused, keep the public API intentional,
7+
and prefer standard-library solutions unless a third-party dependency clearly
8+
improves the maintenance story.
9+
10+
## Setup
11+
12+
- Create and activate a virtual environment:
13+
- `python -m venv .venv`
14+
- `source .venv/bin/activate`
15+
- The reproducible interpreter target lives in `.python-version` (`3.12.12`).
16+
- Install local tooling with `make dev`.
17+
- For a frozen environment based on `uv.lock`, use `make repro`.
18+
19+
## Testing And Validation
20+
21+
Use the smallest useful check while iterating, then run the full gate before
22+
merging.
23+
24+
- Fast local loop:
25+
- `make fmt`
26+
- `make lint`
27+
- `make type`
28+
- `make test`
29+
- If docs changed:
30+
- `make docs-check`
31+
- `make docs`
32+
- If the example changed:
33+
- `make run-example`
34+
- Pre-merge baseline:
35+
- `make ci`
36+
- Pre-publish baseline:
37+
- `make release-check`
38+
39+
## Public Vs Private Boundaries
40+
41+
- The supported public surface is whatever is re-exported from
42+
`src/design_research_python_template/__init__.py`.
43+
- Prefer adding new public behavior to stable top-level modules before creating
44+
deeper internal package trees.
45+
- If you add internal helper modules later, prefix them with `_` and keep them
46+
out of the top-level exports unless there is a deliberate API decision.
47+
48+
## Behavioral Guardrails
49+
50+
- Keep tests deterministic and offline by default.
51+
- Update tests, docs, and examples alongside behavior changes.
52+
- Avoid broad dependency growth in the base install.
53+
- Keep this template easy to fork: simple defaults beat clever abstractions.
54+
55+
## Keep This File Up To Date
56+
57+
Update this file whenever the contributor workflow changes, especially when
58+
setup commands, validation commands, or the public API expectations change.

CONTRIBUTING.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Contributing
2+
3+
## Development Setup
4+
5+
```bash
6+
python -m venv .venv
7+
source .venv/bin/activate
8+
make dev
9+
```
10+
11+
For a reproducible install based on `uv.lock`:
12+
13+
```bash
14+
make lock
15+
make repro
16+
```
17+
18+
## Local Quality Checks
19+
20+
Run these before opening a pull request:
21+
22+
```bash
23+
make fmt
24+
make lint
25+
make type
26+
make docstrings-check
27+
make test
28+
make docs-check
29+
make docs
30+
```
31+
32+
Optional but useful:
33+
34+
```bash
35+
pre-commit install
36+
pre-commit run --all-files
37+
```
38+
39+
## Pull Request Guidelines
40+
41+
- Keep changes small enough to review quickly.
42+
- Add or update tests for behavior changes.
43+
- Update docs and examples when interfaces change.
44+
- Describe what changed and how you validated it.
45+
46+
## Code Style
47+
48+
- Python 3.12+ target
49+
- Ruff for linting and formatting
50+
- Mypy for type checking
51+
- Pytest for tests
52+
- Google-style docstrings in `src/`, `examples/`, and `scripts/`

Makefile

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
PYTHON ?= $(if $(wildcard .venv/bin/python),.venv/bin/python,$(shell if command -v python3.12 >/dev/null 2>&1; then echo python3.12; else echo python3; fi))
2+
PIP ?= $(PYTHON) -m pip
3+
PYTEST ?= $(PYTHON) -m pytest
4+
RUFF ?= $(PYTHON) -m ruff
5+
MYPY ?= $(PYTHON) -m mypy
6+
SPHINX ?= $(PYTHON) -m sphinx
7+
BUILD ?= $(PYTHON) -m build
8+
TWINE ?= $(PYTHON) -m twine
9+
UV ?= $(if $(wildcard .venv/bin/uv),.venv/bin/uv,uv)
10+
REPRO_PYTHON ?= $(shell cat .python-version 2>/dev/null || echo 3.12.12)
11+
REPRO_EXTRAS ?= dev
12+
13+
.PHONY: help check-python check-uv dev install-dev repro lock \
14+
lint fmt fmt-check type test qa coverage docstrings-check \
15+
run-example docs docs-build docs-check docs-linkcheck \
16+
release-check ci clean
17+
18+
help:
19+
@echo "Common targets:"
20+
@echo " dev Install the project in editable mode with dev dependencies."
21+
@echo " repro Frozen reproducible install using uv.lock."
22+
@echo " lock Regenerate uv.lock."
23+
@echo " test Run the pytest suite."
24+
@echo " qa Run lint, fmt-check, type, and test."
25+
@echo " run-example Execute the bundled example script."
26+
@echo " docs Build the HTML docs."
27+
@echo " ci Run the main local CI checks."
28+
29+
check-python:
30+
@$(PYTHON) -c "import pathlib, sys; print(f'Using Python {sys.version.split()[0]} at {pathlib.Path(sys.executable)}'); raise SystemExit(0 if sys.version_info >= (3, 12) else 1)" || (echo "Python >= 3.12 is required by pyproject.toml"; exit 1)
31+
32+
check-uv:
33+
@command -v $(UV) >/dev/null 2>&1 || (echo "uv is required for lock/repro targets. Install it from https://docs.astral.sh/uv/getting-started/installation/"; exit 1)
34+
35+
dev:
36+
$(PIP) install --upgrade pip setuptools wheel
37+
$(PIP) install -e ".[dev]"
38+
39+
install-dev: dev
40+
41+
repro: check-uv
42+
$(UV) sync --frozen --python $(REPRO_PYTHON) $(foreach extra,$(REPRO_EXTRAS),--extra $(extra))
43+
44+
lock: check-uv
45+
$(UV) lock --python $(REPRO_PYTHON)
46+
47+
lint: check-python
48+
$(RUFF) check .
49+
50+
fmt: check-python
51+
$(RUFF) format .
52+
53+
fmt-check: check-python
54+
$(RUFF) format --check .
55+
56+
type: check-python
57+
$(MYPY) src
58+
59+
test: check-python
60+
PYTHONPATH=src $(PYTEST) -q
61+
62+
qa: lint fmt-check type test
63+
64+
coverage: check-python
65+
mkdir -p artifacts/coverage
66+
PYTHONPATH=src $(PYTEST) --cov=src/design_research_python_template --cov-report=term --cov-report=json:artifacts/coverage/coverage.json -q
67+
$(PYTHON) scripts/check_coverage_thresholds.py --coverage-json artifacts/coverage/coverage.json
68+
69+
docstrings-check: check-python
70+
$(PYTHON) scripts/check_google_docstrings.py
71+
72+
run-example: check-python
73+
PYTHONPATH=src $(PYTHON) examples/basic_usage.py
74+
75+
docs-build: check-python
76+
PYTHONPATH=src $(SPHINX) -b html docs docs/_build/html -n -W --keep-going -E
77+
78+
docs-check: check-python
79+
$(PYTHON) scripts/check_docs_consistency.py
80+
81+
docs-linkcheck: check-python
82+
PYTHONPATH=src $(SPHINX) -b linkcheck docs docs/_build/linkcheck -W --keep-going -E
83+
84+
docs: docs-build
85+
86+
release-check: check-python
87+
rm -rf build dist
88+
$(BUILD) --no-isolation
89+
$(TWINE) check dist/*
90+
91+
ci: qa coverage docstrings-check docs-check run-example release-check
92+
93+
clean:
94+
rm -rf .coverage .mypy_cache .pytest_cache .ruff_cache artifacts build dist docs/_build src/design_research_python_template.egg-info
95+
find . -type d -name "__pycache__" -prune -exec rm -rf {} + 2>/dev/null || true
96+
find . -type f \( -name "*.pyc" -o -name ".coverage.*" \) -exec rm -f {} + 2>/dev/null || true

0 commit comments

Comments
 (0)