GuideAdvanced

Python Packaging And Cli Tools

A script that "works on my machine" and an installable package someone else can actually use are two very different things, and this guide walks you from one to the other step by step. You work by packaging a single realistic case — `reservo`, a coworking room-booking system whose object model already exists — and turn it into an installable library with its own command-line tool. You'll learn what a module and a package are, how `import` and `sys.path` resolve, the modern `pyproject.toml` standard (PEP 621) and how to build a real wheel and sdist with `uv build`, how to isolate a project in virtual environments and manage dependencies with `pip` and `uv`, how to build a complete CLI with `argparse` (no external dependencies), how to expose it as an installed command via an entry point in `[project.scripts]`, how to structure a real package with submodules, relative imports, and a deliberate public API, and how to configure a quality toolchain (`ruff`, `mypy`, `pytest`, `pre-commit`). Everything runnable actually runs — the `reservo price --tier basic --hours 3` command prints `7500` from your terminal — the only thing taught as content without execution is publishing to PyPI, because that's a public, irreversible action. The final project integrates all seven pieces into a complete package, built, installed, and running end to end.

64
lessons
8
modules
English · Spanish
available in
Yes
certificate
Free
access
NIEVA

Outcomes

What you'll be able to do

  • Distinguish a module from a package, understand what `__init__.py` does, and how Python resolves an `import` through `sys.path`
  • Write a complete `pyproject.toml` following PEP 621 (metadata, dependencies, build backend) and build a real wheel and sdist with `uv build`
  • Isolate a project in a virtual environment, manage dependencies with `pip` and `uv`, pin versions for reproducibility, and install in editable mode
  • Build a complete command-line interface with `argparse`: subcommands, positional arguments and options, auto-generated help, and exit codes
  • Expose a `main()` function as an installed PATH command via an entry point (`[project.scripts]`), and understand how the generated wrapper script works
  • Apply semantic versioning and know the full distribution flow to PyPI/TestPyPI with `twine`
  • Structure a real package into submodules with clear responsibilities, relative imports, `__main__.py`, and a one-way dependency (the CLI calls the library, never the reverse)
  • Declare a deliberate public API with `__all__` and re-export it in `__init__.py`, and give `__version__` a single source of truth
  • Configure a modern quality toolchain (`ruff` for lint and format, `mypy` for types, `pytest` wired in, `pre-commit` to automate it)
  • Integrate every piece into a complete distributable package, built, installed, and verified with the CLI running from the PATH

Before you start

What you need to bring

It's for you if...

  • Intermediate-level Python developers who've only written standalone scripts and never turned their code into an installable package
  • Devs who want to give their own tool a professional command-line interface, with subcommands and auto-generated help
  • People who need to understand `pyproject.toml` thoroughly because they see it in every modern project but never wrote one from scratch
  • Anyone who wants to publish their first library to PyPI and wants to know the full flow before doing it for real
  • Whoever maintains a single-file package that outgrew itself and needs a clear framework for structuring it into submodules

Requirements and materials

  • Basic Python syntax: variables, functions, dictionaries, lists, control flow, and knowing how to write and run a `.py` file
  • Minimal notions of classes (mastering object-oriented design is not required)
  • Python 3.14 installed and a terminal
  • No need to have used `pip`, `venv`, `uv`, or any packaging tool before: everything is explained from scratch

Content

The syllabus, module by module

Open any of them to see its lessons.

Common questions

What people usually ask

Start whenever you like

Reviews

What students say

These reviews are from enrolled students who completed at least 50% of the course. We moderate reviews only on content grounds (spam, offensive language, personal data), never for being critical or negative.

No approved reviews yet.

Be the first to share your experience!