How to add badges in your pypi project

1. pypi badge

To get the pypi badge, go to page and enter the name of a valid package. Select the code you’d like to insert into your documentation (e.g., RST) and you check get a image like this:

2. Number of downloads

Nothing special to do here. Use the link and append your package name.

3. Continuous integration on Travis

This one is definitely the most difficult but also the most rewarding since you will be able to test your entire software and coverage on different distributions.

First, open an account on . It is quite straightforward to synchronise your github with travis. You will see all your repositories and will need to specify those you want to include into the build process. To do so, cick on the repository of your choice in the

For a build to start, you will need to commit/push a change in the github and a file in your repository (same level as and README.rst) called .travis.yml

You can check that the syntax of your file is correct using travis-lint executable.

 travis-lint .travis.yml

This executable can be installed easily using the gem utility:

gem install travis-lint

Here is an example of such as file:

language: python
  - "3.3"
  - "2.7"
  - "2.6"
  - "export DISPLAY=:99.0"
  - "sh -e /etc/init.d/xvfb start"
# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
  - pip install .
  - pip install nose coverage
  - pip install coveralls
# # command to run tests, e.g. python test
  - python nosetests --with-coverage --cover-package pypiview

From now one, each time you commit/push a change travis will start a new build. If you do not want to trigger a new build (because you’ve just change a print statement), include this line into your commit statement:

[ci skip]

If you want coverage (next section), you need to use the script and after_sucess sections otherwise just comment or remove them.

Note also that if you use matplotlib in your test, the build may fails with an error related to the DISPLAY. This is the reason for the before_install section and the statement related to the DISPLAY.

Having your first build to pass without errors may take you some time and iterations… Finally, you’ll get a badge as follows

4. Coverage

Once you’ve managed to have a succesfuly build on Travis, it is time to look at the coverage. This is very important that the build succeeded otherwise, this step will not work.

Go to, create an account and add your github directory. You may need to synchronise your repo.
There, click on an icon called (view on coveralls) on the same line as your pacakge. In the new page, look for the repo token
, which is a list of random character and number. Keep it for later.

You will need to trigger travis CI by committed some changes.

this should then trigger the coveralls website where the badge should now be ready.

THere is another way, which is more manual; I did not manage but instructions are See for help.

The final badge looks like:


an easy one now. Get a badge for the quality of your code (style) by joining landscape website

add the repository you wish to test going to the bottom of this page


Another easy one is the task badge from waffle. Open an account and then go to

Update pypi

Finally, you need to update your README.rst , which should be in your github repository with the following code (adapted to your needs of course)

.. image::
.. image::
.. image::
.. image:: 
.. image::
.. image:: 
Please follow and like us:
This entry was posted in Python. Bookmark the permalink.

3 Responses to How to add badges in your pypi project

Leave a Reply

Your email address will not be published.