Skip to content
Tutorials Center
My learning

Topics

Python Packaging and Tooling Tutorial

Learn Python Packaging and Tooling step by step: 38 lessons in 9 chapters with examples, quizzes, diagrams and projects.

Start learning →

of lessons completed

Getting Started

  1. 1 What Is Python Packaging? Understand modules, packages, distributions, wheels, sdists and PyPI, and how a folder of code becomes something other people can install with one command.
  2. 2 Modules, Packages and the Import System See how Python finds modules with sys.path, how packages and __init__.py work, and build a real package on disk and import it live in the browser.
  3. 3 Installing Packages with pip Learn the everyday pip commands, version specifiers, extras and requirements files, plus how installers resolve dependencies, with live micropip examples.
  4. 4 Wheels, Sdists and the Package Index Decode wheel filenames and compatibility tags, understand why wheels install faster than sdists, and see how PyPI and the simple index serve both formats.
  5. 5 The Python Tooling Landscape A clear map of pip, venv, uv, pipx, Poetry, Hatch, PDM, setuptools and friends: what each does, how they overlap, and how to choose for your project.

Virtual Environments

  1. 6 Why Virtual Environments? Learn the problem virtual environments solve, how sys.prefix and site-packages change inside one, and why every project deserves its own isolated environment.
  2. 7 Creating Environments with venv Create and use virtual environments with python -m venv, activate them on every shell, read pyvenv.cfg, and understand virtualenv and common mistakes.
  3. 8 uv and Modern Environment Management Use uv to install Python versions, create environments, add dependencies and run commands, and learn how its lock file works with a live parsing example.
  4. 9 Freezing Requirements and Reproducibility Learn what pip freeze records, how requirements.in and pinned files work, why hashes and constraints matter, and build a requirements file checker live.

pyproject and Metadata

  1. 10 pyproject.toml Basics Learn the structure of pyproject.toml, its three standard tables, TOML syntax and how to read and validate one with tomllib, step by step with live code.
  2. 11 Project Metadata Fields Fill in the [project] table correctly: names, versions, authors, license expressions, classifiers, URLs, optional dependencies and how they become core metadata.
  3. 12 Version Specifiers and Environment Markers Master PEP 440 versions, pre-releases, compatible release (~=), specifier sets and environment markers using the packaging library with live examples.
  4. 13 Build Backends Compared Understand the PEP 517 build interface and compare setuptools, hatchling, flit-core, pdm-backend, maturin and scikit-build-core, with configuration examples for each.
  5. 14 src Layout and Package Data Compare src and flat project layouts, learn how packages are discovered, include data files, and read them reliably with importlib.resources, with live examples.

Building and Publishing

  1. 15 Building an sdist and a Wheel Run python -m build, inspect wheel and sdist contents, and create a real wheel by hand with zipfile, RECORD hashes and dist-info, then install it live.
  2. 16 Entry Points and Command-Line Tools Turn functions into installed commands with project.scripts, support python -m, build plugin systems with entry point groups, and read them with importlib.metadata.
  3. 17 Versioning and Changelogs Choose between semantic and calendar versioning, keep one source of truth for the version, derive it from Git tags, and write a useful changelog, with live code.
  4. 18 Publishing to PyPI Upload your package safely: check distributions, try TestPyPI, use twine or uv publish, set up trusted publishing from GitHub Actions, and follow a release checklist.

Dependency Management

  1. 19 Version Specifiers and PEP 440 Learn how Python versions are written and compared, how specifiers like ~=, >=, <, != and == work, and how to test them with the packaging library.
  2. 20 Resolving Dependencies and Conflicts Understand how pip and uv resolve a dependency graph, why conflicts happen, how to read the error messages, and how to fix them with a tiny working resolver.
  3. 21 Lock Files and Reproducible Installs Learn why Python projects need lock files, how pip freeze, pip-compile, uv lock and Poetry produce them, and how hash checking makes installs reproducible.
  4. 22 pip, uv, Poetry and PDM Compared Compare pip, uv, Poetry, PDM and pipenv for Python dependency management, learn dependency groups from PEP 735, and pick the right tool for your project.
  5. 23 Updating and Auditing Dependencies Keep Python dependencies current and safe with outdated checks, pip-audit, Dependabot and Renovate, and learn to read vulnerability advisories with working code.

Linting, Types and Formatting

  1. 24 Linting with Ruff and Pyflakes Catch bugs and style problems automatically in Python. Learn what a linter checks, run pyflakes and pycodestyle for real, and configure Ruff in pyproject.toml.
  2. 25 Formatting with Black and Ruff Format End style debates with an automatic Python formatter. Run Black for real, learn the magic trailing comma and line length, and configure Black or ruff format.
  3. 26 Type Checking with mypy Find bugs before running code with Python type hints and mypy. Run mypy for real, learn strict mode, Optional narrowing, config in pyproject.toml and py.typed.
  4. 27 pre-commit Hooks for Python Projects Run linters and formatters automatically before every commit. Learn the .pre-commit-config.yaml format, common hooks, CI usage, and see a working hook runner.

Testing and CI

  1. 28 Testing a Package with pytest Test your Python package properly with pytest. Learn the src layout, fixtures, parametrization, pytest settings in pyproject.toml, and testing the installed package.
  2. 29 Coverage, tox and nox Measure which lines your tests run with coverage.py, then test across Python versions with tox or nox. Includes a real coverage run and a tox matrix expander.
  3. 30 GitHub Actions for Python Projects Set up continuous integration for a Python package with GitHub Actions. Learn workflows, jobs, matrices, caching, artifacts and permissions, and check a workflow with code.
  4. 31 Release Automation and Trusted Publishing Automate Python package releases safely. Version bumps, changelogs, release checks, and publishing to PyPI from GitHub Actions with trusted publishing instead of tokens.

Distribution and Docker

  1. 32 Docker Images for Python Applications Build small, fast, secure Docker images for Python applications. Layer caching, multi-stage builds, non-root users, uv and pip installs, plus a Dockerfile linter and cache simulator.
  2. 33 Zipapps and Standalone Executables Distribute Python command-line apps without asking users to set up environments. Build a real zipapp, learn entry points, pipx, uv tool, shiv, pex and PyInstaller.
  3. 34 Private Indexes, Mirrors and Vendoring Host internal Python packages and install offline. Learn the PEP 503 simple index, index-url vs extra-index-url, dependency confusion, wheelhouses and vendoring, with runnable examples.

Projects and Practice

  1. 35 Project: Publish a Command-Line Package Put the whole course together. Create a command-line package, test it, build a wheel by hand to see what is inside, install it, and prepare the release workflow.
  2. 36 Project: Build a Mini Dependency Resolver Build a working dependency resolver in Python with extras, markers, backtracking, clear conflict messages and a hash-pinned requirements output, using the packaging library.
  3. 37 Project: Package Health Checker Build a package health checker that validates pyproject.toml metadata, version, requirements, classifiers and project layout, then wire it into pre-commit and CI as a release gate.
  4. 38 Practice: Packaging Problems and Fixes Practice diagnosing real packaging problems: ModuleNotFoundError, missing data files, wrong versions, stale environments and build failures, with runnable reproductions and exercises.