Uncle Sam: I want you to Publish your open-source project TODAY!

Publish your open-source project TODAY!

Peter Kogan
3 min readJun 19, 2022

--

This is a follow-up story on how to create and maintain an open-source project and my new FastAPI dependency library.

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.

Getting Started

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.

Creating a project using python-package-template

Edit the created project:

Your project is almost ready, and now you have to customize it:

  1. Add your code and tests.
  2. Push your project into GitHub according to the template instructions.
  3. 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 TEST_PYPI_PASSWORD and PROD_PYPI_PASSWORD.
    Add the secrets inside the GitHub project settings -> secrets -> actions.
GitHub Action Secrets for PyPI publishing
  • 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_deps and pytest-fastapi-deps with 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!

pytest-fastapi-deps version history

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.

--

--