Publish your open-source project TODAY!
I want to show you how you can start and publish an open-source library in under 24 hours.
You can use existing tools and best practices to publish your work, even if you’re a novice python developer.
Figure out what your project is about: it can be a simple and trivial piece of code or a sophisticated framework. In my latest open-source project, the gist was to expose functionality through a pytest fixture in a few dozen lines of code shown in my previous post.
Create the project using the python-package-template: it’s pretty self-explanatory, see the video below or enter the project home page.
Edit the created project:
Your project is almost ready, and now you have to customize it:
- Add your code and tests.
- Push your project into GitHub according to the template instructions.
- Set up the publishing to PyPI:
- If you haven’t signed up for PyPI, do it now: sign up for free for the test PyPI and production PyPI.
- Create API tokens for both the test and production PyPI. API tokens are under Account Settings.
- Save the tokens you created as GitHub secrets named
Add the secrets inside the GitHub project
settings -> secrets -> actions.
- Copy the publish-to-pypi.yml file from my repository into yours. Unfortunately, the template doesn’t include this bit out of the box, but you can add it yourself: copy the actions file and replace
pytest-fastapi-depswith your project name.
3. Optional: remove/carve out stuff you don’t need from the template project. For example, you might want to remove the docker configuration if you don’t plan on releasing a docker image of your project, or perhaps you don’t want the automatic package dependency bot to run every day (you can change it to run once a month or disable it entirely).
Publish to PyPI
Remember to update the project version in pyproject.toml. Every time you push new code into a feature branch, the action would push your new code into the test PyPI. And when you release a tag — the code would be pushed into the actual production PyPI everyone uses!
You're done! In a matter of a few easy steps and a couple of hours, you can have your python project available for everyone.
Ping me if you have encountered any issues during this tutorial or if you have cool ideas for an open-source project that you want help with.