SlideShare a Scribd company logo
1 of 64
Download to read offline
Open source projects
with Python
Thomas Aglassinger
http://roskakori.at
https://github.com/roskakori/talks/linuxtage
@TAglassinger
Version 1.0.1
About me
● 1995: first open source commit
● 2001: master's degree in information processing science
(Oulu, Finland)
● 2001: Systema Human Information Systems (Steyr, Austria)
● 2004: Raiffeisen Rechenzentrum (Graz, Austria)
● “Casual” open source developer; Open Hub commit history:
Goals
● Beginning from an empty folder a small open
source project is published.
● The project uses Python as programming
language.
● The project is easy to setup and maintain.
● The project is easy to contribute to.
● The project uses quality oriented approach and
utilizes modern tools and best practices.
Intended audience
● Developers who intend to start an open source
project
● People who are already working on open
source Projects in Python
● Anyone who wants to understand the
processes and tools in the background of an
open source project
Topics
●
Naming and licensing a project
●
The sample project: dividemo
●
Version management
●
Project structure
●
Writing a REAME
●
Build process
●
Testing and continuous integration
●
Version numbering
●
Static code checks
●
Merging contributions
●
Documentation
●
Launcher scripts
●
Publishing
Naming and licensing
Naming a project
● No http://<project>.com
● No clashes with existing open source projects:
https://github.com/LogIN-/ospnc
● Other considerations:
https://www.farbeyondcode.com/Choosing-a-name-for-your-open-source-project--5-2700.html
Licensing
● Many licenses to choose from: http://opensource.org/licenses
● Basic choices: http://choosealicense.com/
● Popular:
– GNU General Public License (GPL)
– GNU Library General Public License (LGPL)
– Apache License
– MIT License
– BSD License
● For our simple example program: BSD License
The project: dividemo
Dividemo
Command line tool to divide two integer numbers
and print the result to the standard output:
$ python dividemo.py 8 2
4
$ python dividemo.py 11 3
3
$ python dividemo.py 11 three
usage: dividemo.py [-h] DIVIDEND DIVISOR
dividemo.py: error: argument DIVISOR: invalid int value: 'three'
Source Code
import argparse
import math
import sys
def divided(dividend, divisor):
return dividend // divisor # //=integer division
def main(arguments):
# Parse command line arguments.
parser = argparse.ArgumentParser(description='divide two integer numbers.')
parser.add_argument('dividend', metavar='DIVIDEND', type=int, help='number to divide')
parser.add_argument('divisor', metavar='DIVISOR', type=int,help='number to divide by')
args = parser.parse_args(arguments)
# Process arguments and print result.
result = divided(args.dividend, args.divisor)
print(result)
if __name__ == '__main__':
main(sys.argv[1:])
Store the source code
$ cd ~/workspace # (or something the like)
$ mkdir --parents dividemo/dividemo
$ $EDITOR dividemo/dividemo/dividemo.py
Version management
Version management - goals
● Changes can be tracked
● Other people can easily contribute
● Improvements can be merged easily
● Mistakes in the code can be undone by
reverting to a working version
Popular services
● https://github.com
● https://bitbucket.com
● http://sourceforge.net
Create a project on Github
Project repository URL
● Depend on username and project name
● https://github.com/roskakori/dividemo.git
Project structure
Project structure
● “5 Simple Rules For Building Great Python
Packages”:
http://axialcorps.com/2013/08/29/5-simple-rules-for-building-great-python-packages/
● Pyscaffold can help to putup a new project from
scratch: https://pypi.python.org/pypi/pyscaffold
Pyscaffold
● Builds a scaffold for a new project
● Preconfigures helpful utilities
$ cd ~/workspace # (or something the like)
$ putup --description "divide two integer
numbers" --url
https://github.com/roskakori/dividemo
--license "simple-bsd" --with-travis --with-tox
dividemo --force
Connect with Github
$ git remote add origin
https://github.com/roskakori/dividemo.git
$ git push -u origin master
To avoid entering the Github password on each
push:
https://help.github.com/articles/generating-ssh-keys/
...and the result:
Writing a README
● Should contain:
– Short summary of use
– Possibly a concise example
– Reference to license, documentation, source code
– Where to get support? (email, issue tracker)
● For small applications: README = documentation
● Format: ReStructured Text or Markdown
● Online editor: http://rst.ninjs.org/
README.rst
Dividemo
========
Dividemo is a command line tool that divides two integer numbers and prints the result in the console.
Example::
$ dividemo 11 4
2
For more information, visit https://dividemo.readthedocs.org.
To get support, open an issue at https://github.com/roskakori/dividemo/issues.
The source code is available from https://github.com/roskakori/dividemo.
License
-------
Copyright (c) 2015, Thomas Aglassinger. Distributed under the BSD license. See LICENSE.txt for more information.
Build process
Setup.py (1/2)
● Acts both as
– Installer
– Build tool
● Supported by standard library (distutil)
● Most things are are simple declarations (e.g. license,
author, dependencies)
● If necessary, all functions of the Python library can be
used
→ no limited “scripting language” like make, ant, ...
Setup.py (2/2)
● Has several built in commands, e.g. build and
install the package
● External packages can add additional
commands (e.g. pip, wheel)
● You can also add your own commands
→ pure Python code directly in setup.py
Build package
● python setup.py sdist
build source distribution as *.tar.gz
● python setup.py sdist --formats=zip
build source distribution as *.zip
● Python setup.by bdist_wheel
build binary distribution as wheel;
requires wheel package, see
https://pypi.python.org/pypi/wheel
requirements.txt
● Describes dependencies to other Python
packages that need to be installed
● Simple syntax; one line per package
● Example: requests >= 2.6.2
→ requires requests package, version 2.6.2 or
later
● Pip automatically installs packages described in
requirements.txt
Installation
● python setup.py develop
“Install” current development source code
(make it part of PYTHONPATH)
● python setup.py install
Install package in current virtualenv, see
https://pypi.python.org/pypi/virtualenv
● sudo python setup.py install
Install package in system folders
Testing
A test program
import unittest
from dividemo import dividemo
class DividemoTest(unittest.TestCase):
def test_can_divide(self):
self.assertEqual(2, dividemo.divided(10, 5))
def test_can_print_divided(self):
dividemo.main(['10', '5'])
def test_fails_on_non_integer_divisor(self):
self.assertRaises(SystemExit, dividemo.main, ['10', 'hello'])
Run test suite
● Requires configuration or automatic
configuration by PyScaffold
● python setup.py test
Runs test suite, reports result and builds HTML
report about test coverage
● Coverage reports is located in folder “htmlcov”.
Continuous integration
● After each push to the version management repository, run the
test suite → make you aware of new bugs early
● Travis - https://travis-ci.org/
– Github informs Travis about new push
– Travis runs tests
– If tests fail, Travis sends e-mail
– Test log is available online
● Jenkins - http://jenkins-ci.org/
– Can be deployed locally
– Python setup:
http://www.alexconrad.org/2011/10/jenkins-and-python.html
.travis.yml
language: python
sudo: true
virtualenv:
system_site_packages: true
env:
matrix:
- DISTRIB="ubuntu" PYTHON_VERSION="2.7" COVERAGE="true"
- DISTRIB="conda" PYTHON_VERSION="2.7" COVERAGE="false"
- DISTRIB="conda" PYTHON_VERSION="3.3" COVERAGE="false"
- DISTRIB="conda" PYTHON_VERSION="3.4" COVERAGE="false"
install:
- source tests/travis_install.sh
- pip install -r requirements.txt
before_script:
- git config --global user.email "roskakori@users.sourceforge.net"
- git config --global user.name "Thomas Aglassinger"
script:
- python setup.py test
after_success:
- if [[ "$COVERAGE" == "true" ]]; then coveralls || echo "failed"; fi
cache:
- apt
Activate travis
● Visit https://travis-ci.org/profile
● Click
● Enable project:
Coveralls
● Online test coverage reports
● Add a repository: https://coveralls.io/repos/new
● (even for open source repos)
●
Time to git push!
Version numbering
Pythoner version numbering
● Guidelines: “PEP 440 - Version Identification
and Dependency Specification”
https://www.python.org/dev/peps/pep-0440/
● Easy but cumbersome: manual maintenance in
__init__.py: __version__ = '1.2.3'
Version numbering with Pyscaffold
“Magic” in _version.py:
$ python
>>> from dividemo import _version
>>> _version.get_version()['version']
'0.0.post0.dev2+g8cdc4ea'
Advancing the version
Add a new git tag:
$ git tag -a -m "Tagged version 0.1.0." v0.1.0
$ git push --tags
Trove classifiers
● Describe package
● Make it easier for users to find it
● Available classifiers:
https://pypi.python.org/pypi?%3Aaction=list_classifiers
Add trove classifiers
● Setup.py
● With Pyscaffold: setup.cfg
Dividemo trove classifiers
classifiers = Development Status :: 4 - Beta,
Environment :: Console,
License :: OSI Approved :: BSD License,
Operating System :: OS Independent,
Programming Language :: Python,
Programming Language :: Python :: 2,
Programming Language :: Python :: 3,
Topic :: Utilities
Meanwhile...
Travis finished
Static code checks
Static code checks
● Identify possibly issues by scanning the source
code
● PEP8 Style guide for Python code
http://legacy.python.org/dev/peps/pep-0008/
● “Code smells”, e.g. unreachable or unused
code
● Intended to improve general code quality and
simplify maintenance
flake8
● Finds formatting issues and a few code smells
● Pragmatic and low volume
$ tox -e flake8
dividemo/dividemo.py:5:1: F401 'math' imported but unused
dividemo/dividemo.py:11:1: E302 expected 2 blank lines, found 1
dividemo/dividemo.py:14:80: E501 line too long (90 > 79 characters)
dividemo/dividemo.py:15:64: E231 missing whitespace after ','
...
Pylint
● http://www.pylint.org/
● Provides many checks
● Default setting: very verbose, lots of noise
● Simple front end: https://landscape.io/
● Based on prospector
https://pypi.python.org/pypi/prospector
Managing contributions
Pull requests
● Feature of Github and Bitbucket
● Makes it easy to review, iterate and merge
changes from another fork
● Sadly no live presentation due lack of time
ggg:-(
Documentation
Sphinx documentation
● “Sphinx is a tool that makes it easy to create
intelligent and beautiful documentation”
● http://sphinx-doc.org
● Based on ReStructured Text markup
● Easy linking and cross referencing
● Automatically builds index and search page
● Extract API documentation from source code
Sphinx configuration
● docs/conf.py
● Manually: docs/Makefile
● Pyscaffold:
● Possibly have to set theme in conf.py:
html_theme = 'default'
● Possibly trim option intersphinx_mapping
● HTML results are located in “docs/_build/html”
$ python setup.py docs
Publishing the documentation
● https://readthedocs.org
● After push to repository, rebuild and publish the
documentation
● Dashboard > Import a project > From Github
● Wait for build to finish
● Read it at https://dividemo.readthedocs.org
Launcher script
Launcher scripts
● To just run “dividemo” instead of “python ...”
● Add pointer to main() function in setup.cfg:
[console_scripts]
dividemo = dividemo.dividemo:main
Publish to the
Python Package Index (PyPI)
PyPI first time setup
● Prepare ~/.pypirc:
● Register you project:
[distutils]
index-servers=pypi
[pypi]
repository=https://pypi.python.org/pypi
username=roskakori
password=.....
$ python setup.py register
Publish a new version
$ git tag -a -m "Tagged version 1.0.0." v1.0.0
$ git push –tags
$ python setup.py sdist --formats=zip upload
Summary
Summary
● Many helpful tools for Python projects
– Flake8, git, pip, Pyscaffold, sphinx
● Many helpful services
– Coveralls, Github, PyPI, Readthedocs, Travis
● Easy collaboration with Github and Pull
requests
● Python is fun!

More Related Content

What's hot

Go lang introduction
Go lang introductionGo lang introduction
Go lang introductionyangwm
 
Dive into Pinkoi 2013
Dive into Pinkoi 2013Dive into Pinkoi 2013
Dive into Pinkoi 2013Mosky Liu
 
Writing multi-language documentation using Sphinx
Writing multi-language documentation using SphinxWriting multi-language documentation using Sphinx
Writing multi-language documentation using SphinxMarkus Zapke-Gründemann
 
10 reasons to be excited about go
10 reasons to be excited about go10 reasons to be excited about go
10 reasons to be excited about goDvir Volk
 
Introduction to IPython & Notebook
Introduction to IPython & NotebookIntroduction to IPython & Notebook
Introduction to IPython & NotebookAreski Belaid
 
Introduction to Python for Bioinformatics
Introduction to Python for BioinformaticsIntroduction to Python for Bioinformatics
Introduction to Python for BioinformaticsJosé Héctor Gálvez
 
Django Seminar 08/17/2013
Django Seminar 08/17/2013Django Seminar 08/17/2013
Django Seminar 08/17/2013Trinh Nguyen
 
Practicing Python 3
Practicing Python 3Practicing Python 3
Practicing Python 3Mosky Liu
 
Puppet Systems Infrastructure Construction Kit
Puppet Systems Infrastructure Construction KitPuppet Systems Infrastructure Construction Kit
Puppet Systems Infrastructure Construction KitAlessandro Franceschi
 
Introduction to Clime
Introduction to ClimeIntroduction to Clime
Introduction to ClimeMosky Liu
 
Data analytics in the cloud with Jupyter notebooks.
Data analytics in the cloud with Jupyter notebooks.Data analytics in the cloud with Jupyter notebooks.
Data analytics in the cloud with Jupyter notebooks.Graham Dumpleton
 
Reversing the dropbox client on windows
Reversing the dropbox client on windowsReversing the dropbox client on windows
Reversing the dropbox client on windowsextremecoders
 
Easy contributable internationalization process with Sphinx @ pyconmy2015
Easy contributable internationalization process with Sphinx @ pyconmy2015Easy contributable internationalization process with Sphinx @ pyconmy2015
Easy contributable internationalization process with Sphinx @ pyconmy2015Takayuki Shimizukawa
 
Introduction to go language programming
Introduction to go language programmingIntroduction to go language programming
Introduction to go language programmingMahmoud Masih Tehrani
 
Happy Go Programming Part 1
Happy Go Programming Part 1Happy Go Programming Part 1
Happy Go Programming Part 1Lin Yo-An
 
Learning Python from Data
Learning Python from DataLearning Python from Data
Learning Python from DataMosky Liu
 

What's hot (20)

Go. Why it goes
Go. Why it goesGo. Why it goes
Go. Why it goes
 
Go lang introduction
Go lang introductionGo lang introduction
Go lang introduction
 
Dive into Pinkoi 2013
Dive into Pinkoi 2013Dive into Pinkoi 2013
Dive into Pinkoi 2013
 
Writing multi-language documentation using Sphinx
Writing multi-language documentation using SphinxWriting multi-language documentation using Sphinx
Writing multi-language documentation using Sphinx
 
10 reasons to be excited about go
10 reasons to be excited about go10 reasons to be excited about go
10 reasons to be excited about go
 
Introduction to IPython & Notebook
Introduction to IPython & NotebookIntroduction to IPython & Notebook
Introduction to IPython & Notebook
 
Module net cdf4
Module net cdf4 Module net cdf4
Module net cdf4
 
Introduction to Python for Bioinformatics
Introduction to Python for BioinformaticsIntroduction to Python for Bioinformatics
Introduction to Python for Bioinformatics
 
Django Seminar 08/17/2013
Django Seminar 08/17/2013Django Seminar 08/17/2013
Django Seminar 08/17/2013
 
Python arch wiki
Python   arch wikiPython   arch wiki
Python arch wiki
 
Practicing Python 3
Practicing Python 3Practicing Python 3
Practicing Python 3
 
Puppet Systems Infrastructure Construction Kit
Puppet Systems Infrastructure Construction KitPuppet Systems Infrastructure Construction Kit
Puppet Systems Infrastructure Construction Kit
 
Introduction to Clime
Introduction to ClimeIntroduction to Clime
Introduction to Clime
 
Data analytics in the cloud with Jupyter notebooks.
Data analytics in the cloud with Jupyter notebooks.Data analytics in the cloud with Jupyter notebooks.
Data analytics in the cloud with Jupyter notebooks.
 
Reversing the dropbox client on windows
Reversing the dropbox client on windowsReversing the dropbox client on windows
Reversing the dropbox client on windows
 
Easy contributable internationalization process with Sphinx @ pyconmy2015
Easy contributable internationalization process with Sphinx @ pyconmy2015Easy contributable internationalization process with Sphinx @ pyconmy2015
Easy contributable internationalization process with Sphinx @ pyconmy2015
 
Easy native wrappers with SWIG
Easy native wrappers with SWIGEasy native wrappers with SWIG
Easy native wrappers with SWIG
 
Introduction to go language programming
Introduction to go language programmingIntroduction to go language programming
Introduction to go language programming
 
Happy Go Programming Part 1
Happy Go Programming Part 1Happy Go Programming Part 1
Happy Go Programming Part 1
 
Learning Python from Data
Learning Python from DataLearning Python from Data
Learning Python from Data
 

Similar to Open source projects with python

EuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingEuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingAlessandro Molina
 
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides:  Let's build macOS CLI Utilities using SwiftMobileConf 2021 Slides:  Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides: Let's build macOS CLI Utilities using SwiftDiego Freniche Brito
 
Let's build Developer Portal with Backstage
Let's build Developer Portal with BackstageLet's build Developer Portal with Backstage
Let's build Developer Portal with BackstageOpsta
 
Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...
Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...
Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...OpenShift Origin
 
Efficient development workflows with composer
Efficient development workflows with composerEfficient development workflows with composer
Efficient development workflows with composernuppla
 
My "Perfect" Toolchain Setup for Grails Projects
My "Perfect" Toolchain Setup for Grails ProjectsMy "Perfect" Toolchain Setup for Grails Projects
My "Perfect" Toolchain Setup for Grails ProjectsGR8Conf
 
How to plan and define your CI-CD pipeline
How to plan and define your CI-CD pipelineHow to plan and define your CI-CD pipeline
How to plan and define your CI-CD pipelineElasTest Project
 
PyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and MorePyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and MoreMatt Harrison
 
Tools for maintaining an open source project
Tools for maintaining an open source projectTools for maintaining an open source project
Tools for maintaining an open source projectAll Things Open
 
Improving Operations Efficiency with Puppet
Improving Operations Efficiency with PuppetImproving Operations Efficiency with Puppet
Improving Operations Efficiency with PuppetNicolas Brousse
 
Programming with Python - Basic
Programming with Python - BasicProgramming with Python - Basic
Programming with Python - BasicMosky Liu
 
NuGet beyond Hello World - DotNext Piter 2017
NuGet beyond Hello World - DotNext Piter 2017NuGet beyond Hello World - DotNext Piter 2017
NuGet beyond Hello World - DotNext Piter 2017Maarten Balliauw
 
OpenShift Origin Community Day (Boston) Extending OpenShift Origin: Build You...
OpenShift Origin Community Day (Boston) Extending OpenShift Origin: Build You...OpenShift Origin Community Day (Boston) Extending OpenShift Origin: Build You...
OpenShift Origin Community Day (Boston) Extending OpenShift Origin: Build You...OpenShift Origin
 
OpenShift Origin Community Day (Boston) Writing Cartridges V2 by Jhon Honce
OpenShift Origin Community Day (Boston) Writing Cartridges V2 by Jhon Honce OpenShift Origin Community Day (Boston) Writing Cartridges V2 by Jhon Honce
OpenShift Origin Community Day (Boston) Writing Cartridges V2 by Jhon Honce Diane Mueller
 
Helpful pre commit hooks for Python and Django
Helpful pre commit hooks for Python and DjangoHelpful pre commit hooks for Python and Django
Helpful pre commit hooks for Python and Djangoroskakori
 
Django dev-env-my-way
Django dev-env-my-wayDjango dev-env-my-way
Django dev-env-my-wayRobert Lujo
 
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud RunDesigning flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Runwesley chun
 

Similar to Open source projects with python (20)

EuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingEuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears Training
 
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides:  Let's build macOS CLI Utilities using SwiftMobileConf 2021 Slides:  Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
 
Let's build Developer Portal with Backstage
Let's build Developer Portal with BackstageLet's build Developer Portal with Backstage
Let's build Developer Portal with Backstage
 
Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...
Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...
Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...
 
Efficient development workflows with composer
Efficient development workflows with composerEfficient development workflows with composer
Efficient development workflows with composer
 
My "Perfect" Toolchain Setup for Grails Projects
My "Perfect" Toolchain Setup for Grails ProjectsMy "Perfect" Toolchain Setup for Grails Projects
My "Perfect" Toolchain Setup for Grails Projects
 
R sharing 101
R sharing 101R sharing 101
R sharing 101
 
How to plan and define your CI-CD pipeline
How to plan and define your CI-CD pipelineHow to plan and define your CI-CD pipeline
How to plan and define your CI-CD pipeline
 
PyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and MorePyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and More
 
Python Projects at Neova
Python Projects at NeovaPython Projects at Neova
Python Projects at Neova
 
Mono Repo
Mono RepoMono Repo
Mono Repo
 
Tools for maintaining an open source project
Tools for maintaining an open source projectTools for maintaining an open source project
Tools for maintaining an open source project
 
Improving Operations Efficiency with Puppet
Improving Operations Efficiency with PuppetImproving Operations Efficiency with Puppet
Improving Operations Efficiency with Puppet
 
Programming with Python - Basic
Programming with Python - BasicProgramming with Python - Basic
Programming with Python - Basic
 
NuGet beyond Hello World - DotNext Piter 2017
NuGet beyond Hello World - DotNext Piter 2017NuGet beyond Hello World - DotNext Piter 2017
NuGet beyond Hello World - DotNext Piter 2017
 
OpenShift Origin Community Day (Boston) Extending OpenShift Origin: Build You...
OpenShift Origin Community Day (Boston) Extending OpenShift Origin: Build You...OpenShift Origin Community Day (Boston) Extending OpenShift Origin: Build You...
OpenShift Origin Community Day (Boston) Extending OpenShift Origin: Build You...
 
OpenShift Origin Community Day (Boston) Writing Cartridges V2 by Jhon Honce
OpenShift Origin Community Day (Boston) Writing Cartridges V2 by Jhon Honce OpenShift Origin Community Day (Boston) Writing Cartridges V2 by Jhon Honce
OpenShift Origin Community Day (Boston) Writing Cartridges V2 by Jhon Honce
 
Helpful pre commit hooks for Python and Django
Helpful pre commit hooks for Python and DjangoHelpful pre commit hooks for Python and Django
Helpful pre commit hooks for Python and Django
 
Django dev-env-my-way
Django dev-env-my-wayDjango dev-env-my-way
Django dev-env-my-way
 
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud RunDesigning flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
 

More from roskakori

Expanding skill sets - Broaden your perspective on design
Expanding skill sets - Broaden your perspective on designExpanding skill sets - Broaden your perspective on design
Expanding skill sets - Broaden your perspective on designroskakori
 
Django trifft Flutter
Django trifft FlutterDjango trifft Flutter
Django trifft Flutterroskakori
 
Multiple django applications on a single server with nginx
Multiple django applications on a single server with nginxMultiple django applications on a single server with nginx
Multiple django applications on a single server with nginxroskakori
 
Startmeeting Interessengruppe NLP NLU Graz
Startmeeting Interessengruppe NLP NLU GrazStartmeeting Interessengruppe NLP NLU Graz
Startmeeting Interessengruppe NLP NLU Grazroskakori
 
Helpful logging with python
Helpful logging with pythonHelpful logging with python
Helpful logging with pythonroskakori
 
Helpful logging with Java
Helpful logging with JavaHelpful logging with Java
Helpful logging with Javaroskakori
 
Einführung in Kommunikation und Konfliktmanagement für Software-Entwickler
Einführung in Kommunikation und Konfliktmanagement für Software-EntwicklerEinführung in Kommunikation und Konfliktmanagement für Software-Entwickler
Einführung in Kommunikation und Konfliktmanagement für Software-Entwicklerroskakori
 
Analyzing natural language feedback using python
Analyzing natural language feedback using pythonAnalyzing natural language feedback using python
Analyzing natural language feedback using pythonroskakori
 
Microsoft SQL Server with Linux and Docker
Microsoft SQL Server with Linux and DockerMicrosoft SQL Server with Linux and Docker
Microsoft SQL Server with Linux and Dockerroskakori
 
Migration to Python 3 in Finance
Migration to Python 3 in FinanceMigration to Python 3 in Finance
Migration to Python 3 in Financeroskakori
 
Introduction to pygments
Introduction to pygmentsIntroduction to pygments
Introduction to pygmentsroskakori
 
Lösungsorientierte Fehlerbehandlung
Lösungsorientierte FehlerbehandlungLösungsorientierte Fehlerbehandlung
Lösungsorientierte Fehlerbehandlungroskakori
 
XML namespaces and XPath with Python
XML namespaces and XPath with PythonXML namespaces and XPath with Python
XML namespaces and XPath with Pythonroskakori
 
Erste-Hilfekasten für Unicode mit Python
Erste-Hilfekasten für Unicode mit PythonErste-Hilfekasten für Unicode mit Python
Erste-Hilfekasten für Unicode mit Pythonroskakori
 
Introduction to trader bots with Python
Introduction to trader bots with PythonIntroduction to trader bots with Python
Introduction to trader bots with Pythonroskakori
 
Python builds mit ant
Python builds mit antPython builds mit ant
Python builds mit antroskakori
 
Kanban zur Abwicklung von Reporting-Anforderungen
Kanban zur Abwicklung von Reporting-AnforderungenKanban zur Abwicklung von Reporting-Anforderungen
Kanban zur Abwicklung von Reporting-Anforderungenroskakori
 

More from roskakori (17)

Expanding skill sets - Broaden your perspective on design
Expanding skill sets - Broaden your perspective on designExpanding skill sets - Broaden your perspective on design
Expanding skill sets - Broaden your perspective on design
 
Django trifft Flutter
Django trifft FlutterDjango trifft Flutter
Django trifft Flutter
 
Multiple django applications on a single server with nginx
Multiple django applications on a single server with nginxMultiple django applications on a single server with nginx
Multiple django applications on a single server with nginx
 
Startmeeting Interessengruppe NLP NLU Graz
Startmeeting Interessengruppe NLP NLU GrazStartmeeting Interessengruppe NLP NLU Graz
Startmeeting Interessengruppe NLP NLU Graz
 
Helpful logging with python
Helpful logging with pythonHelpful logging with python
Helpful logging with python
 
Helpful logging with Java
Helpful logging with JavaHelpful logging with Java
Helpful logging with Java
 
Einführung in Kommunikation und Konfliktmanagement für Software-Entwickler
Einführung in Kommunikation und Konfliktmanagement für Software-EntwicklerEinführung in Kommunikation und Konfliktmanagement für Software-Entwickler
Einführung in Kommunikation und Konfliktmanagement für Software-Entwickler
 
Analyzing natural language feedback using python
Analyzing natural language feedback using pythonAnalyzing natural language feedback using python
Analyzing natural language feedback using python
 
Microsoft SQL Server with Linux and Docker
Microsoft SQL Server with Linux and DockerMicrosoft SQL Server with Linux and Docker
Microsoft SQL Server with Linux and Docker
 
Migration to Python 3 in Finance
Migration to Python 3 in FinanceMigration to Python 3 in Finance
Migration to Python 3 in Finance
 
Introduction to pygments
Introduction to pygmentsIntroduction to pygments
Introduction to pygments
 
Lösungsorientierte Fehlerbehandlung
Lösungsorientierte FehlerbehandlungLösungsorientierte Fehlerbehandlung
Lösungsorientierte Fehlerbehandlung
 
XML namespaces and XPath with Python
XML namespaces and XPath with PythonXML namespaces and XPath with Python
XML namespaces and XPath with Python
 
Erste-Hilfekasten für Unicode mit Python
Erste-Hilfekasten für Unicode mit PythonErste-Hilfekasten für Unicode mit Python
Erste-Hilfekasten für Unicode mit Python
 
Introduction to trader bots with Python
Introduction to trader bots with PythonIntroduction to trader bots with Python
Introduction to trader bots with Python
 
Python builds mit ant
Python builds mit antPython builds mit ant
Python builds mit ant
 
Kanban zur Abwicklung von Reporting-Anforderungen
Kanban zur Abwicklung von Reporting-AnforderungenKanban zur Abwicklung von Reporting-Anforderungen
Kanban zur Abwicklung von Reporting-Anforderungen
 

Recently uploaded

Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptcpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptrcbcrtm
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 

Recently uploaded (20)

Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptcpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.ppt
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 

Open source projects with python

  • 1. Open source projects with Python Thomas Aglassinger http://roskakori.at https://github.com/roskakori/talks/linuxtage @TAglassinger Version 1.0.1
  • 2. About me ● 1995: first open source commit ● 2001: master's degree in information processing science (Oulu, Finland) ● 2001: Systema Human Information Systems (Steyr, Austria) ● 2004: Raiffeisen Rechenzentrum (Graz, Austria) ● “Casual” open source developer; Open Hub commit history:
  • 3. Goals ● Beginning from an empty folder a small open source project is published. ● The project uses Python as programming language. ● The project is easy to setup and maintain. ● The project is easy to contribute to. ● The project uses quality oriented approach and utilizes modern tools and best practices.
  • 4. Intended audience ● Developers who intend to start an open source project ● People who are already working on open source Projects in Python ● Anyone who wants to understand the processes and tools in the background of an open source project
  • 5. Topics ● Naming and licensing a project ● The sample project: dividemo ● Version management ● Project structure ● Writing a REAME ● Build process ● Testing and continuous integration ● Version numbering ● Static code checks ● Merging contributions ● Documentation ● Launcher scripts ● Publishing
  • 7. Naming a project ● No http://<project>.com ● No clashes with existing open source projects: https://github.com/LogIN-/ospnc ● Other considerations: https://www.farbeyondcode.com/Choosing-a-name-for-your-open-source-project--5-2700.html
  • 8. Licensing ● Many licenses to choose from: http://opensource.org/licenses ● Basic choices: http://choosealicense.com/ ● Popular: – GNU General Public License (GPL) – GNU Library General Public License (LGPL) – Apache License – MIT License – BSD License ● For our simple example program: BSD License
  • 10. Dividemo Command line tool to divide two integer numbers and print the result to the standard output: $ python dividemo.py 8 2 4 $ python dividemo.py 11 3 3 $ python dividemo.py 11 three usage: dividemo.py [-h] DIVIDEND DIVISOR dividemo.py: error: argument DIVISOR: invalid int value: 'three'
  • 11. Source Code import argparse import math import sys def divided(dividend, divisor): return dividend // divisor # //=integer division def main(arguments): # Parse command line arguments. parser = argparse.ArgumentParser(description='divide two integer numbers.') parser.add_argument('dividend', metavar='DIVIDEND', type=int, help='number to divide') parser.add_argument('divisor', metavar='DIVISOR', type=int,help='number to divide by') args = parser.parse_args(arguments) # Process arguments and print result. result = divided(args.dividend, args.divisor) print(result) if __name__ == '__main__': main(sys.argv[1:])
  • 12. Store the source code $ cd ~/workspace # (or something the like) $ mkdir --parents dividemo/dividemo $ $EDITOR dividemo/dividemo/dividemo.py
  • 14. Version management - goals ● Changes can be tracked ● Other people can easily contribute ● Improvements can be merged easily ● Mistakes in the code can be undone by reverting to a working version
  • 15. Popular services ● https://github.com ● https://bitbucket.com ● http://sourceforge.net
  • 16. Create a project on Github
  • 17. Project repository URL ● Depend on username and project name ● https://github.com/roskakori/dividemo.git
  • 19. Project structure ● “5 Simple Rules For Building Great Python Packages”: http://axialcorps.com/2013/08/29/5-simple-rules-for-building-great-python-packages/ ● Pyscaffold can help to putup a new project from scratch: https://pypi.python.org/pypi/pyscaffold
  • 20. Pyscaffold ● Builds a scaffold for a new project ● Preconfigures helpful utilities $ cd ~/workspace # (or something the like) $ putup --description "divide two integer numbers" --url https://github.com/roskakori/dividemo --license "simple-bsd" --with-travis --with-tox dividemo --force
  • 21. Connect with Github $ git remote add origin https://github.com/roskakori/dividemo.git $ git push -u origin master To avoid entering the Github password on each push: https://help.github.com/articles/generating-ssh-keys/
  • 23. Writing a README ● Should contain: – Short summary of use – Possibly a concise example – Reference to license, documentation, source code – Where to get support? (email, issue tracker) ● For small applications: README = documentation ● Format: ReStructured Text or Markdown ● Online editor: http://rst.ninjs.org/
  • 24. README.rst Dividemo ======== Dividemo is a command line tool that divides two integer numbers and prints the result in the console. Example:: $ dividemo 11 4 2 For more information, visit https://dividemo.readthedocs.org. To get support, open an issue at https://github.com/roskakori/dividemo/issues. The source code is available from https://github.com/roskakori/dividemo. License ------- Copyright (c) 2015, Thomas Aglassinger. Distributed under the BSD license. See LICENSE.txt for more information.
  • 26. Setup.py (1/2) ● Acts both as – Installer – Build tool ● Supported by standard library (distutil) ● Most things are are simple declarations (e.g. license, author, dependencies) ● If necessary, all functions of the Python library can be used → no limited “scripting language” like make, ant, ...
  • 27. Setup.py (2/2) ● Has several built in commands, e.g. build and install the package ● External packages can add additional commands (e.g. pip, wheel) ● You can also add your own commands → pure Python code directly in setup.py
  • 28. Build package ● python setup.py sdist build source distribution as *.tar.gz ● python setup.py sdist --formats=zip build source distribution as *.zip ● Python setup.by bdist_wheel build binary distribution as wheel; requires wheel package, see https://pypi.python.org/pypi/wheel
  • 29. requirements.txt ● Describes dependencies to other Python packages that need to be installed ● Simple syntax; one line per package ● Example: requests >= 2.6.2 → requires requests package, version 2.6.2 or later ● Pip automatically installs packages described in requirements.txt
  • 30. Installation ● python setup.py develop “Install” current development source code (make it part of PYTHONPATH) ● python setup.py install Install package in current virtualenv, see https://pypi.python.org/pypi/virtualenv ● sudo python setup.py install Install package in system folders
  • 32. A test program import unittest from dividemo import dividemo class DividemoTest(unittest.TestCase): def test_can_divide(self): self.assertEqual(2, dividemo.divided(10, 5)) def test_can_print_divided(self): dividemo.main(['10', '5']) def test_fails_on_non_integer_divisor(self): self.assertRaises(SystemExit, dividemo.main, ['10', 'hello'])
  • 33. Run test suite ● Requires configuration or automatic configuration by PyScaffold ● python setup.py test Runs test suite, reports result and builds HTML report about test coverage ● Coverage reports is located in folder “htmlcov”.
  • 34. Continuous integration ● After each push to the version management repository, run the test suite → make you aware of new bugs early ● Travis - https://travis-ci.org/ – Github informs Travis about new push – Travis runs tests – If tests fail, Travis sends e-mail – Test log is available online ● Jenkins - http://jenkins-ci.org/ – Can be deployed locally – Python setup: http://www.alexconrad.org/2011/10/jenkins-and-python.html
  • 35. .travis.yml language: python sudo: true virtualenv: system_site_packages: true env: matrix: - DISTRIB="ubuntu" PYTHON_VERSION="2.7" COVERAGE="true" - DISTRIB="conda" PYTHON_VERSION="2.7" COVERAGE="false" - DISTRIB="conda" PYTHON_VERSION="3.3" COVERAGE="false" - DISTRIB="conda" PYTHON_VERSION="3.4" COVERAGE="false" install: - source tests/travis_install.sh - pip install -r requirements.txt before_script: - git config --global user.email "roskakori@users.sourceforge.net" - git config --global user.name "Thomas Aglassinger" script: - python setup.py test after_success: - if [[ "$COVERAGE" == "true" ]]; then coveralls || echo "failed"; fi cache: - apt
  • 36. Activate travis ● Visit https://travis-ci.org/profile ● Click ● Enable project:
  • 37. Coveralls ● Online test coverage reports ● Add a repository: https://coveralls.io/repos/new ● (even for open source repos) ●
  • 38. Time to git push!
  • 40. Pythoner version numbering ● Guidelines: “PEP 440 - Version Identification and Dependency Specification” https://www.python.org/dev/peps/pep-0440/ ● Easy but cumbersome: manual maintenance in __init__.py: __version__ = '1.2.3'
  • 41. Version numbering with Pyscaffold “Magic” in _version.py: $ python >>> from dividemo import _version >>> _version.get_version()['version'] '0.0.post0.dev2+g8cdc4ea'
  • 42. Advancing the version Add a new git tag: $ git tag -a -m "Tagged version 0.1.0." v0.1.0 $ git push --tags
  • 43. Trove classifiers ● Describe package ● Make it easier for users to find it ● Available classifiers: https://pypi.python.org/pypi?%3Aaction=list_classifiers
  • 44. Add trove classifiers ● Setup.py ● With Pyscaffold: setup.cfg
  • 45. Dividemo trove classifiers classifiers = Development Status :: 4 - Beta, Environment :: Console, License :: OSI Approved :: BSD License, Operating System :: OS Independent, Programming Language :: Python, Programming Language :: Python :: 2, Programming Language :: Python :: 3, Topic :: Utilities
  • 49. Static code checks ● Identify possibly issues by scanning the source code ● PEP8 Style guide for Python code http://legacy.python.org/dev/peps/pep-0008/ ● “Code smells”, e.g. unreachable or unused code ● Intended to improve general code quality and simplify maintenance
  • 50. flake8 ● Finds formatting issues and a few code smells ● Pragmatic and low volume $ tox -e flake8 dividemo/dividemo.py:5:1: F401 'math' imported but unused dividemo/dividemo.py:11:1: E302 expected 2 blank lines, found 1 dividemo/dividemo.py:14:80: E501 line too long (90 > 79 characters) dividemo/dividemo.py:15:64: E231 missing whitespace after ',' ...
  • 51. Pylint ● http://www.pylint.org/ ● Provides many checks ● Default setting: very verbose, lots of noise ● Simple front end: https://landscape.io/ ● Based on prospector https://pypi.python.org/pypi/prospector
  • 53. Pull requests ● Feature of Github and Bitbucket ● Makes it easy to review, iterate and merge changes from another fork ● Sadly no live presentation due lack of time ggg:-(
  • 55. Sphinx documentation ● “Sphinx is a tool that makes it easy to create intelligent and beautiful documentation” ● http://sphinx-doc.org ● Based on ReStructured Text markup ● Easy linking and cross referencing ● Automatically builds index and search page ● Extract API documentation from source code
  • 56. Sphinx configuration ● docs/conf.py ● Manually: docs/Makefile ● Pyscaffold: ● Possibly have to set theme in conf.py: html_theme = 'default' ● Possibly trim option intersphinx_mapping ● HTML results are located in “docs/_build/html” $ python setup.py docs
  • 57. Publishing the documentation ● https://readthedocs.org ● After push to repository, rebuild and publish the documentation ● Dashboard > Import a project > From Github ● Wait for build to finish ● Read it at https://dividemo.readthedocs.org
  • 59. Launcher scripts ● To just run “dividemo” instead of “python ...” ● Add pointer to main() function in setup.cfg: [console_scripts] dividemo = dividemo.dividemo:main
  • 60. Publish to the Python Package Index (PyPI)
  • 61. PyPI first time setup ● Prepare ~/.pypirc: ● Register you project: [distutils] index-servers=pypi [pypi] repository=https://pypi.python.org/pypi username=roskakori password=..... $ python setup.py register
  • 62. Publish a new version $ git tag -a -m "Tagged version 1.0.0." v1.0.0 $ git push –tags $ python setup.py sdist --formats=zip upload
  • 64. Summary ● Many helpful tools for Python projects – Flake8, git, pip, Pyscaffold, sphinx ● Many helpful services – Coveralls, Github, PyPI, Readthedocs, Travis ● Easy collaboration with Github and Pull requests ● Python is fun!