I use cookiecutter to start almost all of my Python projects. It helps me quickly generate a skeleton of a project with my preferred directory structu

Simon Willison’s Weblog

submited by
Style Pass
2024-04-26 12:00:02

I use cookiecutter to start almost all of my Python projects. It helps me quickly generate a skeleton of a project with my preferred directory structure and configured tools.

I made some major upgrades to my python-lib cookiecutter template today. Here’s what it can now do to help you get started with a new Python library:

The changes I made today are that I switched from setup.py to pyproject.toml, and I made a big improvement to how the publishing workflow authenticates with PyPI.

My previous version of this template required you to jump through quite a few hoops to get PyPI publishing to work. You needed to create a PyPI token that could publish a new package, then paste that token into a GitHub Actions secret, then publish the package, and then disable that token and create a new one dedicated to just updating this package in the future.

To publish a new package, you need to sign into PyPI and create a new “pending publisher”. Effectively you tell PyPI "My GitHub repository myname/name-of-repo should be allowed to publish packages with the name name-of-package".

Leave a Comment