You want to make a python package available on
PyPi without spending ages to learn how to do it ?
If you are using
GitHub to host your project, this article is for you !
Create your setup.py file
Every python package needs a
setup.py file to be deployed with
You can use a
setup.py example available on Django website to create yours.
GitHub repository seems like:
+-- my_python_package <-- The package you want to deploy on PyPi
Configure Travis CI
You need to configure
Tracis CI to use continuous integration for your
If it's your first time, go to Tracis CI, sign-in with
GitHub, and activate your
GitHub repository (
Travis CI has access to your repositories, but they are disabled by default).
Then add a
.travis.yml file, on your
GitHub repository root, with this content:
- touch foo
For now, your
Travis CI configuration is executing something totally useless (
touch foo) on each commit, but usually people are using it to run tests.
Configure PyPi deployment with travis-ci
Now we also want our project to be deployed on
Travis CI can do that for us if we add a
deploy section in
.travis.yml, that is now:
- touch foo
With that configuration, this project will be deployed on
Pypi with user
romgar and password
my_secure_password, but only when you create (and push) new tags on
Get PyPi deployment credentials
user name is the one you have used to register on Pypi. Yes, you have to create an account on
You also need to replace
my_secure_password with your secure password, generated with
Travis CI command line client.
To install it (more details on Travis blog):
Maybe you will miss rdoc gem in some cases, depending on your OS. Just install it before:
Then encrypt your PyPi password with
$ travis encrypt --add deploy.password
The generated password will be automatically added to your
.travis.yml config file.
At the end, you have a repository that is automatically deploying a new version of your python package each time you add a new tag on
master !! Well done.
There are comments.