Skip to main content
Albero Academy

Packaging

Structure a project and declare dependencies with pyproject.toml.

Production9 min

To share code — with teammates, a server, or the world (PyPI) — you package it. A packaged project has a standard layout and a pyproject.toml that declares its metadata and dependencies, so anyone can install it reproducibly with pip.

pyproject.toml

This single file is the modern standard for project configuration — metadata, dependencies, and the build system:

pyproject.toml
[project]
name = "albero-tools"
version = "0.1.0"
requires-python = ">=3.10"
dependencies = ["requests>=2.31", "pandas"]
[project.scripts]
albero = "albero_tools.cli:main" # a command-line entry point
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

Project layout & building

the src layout
albero-tools/
├── pyproject.toml
├── src/albero_tools/
│ ├── __init__.py
│ └── cli.py
└── tests/
# build a distributable, then install it
python -m build
pip install .

Key takeaways

  1. 01pyproject.toml is the modern file for project metadata, dependencies and build config.
  2. 02Declare dependencies with sensible version ranges; add entry points under [project.scripts].
  3. 03The src/ layout keeps imports clean and catches packaging errors.
  4. 04python -m build produces installable artifacts; pip install . installs locally.

Finished this chapter?

Mark it complete to track your progress through Python.