distributing python application the right way

14
DISTRIBUTING PYTHON APPLICATION THE RIGHT WAY deck version 0.1

Upload: vaibhav-mishra

Post on 06-May-2015

230 views

Category:

Engineering


4 download

TRANSCRIPT

Page 1: Distributing Python Application the right way

DISTRIBUTING PYTHONAPPLICATION THE RIGHT

WAYdeck version 0.1

Page 2: Distributing Python Application the right way

DON'T REINVENT THE WHEEL

Make use of already established tools and iterate over it.

Page 3: Distributing Python Application the right way

COOKIECUTTER

Use Cookiecutter to bootstrap your project from all the availabletemplates

Make your own template to your need

cookiecutter https://github.com/audreyr/cookiecutter-pypackage.git

Page 4: Distributing Python Application the right way

BUILD YOUR APP

https://github.com/vinu76jsr/django_profiler/blob/master/profiler/middleware.py

all the code to write your app,

this is a django middleware which intercepts requests andprovides cProfile output but that's not important, it is here only

as placeholder

Page 5: Distributing Python Application the right way

EDIT SETUP.PYsetup( name= 'profile-middleware', # the name for pip install ..... version=version, description= """Profiler for django views""", long_description=readme + '\n\n' + history, author= 'Vaibhav Mishra', author_email= '[email protected]', url= 'https://github.com/vinu76jsr/django_profiler' packages=[ 'profiler', # which packages should be available in PythonPATH ], include_package_data= True, install_requires=[ ], license= "BSD", zip_safe= False, keywords= 'profiler',

Page 6: Distributing Python Application the right way

SETUP.PY CONTINUEDinstall_requires=[ ], # specify dependencies here license= "BSD", zip_safe= False, keywords= 'profiler', classifiers=[ 'Development Status :: 2 - Pre-Alpha', 'Framework :: Django', 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Natural Language :: English', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.6', # language matrix 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', ], )

Page 7: Distributing Python Application the right way

SHOW YOUR CONFIDENCE

Integration with travis or any other CI

Integration with a code coverage metric tools

Doesn't matter how you do it, but always a good idea

show the metrics

-- what's up with the coverage

Page 8: Distributing Python Application the right way

WHAT IS WITH THE COVERAGE

an acceptable target is 60%+I used coveralls to show the badgealthough it's not bulletproof good coverage generally meansbetter tested code and hence lesser bug

Page 9: Distributing Python Application the right way

last command picks your version from setup.py and upload it topypi

UPLOAD TO PYPI$ python setup.py register

running register We need to know who you are, so please choose either: 1. use your existing login, 2. register as a new user, 3. have the server generate a new password for you (and email it to you), or 4. quit Your selection [default 1]:1

$ python setup.py sdist upload

Page 10: Distributing Python Application the right way

THAT'S IT Your package is available on PyPI

one more thing...

Page 11: Distributing Python Application the right way

to preview them

DOCUMENTATIONNobody can use your app if they don't know how toREADME.MD is a good startgo to docs folder and write your docs

make docs

Page 12: Distributing Python Application the right way

DOCUMENTATION TIPS

Maintain a changeloguse sphinx to generate docs and write them in restructuredtextAdd support for readthedocs.org

Page 13: Distributing Python Application the right way

ADDING DOCS TO READTHEDOCS

If you are using github it's easy peasyadd readthedocs webhook in your projectregister a url in read the docs and point it to readthedocs.org

That's it

check out django-profiler-docs

Page 14: Distributing Python Application the right way

QUESTIONS?