Slide 1

Slide 1 text

Building open source the Python application right way an

Slide 2

Slide 2 text

Hi.

Slide 3

Slide 3 text

I’m Kiran. Hacker Programmer Open Source enthusiast Computer Science fanboy

Slide 4

Slide 4 text

Currently, having an affair with Python

Slide 5

Slide 5 text

Why follow Conventions Guidelines Best Practices

Slide 6

Slide 6 text

Your code is Open Source !

Slide 7

Slide 7 text

What does that mean You ask ?

Slide 8

Slide 8 text

Code available to People will try to help start using it everyone People will(might)

Slide 9

Slide 9 text

So, what do I do ?

Slide 10

Slide 10 text

Make it easier for people to use 
 your application

Slide 11

Slide 11 text

How ?

Slide 12

Slide 12 text

Let’s start with basic project structure

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

Let’s make it simpler

Slide 15

Slide 15 text

Documentation Tests Application Dependency Management Setup Task Execution Extras Publish

Slide 16

Slide 16 text

Application

Slide 17

Slide 17 text

Write good code. http://www.python.org/dev/peps/pep-0008/

Slide 18

Slide 18 text

Don’t bloat your code with Use them when required classes

Slide 19

Slide 19 text

to architect your application modules Use

Slide 20

Slide 20 text

Tests

Slide 21

Slide 21 text

“Code not tested is broken by design” - Jacob Kaplan Moss

Slide 22

Slide 22 text

Lots of ways to your application Test

Slide 23

Slide 23 text

Start with simple unit tests

Slide 24

Slide 24 text

unittest Nose py.test Most commonly used

Slide 25

Slide 25 text

Documentation

Slide 26

Slide 26 text

For small projects Code is the documentation http://www.python.org/dev/peps/pep-0257/

Slide 27

Slide 27 text

Sadly This is not scalable

Slide 28

Slide 28 text

Use Sphinx http://sphinx-doc.org/

Slide 29

Slide 29 text

HTML EPUB PDF Man Pages LaTex Automatic Syntax Highlighting Plain Text Theming Support Internationalisation

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

Dependency Management

Slide 32

Slide 32 text

Project Dependencies requirements.txt

Slide 33

Slide 33 text

pip install -r requirements.txt then

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

Setup

Slide 36

Slide 36 text

Pro Tip: Use Virtualenv to setup your environment

Slide 37

Slide 37 text

Why ? Test with different Python versions No unnecessary namespace pollution Different environments and settings per project Install dependencies inside environment

Slide 38

Slide 38 text

Publish

Slide 39

Slide 39 text

setup.py contains the necessary information required for it’s installation Every project’s

Slide 40

Slide 40 text

Packages and uploads your application to Python Package Index a.k.a PyPI

Slide 41

Slide 41 text

setup( name='project name', version=myapp.__version__, description='project description here', license=open("LICENSE").read(), author='author', author_email='email', url='project url', packages=['myapp'], include_package_data=True, classifiers=( 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'Natural Language :: English', 'License :: OSI Approved :: MIT License', 'Programming Language :: Python', 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.3', ), test_suite='tests', )

Slide 42

Slide 42 text

Register at PyPI python setup.py register Package and Upload application python setup.py sdist upload

Slide 43

Slide 43 text

Install application on any platform pip install myapp

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

Task Execution

Slide 46

Slide 46 text

Makefile Use a to automate multiple tasks and commands http://mrbook.org/tutorials/make/

Slide 47

Slide 47 text

Extras (a.k.a enhancements)

Slide 48

Slide 48 text

AUTHORS CHANGELOG CONTRIBUTING

Slide 49

Slide 49 text

is License very important for open source projects http://www.tldrlegal.com/

Slide 50

Slide 50 text

Recap

Slide 51

Slide 51 text

RECAP Documentation Tests Application Dependency Management Setup Task Execution Extras Publish

Slide 52

Slide 52 text

Questions ?

Slide 53

Slide 53 text

Thank you ! @kirang89 http://kirang.in