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__.pysrc/mypackage/core.pypyproject.tomlREADME.mdandtests/
The src layout prevents accidentally importing your code from the project root instead of the installed copy.
All lessons in this course
- Project Structure and pyproject.toml
- Building with build
- Versioning and Metadata
- Publishing with twine