CLI journal project (6/6): package, pyproject, and shipping
Finish pyproject.toml, the journal-stats script entry, the README, tests, and a trial upload to TestPyPI. Twelve exercises before you ship the CLI.
Getting started
Home Assistant
Buying
Finish pyproject.toml, the journal-stats script entry, the README, tests, and a trial upload to TestPyPI. Twelve exercises before you ship the CLI.


AI-generated illustration
Some links on this page are affiliate links. The button opens Amazon so you can check today’s price.
Finish pyproject.toml: a [project] table with name = "journal-stats" (change the name if it is already taken on PyPI), version, requires-python, dependencies, and [project.scripts] so journal-stats = "journal_stats.cli:main". Use a src/journal_stats/ tree for the src layout.
python -m build produces a wheel and an sdist; twine upload dist/* sends them to TestPyPI for a trial. The README documents installation, an example journal-stats analyze a.log b.log, the --async / --no-async options, and --json for machine-readable output.
The packaging lesson is pyproject.toml. Project hub: advanced Python journal CLI.
Exercise 1 — A [project.scripts] table for journal-stats. Easy
[project.scripts]
journal-stats = "journal_stats.cli:main"
Exercise 2 — packages = { find = {} } under [tool.setuptools] with where = ["src"]. Intermediate
[tool.setuptools.packages.find]
where = ["src"]
Exercise 3 — pip install -e . then journal-stats --help. Easy
.venv\Scripts\activate ; pip install -e . ; journal-stats --help
Exercise 4 — [project.optional-dependencies]: a dev extra with mypy, pytest, and ruff. Intermediate
[project.optional-dependencies]
dev = ["mypy>=1.8", "pytest>=8", "ruff>=0.3"]
Exercise 5 — python -m build needs the build package. Easy
pip install build
Exercise 6 — twine check dist/* — what it does. Intermediate
Checks the README long description and the metadata.
Exercise 7 — [project.urls] for Home and Repository. Easy
[project.urls]
Homepage = "https://example.org"
Repository = "https://github.com/..."
Exercise 8 — Do not publish secrets from .pypirc — where do you store them? Hard
~/.pypirc outside the repo; CI secret tokens.
Exercise 9 — uvx or pipx install for an isolated CLI — the advantage. Intermediate
One environment per tool, without polluting the system Python.
Exercise 10 — A CHANGELOG.md — the first 0.1.0 entry. Easy
## 0.1.0
- Multi-file analysis, stats by level, optional JSON output.
Exercise 11 — Compare this project with the planner project — a skill that is new here. Easy
A personal answer — asyncio, strict typing, packaging.
Exercise 12 — Keep going toward open-source contributions — a suggestion. Intermediate
Pick a good first issue on a typed Python project.
You now have the through-line for a complete log tool: generators, decorators, asyncio plus an executor, typing, and a package. Adapt the line format to your real files.
Was this page helpful?
Thank you!
What should we improve?
Torn between two models or stuck on a build? Drop us a line and we will get back to you by email.
Cookies and analytics
We use Google Analytics 4 to understand how the site is used (page views, navigation). It is only switched on if you accept. Declining does not stop you using the site. More: cookie settings and privacy policy (in French).