Skip to content

Commit be762fc

Browse files
committed
scaffold: add Makefile, dependabot and pre-commit templates; use uv sync in scaffolder
1 parent f2bf690 commit be762fc

File tree

4 files changed

+81
-1
lines changed

4 files changed

+81
-1
lines changed

python_project_deployment/scaffolder.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ def _render_templates(self, dest: Path) -> None:
101101
(".gitignore.j2", dest / ".gitignore"),
102102
("LICENSE.j2", dest / "LICENSE"),
103103
("ci.yaml.j2", dest / ".github" / "workflows" / "ci.yaml"),
104+
("Makefile.j2", dest / "Makefile"),
105+
("dependabot.yml.j2", dest / ".github" / "dependabot.yml"),
104106
("package_init.py.j2", dest / self.config.package_name / "__init__.py"),
105107
("hello.py.j2", dest / self.config.package_name / "hello.py"),
106108
("test_hello.py.j2", dest / "tests" / "test_hello.py"),
@@ -157,8 +159,9 @@ def _setup_environment(self, dest: Path) -> None:
157159
# Use uv to create venv and run installs
158160
self.logger.info("Using uv binary: %s", uv_path)
159161
subprocess.run([uv_path, "venv"], cwd=dest, check=True, capture_output=True)
162+
# Use uv sync to install dev extras (preferred over direct pip usage)
160163
subprocess.run(
161-
[uv_path, "pip", "install", "-e", ".[dev]"],
164+
[uv_path, "sync", "--all-extras"],
162165
cwd=dest,
163166
check=True,
164167
capture_output=True,
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
SHELL := /bin/bash
2+
.PHONY: help install sync test lint type format docs precommit clean
3+
4+
help:
5+
@echo "Available targets:"
6+
@echo " make install # install uv (if missing) and sync dependencies"
7+
@echo " make sync # uv sync --all-extras"
8+
@echo " make test # run tests with coverage"
9+
@echo " make lint # run ruff"
10+
@echo " make type # run mypy"
11+
@echo " make format # format with ruff"
12+
@echo " make docs # build Sphinx docs"
13+
@echo " make precommit # install pre-commit hooks"
14+
@echo " make clean # remove build artifacts"
15+
16+
install:
17+
@command -v uv >/dev/null 2>&1 || \
18+
{ echo "uv not found. Please install uv. Example:"; \
19+
echo " curl -LsSf https://astral.sh/uv/install.sh | sh"; exit 1; }
20+
uv sync --all-extras
21+
22+
sync:
23+
uv sync --all-extras
24+
25+
test:
26+
uv run pytest --cov
27+
28+
lint:
29+
uv run ruff check .
30+
31+
type:
32+
uv run mypy src
33+
34+
format:
35+
uv run ruff format .
36+
37+
docs:
38+
uv run sphinx-build -b html docs docs/_build
39+
40+
precommit:
41+
uv run pre-commit install
42+
43+
clean:
44+
rm -rf .venv build dist htmlcov coverage.xml coverage.json docs/_build
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
- package-ecosystem: "pip"
8+
directory: "/"
9+
schedule:
10+
interval: "weekly"
11+
allow:
12+
- dependency-type: "all"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.6.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- repo: https://github.com/charliermarsh/ruff-pre-commit
9+
rev: v0.0.254
10+
hooks:
11+
- id: ruff
12+
args: ["--fix"]
13+
- repo: https://github.com/psf/black
14+
rev: 23.9.1
15+
hooks:
16+
- id: black
17+
- repo: https://github.com/pre-commit/mirrors-mypy
18+
rev: v1.7.0
19+
hooks:
20+
- id: mypy
21+
additional_dependencies: ["mypy==1.7.0"]

0 commit comments

Comments
 (0)