Steps for new Python library or package

Here are the steps.

Create repo on github with license, gitignore and readme stubs.

Clone the repo in the work area.

Lets say, my new library is called new-library

new-library is the repo name.

Inside the cloned repo, create virtual env by running:
pipenv install --python 3.8

Above step creates a virtualenv using python 3.8 (already installed on my system)

now install all the required packages. The basic ones I always install are:
pytest, pytest-cov, typing, codecov, mypy and flake8

pipenv shell

pipenv install pytest pytest-cov typing codecov mypy flake8


# IDE dirs

to .gitignore

create a directory called new-library (inside the directory new-library .. this is also the repo). Inside this, create a file called new-library is now a Python package. I tend to have my blank.

lets create a file called inside this directory so that we have something to work with.

Now lets create a tests directory right under the repo directory (called new-library). This tests directory is at the same level as .gitignore and files.
Inside this directory, create Then create a file called

Now create a .coveragerc file to configure code coverage. This file is also at the root level (same level as .gitignore)

Now create a setup.cfg file where you can put configuration details. Again at the root.

Now create a file. Again at root level.

Now, lastly create .travis.yml file. Again at root level.

Don’t forget to register and enable the repo in Travis CI dashboard before checking in the project. Now, after you check in all changes to github, you will see that build gets triggered in travis.

locally, you can run the tests with coverage using:
pytest --cov=new-library tests/

You can check the compile with type safety:
mypy new-library --ignore-missing-imports

You can check linting:
flake8 new-library

No Comments

You can leave the first : )

Leave a Reply

Your email address will not be published. Required fields are marked *