-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopier.yml
More file actions
256 lines (223 loc) · 8.09 KB
/
copier.yml
File metadata and controls
256 lines (223 loc) · 8.09 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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# Copier template: uv-first Python package (optional NumPy/pandas, docs, strict typing)
# -------------------------------------------------------------------------
# Template metadata
# -------------------------------------------------------------------------
# Minimal required Copier version for this template and where the
# template lives inside the repository.
_min_copier_version: "9.11.2"
_subdirectory: template
# Jinja extensions enabled for rendering templates. Add extensions
_jinja_extensions:
- jinja2_time.TimeExtension
- jinja2.ext.do
- jinja2.ext.loopcontrols
# File used to persist answers between runs so re-running copier
# can reuse previously provided values.
_answers_file: ".copier-answers.yml"
# -------------------------------------------------------------------------
# Lifecycle (update safety)
# -------------------------------------------------------------------------
# Files and directories listed here will be preserved on template
# updates to avoid overwriting user edits in generated projects.
_skip_if_exists:
- docs/
- .github/CODE_OF_CONDUCT.md
- .github/ISSUE_TEMPLATE/bug_report.md
- .github/ISSUE_TEMPLATE/feature_request.md
- .github/PULL_REQUEST_TEMPLATE.md
- CLAUDE.md
- CONTRIBUTING.md
- env.example
- mkdocs.yml
- pyproject.toml
- README.md
- SECURITY.md
- src/{{ package_name }}/__init__.py
- src/{{ package_name }}/common/bump_version.py
# -------------------------------------------------------------------------
# Questions / Prompts
# -------------------------------------------------------------------------
# Interactive prompts presented when generating a project. Keep
# prompts clear and provide sensible defaults to simplify onboarding.
project_name:
type: str
help: Human-readable project name (e.g., "My Library")
default: "My Library"
placeholder: "My Library"
project_slug:
type: str
default: "{{ project_name | lower | replace(' ', '-') | replace('_', '-') | regex_replace('[^a-z0-9-]', '') }}"
help: Slug for URLs and package distribution
package_name:
type: str
default: "{{ project_name | lower | replace(' ', '_') | replace('-', '_') }}"
help: Python package name (must be valid Python identifier)
validator: >-
{% if not package_name.isidentifier()
or not package_name.replace('_', '').isalnum() %}
Package name must be a valid Python identifier (letters, digits, underscores; cannot start with a digit)
{% endif %}
project_description:
type: str
help: Short description of the project
default: "A Python library"
author_name:
type: str
help: Author's full name
default: "Your Name"
author_email:
type: str
help: Author's email
default: "you@example.com"
github_username:
type: str
help: GitHub username or organization
default: "yourusername"
python_min_version:
type: str
help: Minimum Python version
default: "3.11"
choices:
- "3.11"
- "3.12"
- "3.13"
license:
type: str
help: Project license
default: MIT
choices:
- MIT
- Apache-2.0
- BSD-3-Clause
- GPL-3.0
- Proprietary
include_docs:
type: bool
help: Include MkDocs documentation setup?
default: true
include_pandas_support:
type: bool
help: Include pandas in dependencies?
default: false
include_numpy:
type: bool
help: Include NumPy in dependencies?
default: false
include_release_workflow:
type: bool
help: Add a GitHub Actions release workflow (automated versioning and GitHub Releases)?
default: true
include_pypi_publish:
type: bool
help: "Publish to PyPI on release? (Uses Trusted Publisher / OIDC \u2014 no API token needed)"
default: false
when: "{{ include_release_workflow }}"
include_security_scanning:
type: bool
help: Add CodeQL security scanning and dependency audit workflow?
default: true
include_cli:
type: bool
help: Generate a Typer-based CLI entry point and console script?
default: false
include_git_cliff:
type: bool
help: Add git-cliff, cliff.toml, and a just changelog recipe for release notes?
default: true
# -------------------------------------------------------------------------
# Computed values
# -------------------------------------------------------------------------
# Template-generated computed values (not asked interactively).
# Use these for dynamic defaults and CI matrix generation.
current_year:
type: str
when: false
default: "{% now 'utc', '%Y' %}"
# Renders as a JSON array string, e.g. '["3.11", "3.12", "3.13"]'. In workflow templates,
# use fromJson() when passing to a matrix (e.g. matrix.python: ${{ fromJson(...) }}).
github_actions_python_versions:
type: str
when: false
default: >-
{% if python_min_version == "3.11" -%}
["3.11", "3.12", "3.13"]
{%- elif python_min_version == "3.12" -%}
["3.12", "3.13"]
{%- else -%}
["3.13"]
{%- endif %}
# -------------------------------------------------------------------------
# Post-generation tasks
# -------------------------------------------------------------------------
# Commands run after template rendering.
#
# Notes / rationale:
# - Generated projects are "uv-first" (lock-file-first workflow). These tasks should succeed even
# when the host Python lacks `ensurepip`/`pip` (common on minimal distro Pythons).
# - To avoid template generation failing on machines without `uv`, we bootstrap `uv` first.
# We try `pip` if available; otherwise we fall back to Astral's installer script.
# - Keep tasks idempotent.
#
# Copy vs update: these tasks run after both `copier copy` and `copier update` (not gated
# with _copier_operation) so the lockfile and local env stay aligned with the template after
# updates. Consumers may use `copier update --skip-tasks` when they want to skip them.
_tasks:
- ["git", "init"]
- command: >-
sh -c '
# Bootstrap `uv` if missing.
#
# Copier executes tasks via /bin/sh, so this must be POSIX-sh compatible.
# We try (in order):
# - existing `uv` on PATH
# - `python -m pip install uv` (if pip is available)
# - Astral install script via curl/wget
if command -v uv >/dev/null 2>&1; then
exit 0
fi
if command -v python >/dev/null 2>&1 && python -m pip --version >/dev/null 2>&1; then
python -m pip install --upgrade uv && exit 0
fi
if command -v python3 >/dev/null 2>&1 && python3 -m pip --version >/dev/null 2>&1; then
python3 -m pip install --upgrade uv && exit 0
fi
if command -v curl >/dev/null 2>&1; then
curl -LsSf https://astral.sh/uv/install.sh | sh || exit 1
elif command -v wget >/dev/null 2>&1; then
wget -qO- https://astral.sh/uv/install.sh | sh || exit 1
else
echo "❌ uv is required but was not found. Install from https://docs.astral.sh/uv/ or ensure curl/wget is available." >&2
exit 1
fi
# Astral installer typically drops an env file that prepends ~/.local/bin to PATH.
if [ -f "$HOME/.local/bin/env" ]; then
. "$HOME/.local/bin/env"
fi
command -v uv >/dev/null 2>&1
'
- command: uv lock
- command: >-
uv sync --extra dev --extra test
{%- if include_docs %} --extra docs{% endif -%}
{%- if include_git_cliff %} --group changelog{% endif %}
- command: uv run pre-commit install || true
- command: uv run pre-commit install --hook-type pre-push || true
- command: uv run ruff check --fix --unsafe-fixes . || true
- command: uv run basedpyright || true
- command: sh -c 'rmdir docs 2>/dev/null || true'
when: "{{ not include_docs }}"
- command: >-
sh -c 'find . -type f -empty ! -path "./.git/*" ! -path "./.venv/*" -delete'
- command: echo "✅ Project {{ project_name }} created successfully!"
- command: echo "📁 Location $(pwd)"
- command: echo "🚀 Run 'just ci' to verify everything works"
# -------------------------------------------------------------------------
# Template-only exclusions
# -------------------------------------------------------------------------
# Files and directories present in the template repo that should not
# be copied into generated projects (editor state, virtualenvs, etc.).
_exclude:
- ".git"
- ".venv"
- "__pycache__"
- "*.pyc"