0 Where it starts
Build it yourself. Read the tutorial is the other way to read this part.
just setuptally is a uv project with one command, tally, which has nothing to count yet. just setup makes the
environment of the project, .venv, with uv sync. Run the command, to see where we begin.
uv run tallyIt prints tally: nothing to count yet.
Check your files against this part. The command prints nothing when they match, and otherwise shows what differs:
git check 6a63758166d3If you are stuck, this command puts the files of this part in place of yours. A file that you made yourself stays:
git rm -rq --cached --ignore-unmatch -- :/ && git restore --source 6a63758166d3 --staged --worktree -- :/What changed
.gitignore: the files that git does not hold, such as.venv. New, 10 lines. The file..python-version: the version of Python that uv uses. New, 1 line. The file.README.md: one line about tally. New, 3 lines. The file.justfile: the recipes, withsetupfirst. New, 15 lines. The file.pyproject.toml: the project, and the table[project.scripts]that makes the commandtally. New, 14 lines. The file.- look at
tally = "tally:main"
- look at
src/tally/__init__.py:main, which has nothing to count yet. New, 5 lines. The file.src/tally/__main__.py: letspython -m tallyrunmaintoo. New, 3 lines. The file.uv.lock: the exact packages, the same for every learner. New, 8 lines. The file.
The diff of .gitignore
@@ -0,0 +1,10 @@
+# Python-generated files
+__pycache__/
+*.py[oc]
+build/
+dist/
+wheels/
+*.egg-info
+
+# Virtual environments
+.venvThe diff of .python-version
@@ -0,0 +1 @@
+3.12The diff of README.md
@@ -0,0 +1,3 @@
+# tally
+
+Count the words in a text.The diff of justfile
@@ -0,0 +1,15 @@
+# The recipes of tally. Each one runs through uv, in the project's own environment.
+default:
+ @just --list
+
+# Make the environment of this step: the first command of every step
+setup:
+ uv sync
+
+# Count the words of a file
+run file:
+ uv run tally {{ file }}
+
+# Run the tests
+test:
+ uv run python -m unittest discover -s tests -qThe diff of pyproject.toml
@@ -0,0 +1,14 @@
+[project]
+name = "tally"
+version = "0.1.0"
+description = "Count the words in a text"
+readme = "README.md"
+requires-python = ">=3.12"
+dependencies = []
+
+[project.scripts]
+tally = "tally:main"
+
+[build-system]
+requires = ["uv_build>=0.12.13,<0.13.0"]
+build-backend = "uv_build"The diff of src/tally/__init__.py
@@ -0,0 +1,5 @@
+"""tally: count the words in a text."""
+
+
+def main() -> None:
+ print("tally: nothing to count yet")The diff of src/tally/__main__.py
@@ -0,0 +1,3 @@
+from tally import main
+
+main()