Package, test and release a Python library
8 steps · about 4 h 35 min · Intermediate
- Build a minimal package (guide, Python Packaging User Guide, 40 min)
Create a standard source layout and project metadata.
- Write project metadata (guide, Python Packaging User Guide, 40 min)
Declare builds, dependencies and package information clearly.
- Choose a source layout (guide, Python Packaging User Guide, 25 min)
Prevent accidental imports from hiding packaging errors.
- Test in an isolated environment (guide, Python documentation, 30 min)
Keep package tests independent of global installations.
- Add focused tests (guide, pytest documentation, 35 min)
Protect public behaviour before distributing the package.
- Build distribution files (guide, Python Packaging User Guide, 40 min)
Produce source and wheel artifacts using standard tools.
- Practise on TestPyPI (guide, Python Packaging User Guide, 30 min)
Check upload and installation before a real release.
- Understand trusted publishing (guide, Python Packaging User Guide, 35 min)
Use short-lived trusted identities instead of long-lived upload secrets.