PyPI deployment in 5 minutes with github-logo travis-logo

Presenter Notes

Me (Romain Garrigues @rgarrigues)

Presenter Notes

The goal

x Be able to install your_lovely_package with pip

1 $ pip install your_lovely_package

x Easily deploy a new release on PyPI, for example by pushing a tag on master branch.

Presenter Notes

GitHub: Your project

github-defaultproject

You only need:

  • Your django app (python package)
  • README to describe your project
  • setup.py to describe your python package

Presenter Notes

GitHub: Setup file

Example:

 1 import os
 2 from setuptools import setup
 3 
 4 setup(
 5     name='your-lovely-package',
 6     version='0.1',
 7     packages=['your_lovely_package'],
 8     include_package_data=True,
 9     license='BSD License',  # example license
10     description='A simple lovely package.',
11     long_description='You could read README file and put it there',
12     url='https://github.com/romgar/your-lovely-package',
13     author='Romain Garrigues',
14     author_email='romain.garrigues.cs@gmail.com',
15     classifiers=[
16         'Framework :: Django',
17     ],
18 )

Presenter Notes

Travis CI : Create an account

  • Continuous integration platform for GitHub projects @ https://travis-ci.org/
  • Trigger scripts on every commit on every branch of your GitHub projects

travis-landing_page

Presenter Notes

Travis CI: Link GitHub account

github-login

Presenter Notes

Travis CI: Activate GitHub repositories

https://travis-ci.org/profile/romgar

travis-activate_repo

Presenter Notes

GitHub: configure travis

Create a .travis.yml file on your GitHub repository root folder:

1 language: python
2 
3 python:
4   - "2.7"
5 
6 script:
7   - touch foo

Presenter Notes

GitHub: deploy section in Travis CI config

 1 language: python
 2 
 3 python:
 4     - "2.7"
 5 
 6 script:
 7     - touch foo
 8 
 9 deploy:
10     provider: pypi
11     user: romgar   <--- your PyPI username
12     password:
13         secure: my_secure_password <--- to be generated
14     on:
15         tags: true
16         branch: master

Presenter Notes

GitHub: generate secure password

1 $ gem install travis
2 $ travis encrypt --add deploy.password

The generated password will be automatically added to your .travis.yml config file.

Presenter Notes

Summary

  • Create a GitHub repository with your package, a README and a setup.py file,
  • Activate Continuous Integration of this repository on Travis CI,
  • Create a .travis.yml, with a deploy section,
  • Generate secure password,
  • Push files, and deploy it automatically on PyPI depending on conditions,
  • Well done !!!
  • Every step explained in details @ 5minutes.youkidea.com

Presenter Notes