distributing python application the right way

Post on 06-May-2015

230 Views

Category:

Engineering

4 Downloads

Preview:

Click to see full reader

TRANSCRIPT

DISTRIBUTING PYTHONAPPLICATION THE RIGHT

WAYdeck version 0.1

DON'T REINVENT THE WHEEL

Make use of already established tools and iterate over it.

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

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

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= 'vinu76jsr@gmail.com', 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',

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', ], )

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

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

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

THAT'S IT Your package is available on PyPI

one more thing...

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

DOCUMENTATION TIPS

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

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

QUESTIONS?

top related