-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopier.yaml
More file actions
204 lines (174 loc) · 5.19 KB
/
copier.yaml
File metadata and controls
204 lines (174 loc) · 5.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# Copier template for Python projects
# Usage: uvx copier copy --trust gh:namitdeb739/python-template <project-dir>
# Docs: https://namitdeb739.github.io/python-template
# --- Project identity ---
project_name:
type: str
help: Project name in kebab-case (e.g. my-ml-project)
placeholder: my-project
package_name:
type: str
help: Python package name in snake_case (leave blank to auto-derive)
default: "{{ project_name | replace('-', '_') }}"
placeholder: my_project
description:
type: str
help: Short one-line description
placeholder: A Python project
author_name:
type: str
help: Author full name
placeholder: Your Name
author_email:
type: str
help: Author email
placeholder: you@example.com
github_user:
type: str
help: GitHub username or organisation
placeholder: your-username
# --- Feature toggles ---
# CI / security
ci_github:
type: bool
default: true
help: Enable GitHub Actions CI/CD?
security:
type: str
default: basic
help: "Security level"
choices:
"No security tooling": none
"Pre-commit hooks + ruff linting": basic
"Basic + CodeQL, pip-audit, Dependabot, branch protection": full
# Code quality
testing:
type: str
default: standard
help: "Testing level"
choices:
"pytest only": minimal
"pytest + coverage + fixtures": standard
"Standard + coverage threshold + parametrized examples": full
use_typecheck:
type: bool
default: true
help: Enable mypy strict type checking?
# Documentation & deployment
use_docs:
type: bool
default: true
help: Include MkDocs documentation?
use_docker:
type: str
default: cpu
help: "Docker support"
choices:
"No Docker": none
"CPU Dockerfile + Compose": cpu
"CPU + GPU Dockerfile": gpu
# Dev environment
use_devcontainer:
type: bool
default: false
help: Include VS Code dev container config?
# Domain-specific extras
use_ml:
type: bool
default: false
help: Include ML/data science setup (notebooks, data dir, optional deps)?
use_iot:
type: bool
default: false
help: Include IoT/embedded setup (serial, GPIO, MQTT drivers, device config)?
use_cli:
type: bool
default: false
help: Include Typer CLI scaffold (commands, --help, rich output)?
use_api:
type: bool
default: false
help: Include FastAPI REST API scaffold (routes, health endpoint, uvicorn serve)?
use_db:
type: bool
default: false
help: Include SQLAlchemy 2 + Alembic (database session, migrations)?
# --- Post-setup options ---
init_dvc:
type: bool
help: Initialise DVC for data versioning?
default: false
when: "{{ use_ml }}"
init_env:
type: bool
help: Create .env from .env.example?
default: false
when: "{{ use_ml }}"
_min_copier_version: "9.0.0"
_subdirectory: template
_exclude:
- .git/
- .venv/
- site/
- uv.lock
_tasks:
# Rename source package directory to match package_name
- command: mv src/project_name "src/{{ package_name }}"
when: "{{ package_name != 'project_name' }}"
# Remove disabled features
- command: rm -rf .devcontainer/
when: "{{ not use_devcontainer }}"
- command: rm -rf "src/{{ package_name }}/drivers/" "src/{{ package_name }}/sensors/" config/
when: "{{ not use_iot }}"
- command: rm -f tests/test_drivers.py
when: "{{ not use_iot }}"
- command: rm -f "src/{{ package_name }}/cli.py"
when: "{{ not use_cli }}"
- command: rm -rf "src/{{ package_name }}/api/"
when: "{{ not use_api }}"
- command: rm -rf "src/{{ package_name }}/db/" alembic/ alembic.ini
when: "{{ not use_db }}"
- command: rm -rf docker/ .dockerignore
when: "{{ use_docker == 'none' }}"
- command: rm -f docker/Dockerfile.gpu
when: "{{ use_docker != 'gpu' and use_docker != 'none' }}"
- command: rm -rf docs/ mkdocs.yml
when: "{{ not use_docs }}"
- command: rm -rf notebooks/ data/ .env.example
when: "{{ not use_ml }}"
- command: rm -rf .github/workflows/ .github/dependabot.yml
when: "{{ not ci_github }}"
- command: rm -f .github/workflows/codeql.yml .github/workflows/dependabot-auto-merge.yml .github/dependabot.yml
when: "{{ ci_github and security != 'full' }}"
- command: rm -f .github/workflows/docs.yml
when: "{{ ci_github and not use_docs }}"
- command: rm -f .pre-commit-config.yaml
when: "{{ security == 'none' }}"
- command: rm -f tests/conftest.py tests/test_config.py
when: "{{ testing == 'minimal' }}"
# Initialise git and make initial commit
- git init
- git config core.longpaths true
- git add -A
- 'git commit -m "chore: initial project from template"'
# Install dependencies and hooks
- uv sync --dev
- command: uv run pre-commit install
when: "{{ security != 'none' }}"
# Optional extras
- command: uv run dvc init && uv run dvc config core.autostage true
when: "{{ init_dvc }}"
- command: cp .env.example .env
when: "{{ init_env }}"
_message_after_copy: |
Project {{ project_name }} is ready!
Next steps:
cd {{ project_name }}
just check # verify lint + type-check + tests all pass
{% if ci_github %}
just init-remote # create GitHub repo, push, configure branch protection + Pages
{% else %}
git init && git add -A && git commit -m "chore: initial commit"
{% endif %}
Update later:
uvx copier update --trust