0Pricing
Python Academy · Lesson

Project Structure and pyproject.toml

Lay out a package.

Why Package Your Code

A script lives on your machine; a package can be installed by anyone with pip install. Packaging turns a folder of code into a distributable, versioned, reusable unit.

The first step is a clean project layout and a configuration file.

The src Layout

The recommended structure puts your importable code under a src/ directory:

  • src/mypackage/__init__.py
  • src/mypackage/core.py
  • pyproject.toml
  • README.md and tests/

The src layout prevents accidentally importing your code from the project root instead of the installed copy.

All lessons in this course

  1. Project Structure and pyproject.toml
  2. Building with build
  3. Versioning and Metadata
  4. Publishing with twine
← Back to Python Academy