Convert your template
With pytemplate-uv 3.8 and later, a Copier or cookiecutter template can become a pack without a rewrite from scratch. This page is for template authors. Read Template packs for the layout a pack needs, and Publish a pack to list the result.
Conversion keeps your template's files and most of its questions. The checks decide what remains to
fix: run pack check after each step, and fix what it reports.
Copier
A Copier template is adapted in place. Work in a copy of the template's repository.
-
Add
pytemplate-pack.tomlat the root, withcontract = 1, anid,name,description,version, andcategories(see Publish a pack). -
Add a
profile.tomlfor each profile, withname,description, andkind(cli,library, orservice).pytemplate schema profileprints the full format. Its lifecycle commands must start withuv, such asuv syncanduv run pytest. -
Run the check and fix what it refuses:
uvx pytemplate-uv@latest pack check . --lifecycle
The check refuses these Copier settings, because they run code or read data outside the template:
_tasks: remove them. A check the project should run belongs in the lifecycle commands, which must start withuv._jinja_extensions: remove them, and rewrite the templates that used them with the built-in filters._migrations: remove them. Packs do not run migrations._external_data, and any symlink or git submodule: copy the content into the template instead.
Run pack check --lifecycle again until it passes.
cookiecutter
A cookiecutter template is rewritten, and the pytemplate-author skill can do the rewrite with you. The changes are:
- Each
cookiecutter.xvariable becomesx, in file names, folder names, and template text. For example,{{ cookiecutter.project_name }}becomes{{ project_name }}. - The questions in
cookiecutter.jsonmove toquestions.yml. - Hooks never run: pytemplate does not run
hooks/pre_gen_project.pyorhooks/post_gen_project.py. Turn what a hook did into a question or a component, or drop it, and delete thehooks/folder. - The layout becomes a pack: a profile folder with its
profile.tomlandtemplate/, as in Template packs.
Then run pack check --lifecycle as above.
Keep the license and credit
The template's license and copyright lines stay. Keep its LICENSE file, and its copyright notices in
the source files. In the pack's README, say "adapted from" the original, with its tag and commit. A pack you adapt must not use the original's name or branding
for itself; give the pack its own id and name.
Test the result
Render a project under a new name, and run its tests:
uvx pytemplate-uv@latest create new-name -p PROFILE --template ./my-pack -y
cd new-name && uv sync && uv run pytest
A pack is ready to list when each profile renders, its tests pass in a project made from it, and
pack check --lifecycle reports no errors.