A course as a pack

With pytemplate-uv 3.8 and later, an instructor can turn an assignment's starter project into a template pack. Each student then creates their copy with one uvx command, and gets the same Python version, libraries, and tests as everyone else in the course. This page is for instructors. Read Template packs for the format, and Make a pack with an agent if you want help making the pack.

1. Start from the assignment's project

Begin with a project that works: the starter code, the tests that define "done", and a pyproject.toml that names the libraries the course uses. Run uv sync and uv run pytest in it first.

Then make it a pack, in one of two ways:

  • From a project. uvx pytemplate-uv@latest pack from-project SRC DEST --project-name NAME copies only the files that git tracks, leaves out .env files, keys, and uv.lock, and reports what it did. Read the report before you hand the pack out.
  • From scratch. uvx pytemplate-uv@latest pack init DIR writes a minimal pack with one profile. Copy your starter files into its template folder.

Use a name for the project that students will recognize, such as week-3-scraper, and check that no name from your own machine or course system is left in it.

2. Check the pack

uvx pytemplate-uv@latest pack check ./week-3-pack --lifecycle --forbid old-project-name

--lifecycle runs the pack's own checks, so it runs the pack's code; run it on your own machine, on the pack you wrote. A lifecycle command that fails fails the check.

3. Publish the pack for students

Put the pack in a git repository, and tag a release. Students need two things: the repository and the tag, plus the commit and digest that pin the exact files:

uvx pytemplate-uv@latest create week-3 --template gh:ORG/week-3-pack \
  --template-ref v1.0.0 --template-commit <commit> --template-digest <digest> -p PROFILE -y

Replace ORG, the tag, the commit, the digest, and PROFILE (the pack's profile id) with your own. The commit is the one the tag points to, and the digest is computed over its files; Pin a pack and the digest explain them. Pinning keeps every student on the same files, even if you change the pack later. Publish a new tag for a change.

Students then run:

cd week-3 && uv sync && uv run pytest

Their project has the Python version, libraries, and tests your profile declares. A course does not need a hub listing: the pack is named by its repository and pins, not by the hub.

Notes for the course

  • Students need network access once, for uv sync and the first run of uvx.
  • Only the instructor changes the pack. Students work in their own generated project, which they commit to their own repository.
  • A pack that renders is not a pack that teaches well. Run the tests yourself, in a clean project, before each term.

Edit this page on GitHub