Package, test and release a Python library

8 steps · about 4 h 35 min · Intermediate

  1. Build a minimal package (guide, Python Packaging User Guide, 40 min)

    Create a standard source layout and project metadata.

  2. Write project metadata (guide, Python Packaging User Guide, 40 min)

    Declare builds, dependencies and package information clearly.

  3. Choose a source layout (guide, Python Packaging User Guide, 25 min)

    Prevent accidental imports from hiding packaging errors.

  4. Test in an isolated environment (guide, Python documentation, 30 min)

    Keep package tests independent of global installations.

  5. Add focused tests (guide, pytest documentation, 35 min)

    Protect public behaviour before distributing the package.

  6. Build distribution files (guide, Python Packaging User Guide, 40 min)

    Produce source and wheel artifacts using standard tools.

  7. Practise on TestPyPI (guide, Python Packaging User Guide, 30 min)

    Check upload and installation before a real release.

  8. Understand trusted publishing (guide, Python Packaging User Guide, 35 min)

    Use short-lived trusted identities instead of long-lived upload secrets.