You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: convert template to copier so projects can pull template updates - #32
Stacked on #15. Retarget to main after #15 merges.
What does this PR do? 📝
Converts the template to copier, so projects created from it can pull later template updates with one command: just update-template.
copier.yml asks five questions: project name, slug, package name, description, and Python version. The questions include help text and validators, and the suggested defaults work if users just press Enter.
template/ holds every file a new project gets. Only the files that need an answer use .jinja: pyproject.toml, README.md, the docs titles, .python-version, the test import, and the src/{{ package_name }}/ folder name. The Justfile and workflows stay plain so their own {{ }} syntax is untouched.
just update-template (Windows and Mac/Linux) checks that the user's work is committed, runs copier update, lists the changed files, and says what to do next in plain language.
.gitattributes (eol=lf) fixes a Windows problem. Git for Windows' default core.autocrlf=true turned every changed file into a single whole-file conflict on update. With .gitattributes, conflicts cover only the lines that actually changed.
[tool.uv.build-backend] module-name fixes a crash. uv_build looks for the package under the project name, so builds broke whenever a user picked a package name that differed from the slug.
No uv.lock is shipped. Each project creates its own lock file on the first just get-started.
Root README is a step-by-step guide for IPA staff who are new to git and copier. It covers one-time setup, creating a project, getting updates, resolving conflicts in VS Code (with an undo escape hatch), linking projects made from the old GitHub template, a glossary, and a maintainer section.
Root CI (template-ci.yml) renders the template, checks that no Jinja leaked into the output, runs the generated project's pre-commit hooks and tests, then runs copier update and checks that it leaves no changes. The root has its own zizmor and check-yaml hooks, and Dependabot (with a 7-day cooldown) watches actions in / and /template.
Projects created with GitHub's "Use this template" button get a one-time copy. Fixes like the zizmor hardening and the security bumps in #15 never reach them.
Option
Can existing projects pull updates?
Notes
GitHub "Use this template"
No
One-time copy
cookiecutter
No
Creates projects only
cruft (on cookiecutter)
Yes
Applies template diffs as patches with weaker conflict handling; needs {{cookiecutter.x}}/ folders
copier
Yes, built in
3-way merge with inline conflicts; records answers; works for any language; runs with uvx, no install
Recommendation for the Stata, R and PPI templates: use the same pattern: copier with _subdirectory: template, a few questions, .gitattributes with eol=lf, a just update-template recipe, and CI that renders the template and tests the result. copier runs through uvx, so Stata and R users need no Python project of their own.
How was this implemented? 🛠️
git mv keeps the file history. I followed the docs literally on Windows, in fresh temp folders, for each path:
create → git init → just venv → first commit: all hooks pass on the first try
just update-template with unsaved work: refuses, with a friendly message
update with a template change: the change is applied, .copier-answers.yml is bumped
update where the template and the user changed the same line: an inline conflict scoped to that line (before updating = yours = VS Code "Current"; after updating = template = "Incoming")
linking an old GitHub-template project (CRLF line endings) with copier copy --overwrite, then renormalizing: tests pass, and a later just update-template works
package_name=my-pkg: rejected by the validator
the CI steps, replayed locally: no Jinja leaks, hooks and tests pass, the update leaves a clean tree
How to test or reproduce ? 🧪
uvx copier copy --defaults --vcs-ref copier-template -d project_name="Test Project" gh:PovertyAction/ipa-python-template test-project
cd test-project
git init && just venv && git add -A && git commit -m init
just check-all
just update-template
Please also try the root README as if you were new to it. The goal is that someone unfamiliar with git can follow it.
After merge (manual steps)
Tag v1.0.0 on main. copier update follows tags; until then users see "No git tags found; using HEAD".
Turn off the GitHub "Template repository" flag (gh repo edit --template=false). The button would copy unrendered .jinja files.
Post the recommendation on the Asana task.
Checklist ✅
I have run and tested my changes locally
I have limited this PR to less than 1000 lines of code change (if not, explain why)
I have updated/added tests to cover my changes (if applicable): template CI renders and tests the output
I have updated/added requirements to cover my changes (if applicable)
I have run linting and formatting on any code changes (if applicable)
I have updated the documentation (README, etc.) accordingly
Reviewer Emoji Legend
:code:
Meaning
😃👍💯
:smiley::+1::100:
I like this...
...and I want the author to know it! This is a way to highlight positive parts of a code review.
⭐⭐⭐
:star: :star: :star:
Important to fix before PR can be approved...
And I am providing reasons why it needs to be addressed as well as suggested improvements.
⭐⭐
:star: :star:
Important to fix but non-blocking for PR approval...
And I am providing suggestions where it could be improved either in this PR or later.
⭐
:star:
Give this some thought but non-blocking for PR approval...
...and consider this a suggestion, not a requirement.
❓
:question:
I have a question.
This should be a fully formed question with sufficient information and context that requires a response.
📝
:memo:
This is an explanatory note, fun fact, or relevant commentary that does not require any action.
⛏
:pick:
This is a nitpick.
This does not require any changes and is often better left unsaid. This may include stylistic, formatting, or organization suggestions and should likely be prevented/enforced by linting if they really matter
♻️
:recycle:
Suggestion for refactoring.
Should include enough context to be actionable and not be considered a nitpick.
Move project files into template/ (copier _subdirectory), template the
project name, package name, description, and Python version, and record
answers in .copier-answers.yml. Add a just update-template recipe that
wraps copier update with plain-language guidance. Stop shipping uv.lock;
generated projects create their own on first just get-started.
Co-Authored-By: Claude <noreply@anthropic.com>
Add a root README that walks IPA staff through creating a project with
copier, pulling template updates, resolving conflicts, and linking
projects made from the old GitHub template. Add template CI that renders
the template and runs the generated project's checks and an update.
Ship .gitattributes (eol=lf) so updates on Windows do not turn every
line into a conflict.
Co-Authored-By: Claude <noreply@anthropic.com>
- CI: render from an absolute template path. copier stores the source
path in .copier-answers.yml, so '.' made copier update look inside the
generated project (Unknown revision error). Same fix in maintainer docs.
- CI: test both Python version choices (3.12, 3.13).
- Generated ci.yml: take the Python version from .python-version instead
of hard-coding 3.12, so 3.13 projects can sync.
- project_slug: must end with a letter or number (valid distribution
name); default now strips punctuation from the project name.
- package_name: reject Python keywords such as class.
- Serialize project_name and description with to_json so quotes and
backslashes produce valid YAML and TOML.
Co-Authored-By: Claude <noreply@anthropic.com>
Addressed the Copilot review in 3c4d91b (replies inline). Also fixed the point from the review summary: the generated project's ci.yml no longer hard-codes Python 3.12. setup-uv/uv now read .python-version, and template CI runs the full render → checks → update cycle for both 3.12 and 3.13.
CI failure (Unknown revision in the update step): CI rendered with copier copy ... . "$RUNNER_TEMP/out". copier records the source path in .copier-answers.yml, so _src_path: . made copier update look for the template inside the generated project. CI now passes "$GITHUB_WORKSPACE", and the maintainer docs use "$PWD" with a note explaining why. Template CI is now green on 3.12 and 3.13.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The template still contains an actionable contact placeholder and several inaccurate setup/documentation instructions that could mislead or block users of generated projects.
No open issues 🎉
3 previously missed issues
In code that hasn't changed since last review
Clarify that uv.lock is generated during setup
template/README.md.jinja:15
This layout promises that uv.lock is part of every generated project, but this template intentionally ships no lockfile and uv sync creates it during just get-started. New users will look for a file that does not exist until setup runs; label it as generated by just get-started (or otherwise explain that it is not shipped).
Mac/Linux setup does not install Quarto
template/README.md.jinja:39
The Mac/Linux install command does not install Quarto, although the following text says this setup installs it and the project exposes preview-docs/build-docs recipes. A fresh Mac/Linux project therefore cannot use its documented documentation commands; add the appropriate Quarto installation commands or remove that claim.
Document the correct Bash activation path
template/README.md.jinja:84
On macOS/Linux, Bash uses .venv/bin/activate, but this table documents the Windows Scripts path. Following these instructions on a Unix machine will fail even after just get-started; use the Unix path for Bash and document the Windows Git Bash case separately if needed.
- Note that uv.lock is created by `just get-started`, not shipped
- Add Quarto install steps for Mac and Linux
- Split venv activation commands by OS (bin vs Scripts)
Addressed the 3 previously missed issues from the follow-up review in 8b4e1dd (template/README.md.jinja):
uv.lock: the layout comment now says it is created by just get-started (and should be committed), since the template ships no lockfile.
Quarto on Mac/Linux: split the install table. Mac adds brew install --cask quarto; Linux links to the Quarto installer page (Homebrew casks are macOS-only).
venv activation: the table now has Mac/Linux (.venv/bin/...) and Windows (.venv/Scripts/...) columns for Bash, PowerShell, and Nushell.
Checked by rendering a project with copier and running the project's panache format / panache lint on the generated README (no issues).
Not changed yet: template/.github/CODE_OF_CONDUCT still has [INSERT CONTACT METHOD], pending a decision on the reporting contact.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Summary 🚀
What does this PR do? 📝
Converts the template to copier, so projects created from it can pull later template updates with one command:
just update-template.copier.ymlasks five questions: project name, slug, package name, description, and Python version. The questions include help text and validators, and the suggested defaults work if users just press Enter.template/holds every file a new project gets. Only the files that need an answer use.jinja:pyproject.toml,README.md, the docs titles,.python-version, the test import, and thesrc/{{ package_name }}/folder name. TheJustfileand workflows stay plain so their own{{ }}syntax is untouched.just update-template(Windows and Mac/Linux) checks that the user's work is committed, runscopier update, lists the changed files, and says what to do next in plain language..gitattributes(eol=lf) fixes a Windows problem. Git for Windows' defaultcore.autocrlf=trueturned every changed file into a single whole-file conflict on update. With.gitattributes, conflicts cover only the lines that actually changed.[tool.uv.build-backend] module-namefixes a crash.uv_buildlooks for the package under the project name, so builds broke whenever a user picked a package name that differed from the slug.uv.lockis shipped. Each project creates its own lock file on the firstjust get-started.template-ci.yml) renders the template, checks that no Jinja leaked into the output, runs the generated project's pre-commit hooks and tests, then runscopier updateand checks that it leaves no changes. The root has its own zizmor and check-yaml hooks, and Dependabot (with a 7-day cooldown) watches actions in/and/template.Why is this change needed? 🤔
Asana: Evaluate a template update mechanism (cookiecutter or similar) for all templates.
Projects created with GitHub's "Use this template" button get a one-time copy. Fixes like the zizmor hardening and the security bumps in #15 never reach them.
{{cookiecutter.x}}/foldersuvx, no installRecommendation for the Stata, R and PPI templates: use the same pattern: copier with
_subdirectory: template, a few questions,.gitattributeswitheol=lf, ajust update-templaterecipe, and CI that renders the template and tests the result. copier runs throughuvx, so Stata and R users need no Python project of their own.How was this implemented? 🛠️
git mvkeeps the file history. I followed the docs literally on Windows, in fresh temp folders, for each path:git init→just venv→ first commit: all hooks pass on the first tryjust update-templatewith unsaved work: refuses, with a friendly message.copier-answers.ymlis bumpedbefore updating= yours = VS Code "Current";after updating= template = "Incoming")copier copy --overwrite, then renormalizing: tests pass, and a laterjust update-templateworkspackage_name=my-pkg: rejected by the validatorHow to test or reproduce ? 🧪
Please also try the root README as if you were new to it. The goal is that someone unfamiliar with git can follow it.
After merge (manual steps)
v1.0.0onmain.copier updatefollows tags; until then users see "No git tags found; using HEAD".gh repo edit --template=false). The button would copy unrendered.jinjafiles.Checklist ✅
Reviewer Emoji Legend
:code::smiley::+1::100:...and I want the author to know it! This is a way to highlight positive parts of a code review.
:star: :star: :star:And I am providing reasons why it needs to be addressed as well as suggested improvements.
:star: :star:And I am providing suggestions where it could be improved either in this PR or later.
:star:...and consider this a suggestion, not a requirement.
:question:This should be a fully formed question with sufficient information and context that requires a response.
:memo::pick:This does not require any changes and is often better left unsaid. This may include stylistic, formatting, or organization suggestions and should likely be prevented/enforced by linting if they really matter
:recycle:Should include enough context to be actionable and not be considered a nitpick.