Speedup python cli projects

27 Oct, 2022
Xebia Background Header Wave

Use our python-cli-tool cookiecutter project. Get an python cli project up and running in a few steps. In my previous speedup-event-driven-projects blog. I wrote how you could use cookiecutter to spin up an event driven project for AWS. In this blog post I will show you how you could do this for python cli projects.

For this blog post I assume that you have the following installed:

  • python3
  • cookiecutter
  • poetry

Lets create an cli project

We will begin with executing the cookiecutter command:

cookiecutter gh:binxio/python-cli-tool

Screenshot of the commands being executed

Cookiecutter will create a folder based on the project_name. In this folder you now only need to install the dependencies. You can use the following command:

make install

The install target of the Makefile will:

  • Perform a poetry init, this will create the pyproject.toml file.
  • Create git repository and install the pre-commit hooks.
  • Perform a poetry install. This will install all project dependencies based on the pyproject.toml file.
  • Adds extra configuration to the pyproject.toml file.
  • Commits everything to the git repository.

You will end up with something like this:

Screenshot of the project tree structure

The project itself has unit testing in-place:

Screenshot of the tests running

And you can test your cli tool as well by executing the commands through poetry:

Screenshot of the CLI tool in action

Now it’s time to configure your remote GitHub repository:

git remote add origin
git branch -M main
git push -u origin main
git checkout -b develop
git push --set-upstream origin develop

We pushed the main branch to the remote and created a develop branch as a working branch.

The project itself contains the following workflows:

  • Continuous Integration, checks when you push to main or open a pull request to develop.
  • Create Release, creates an release for you when you merge to main and uploads it to (You need to configure a PYPI_API_TOKEN secret in GitHub for this to work)
  • Release Notes, creates a proposal for your release notes. This is based on your merged pull requests. So make sure you use correct messages.


By using the python-cli-tool cookiecutter project you will speedup your python cli project!

And you can focus on what matters! Your business logic!

Photo by Ekaterina Belinskaya

Joris Conijn
Joris has been working with the AWS cloud since 2009 and focussing on building event driven architectures. While working with the cloud from (almost) the start he has seen most of the services being launched. Joris strongly believes in automation and infrastructure as code and is open to learn new things and experiment with them, because that is the way to learn and grow. In his spare time he enjoys running and runs a small micro brewery from his home.

Get in touch with us to learn more about the subject and related solutions

Explore related posts