0 The project

Build it yourself. Read the tutorial is the other way to read this part.

This walk goes through rahuldave/cheesecracker on GitHub. This part is where the project starts, at step-00. The code of this part

The project starts empty, with a pyproject.toml, a lockfile and a justfile. The next sections give it code and tests.

just setup

Two tools run everything in this project, uv and just.

uv manages a Python project. It installs Python, and the packages that the project needs, into the folder .venv of the project. pyproject.toml lists the packages, and uv.lock holds the exact version of each. So every machine gets the same versions.

uv run CMD runs a command with that Python and those packages. uv is written in Rust by Astral. It does the work of several older Python tools, such as pip, which installs packages.

just runs the commands of a project by short names. Each name is a recipe in the file justfile, with the commands that it runs. just NAME runs a recipe, and just alone lists them. A recipe keeps a long command in one place, so everyone on the project runs it by the same short name.

The project is empty. It has a pyproject.toml with no dependencies, an empty uv.lock, a README.md, a .gitignore, and a justfile with one recipe, setup. just setup runs uv sync --locked. The command makes the folder .venv, with Python 3.12 and every package of uv.lock in it.

Run it a second time. With nothing new in uv.lock, it changes nothing.

just setup

uv prints Resolved 1 package and Checked, and no line Creating virtual environment.

Two settings of pyproject.toml, in the table [tool.uv], matter for the whole project. package = false says that cheesecracker is an application. uv installs its dependencies, and does not install the project as a package. default-groups = "all" makes uv sync and uv run install every group of dependencies, such as the tools of the tests.

just --list

just --list prints the one recipe, setup, with its comment.

Check your files against this part. The command prints nothing when they match, and otherwise shows what differs:

git check cf50a6ef5045

If you are stuck, this command puts the files of this part in place of yours. A file that you made yourself stays:

git fetch --quiet --tags --force origin; git rm -rq --cached --ignore-unmatch -- :/ && git restore --source step-00 --staged --worktree -- :/

What changed

  • .gitignore: the environment, the caches of the tools, and the secrets, which git never takes. New, 21 lines. The file
  • .python-version: the version of Python that uv installs, 3.12. New, 1 line. The file
  • README.md: what the project is, and how to set it up. New, 14 lines. The file
  • justfile: the recipe setup, and default, which lists the recipes. New, 12 lines. The file
    • look at uv sync --locked
  • pyproject.toml: the name of the project, no dependencies yet, and the table [tool.uv]. New, 13 lines. The file
    • look at default-groups = "all"
  • uv.lock: the lockfile, with the project and no packages yet. New, 8 lines. The file

The diff of .gitignore
@@ -0,0 +1,21 @@
+# Python
+__pycache__/
+*.py[cod]
+.venv/
+
+# What the tests and the coverage write
+.pytest_cache/
+.coverage
+htmlcov/
+.ruff_cache/
+
+# Secrets: never commit them
+secrets/
+.env
+*.key
+*.pem
+
+# The editor and the system
+.vscode/
+.idea/
+.DS_Store

The diff of .python-version
@@ -0,0 +1 @@
+3.12

The diff of README.md
@@ -0,0 +1,14 @@
+# cheesecracker
+
+cheesecracker is the API server of the Cheese App, a class project of AC215. The server answers a few HTTP
+requests. The project shows how to test a server, check its code, and run it in Docker.
+
+## Run it
+
+You need [uv](https://docs.astral.sh/uv/) and [just](https://just.systems/). Then run:
+
+```
+just setup
+```
+
+`just` lists every recipe of the project.

The diff of justfile
@@ -0,0 +1,12 @@
+# cheesecracker: every task is a recipe here. `just` lists them.
+
+# Each word after a recipe's name reaches its commands whole, as "$1", "$2" and so on; "$@" is all of them
+set positional-arguments
+
+[private]
+default:
+    @just --list --unsorted
+
+# Install Python and every dependency into .venv, exactly as the lockfile says
+setup:
+    uv sync --locked

The diff of pyproject.toml
@@ -0,0 +1,13 @@
+[project]
+name = "cheesecracker"
+version = "0.1.0"
+description = "The Cheese App's API server, with its tests, its checks and its Docker images"
+readme = "README.md"
+requires-python = ">=3.12"
+dependencies = []
+
+[tool.uv]
+# The project is an application, not a library: uv installs its dependencies, and not the project itself
+package = false
+# uv sync and uv run install every dependency group, not only dev
+default-groups = "all"