matt_davidson@python_talks ~/ $ delivering a python project
|-- my_first_module.py |-- test_my_first_module.py
setup( name='my_first_package', version=my_first_package.__version__, author='Matt Davidson', tests_require=['pytest'], install_requires=['requests==2.7.0', 'docopt==0.6.2' ], cmdclass={'test': PyTest}, author_email='matt@mattjdavidson.co.uk', description='A dummy package used for presentations', long_description=long_description, packages=['my_first_package'], include_package_data=True, platforms='any',
my_first_package ======= Documentation ------------- Available in docs directory of the project, hopefully hosted somewhere else too! ### Installation `pip install my_first_package` ## Contact Me Questions or comments about `my first package`? Hit me up at [matt@mattjdavidson.co.uk](mailto:matt@mattjdavidson.co.uk).
docopt==0.6.2 requests==2.7.0
""" my_first_package is a dummy package used for presentations """ __version__ = '0.0.1'
|- README.md |- requirements.txt |- setup.py |- docs | |-- my_first_module.rst |- my_first_package | |-- __init__.py | |-- my_first_module.py |- tests | |-- test_my_first_module.py
• Create projects using templates • Windows, Mac, Linux • Python, Javascript, Ruby etc. https://github.com/audreyr/cookiecutter
• Readability > Verbosity • Generate from docstrings • Use a tool!
def complex(real=0.0, imag=0.0): """Form a complex number. If necessary you can include a much longer multi line explanation here if the single line explanation is not sufficient. Keyword arguments: real -- the real part (default 0.0) imag -- the imaginary part (default 0.0) """ if imag == 0.0 and real == 0.0: return complex_zero ...
• http://sphinx-doc.org/ • http://fitzgen.github.io/pycco/ • http://www.mkdocs.org/
• Manage throughout development lifecycle • Dependency’s dependencies matt@workstation ~/code $ pip freeze > requirements.txt
• PyPA recommended install tool • Easy to use with PyPI (mirrors), wheels • Easy requirements gathering • 2.7.9+ 3.4+ included
matt@workstation ~/code $ pip install my_first_package matt@workstation ~/code $ pip install /path/to/dir matt@workstation ~/code $ pip install -e /path/to/dir matt@workstation ~/code $ pip install -r requirements.txt matt@workstation ~/code $ pip uninstall ... matt@workstation ~/code $ pip install --no-index --find-links /path/to/dependencies my_first_package
• A zip archive • Requires setup.py and PEP 376 files • Wheel > egg (dependencies)
matt@workstation ~/code $ python setup.py bdist_wheel matt@workstation ~/code $ pip install wheel matt@workstation ~/code $ pip --wheel-dir /path/to/dir my_first_package matt@workstation ~/code $ pip install --no-index --find-links /path/to/dir my_first_package
• Organise your code • Run your tests • Generate your documents • Build your wheels • Distribute your wheels • Share your code
matt@workstation ~/code $ python setup.py test matt@workstation ~/code $ sphinx/pycco ... matt@workstation ~/code $ pip wheel --wheel-dir /path/to/dir my_first_package matt@workstation ~/code $ git bundle create repo.bundle --all matt@workstation ~/code $ pip install --no-index --find-links /path/to/dir my_first_package
• Development Tools and Virtualenvs • Unit Testing and Docker • Python 2 vs Python 3 & “future” proofing • Intermediate Python • Pythonic Code
• https://www.python.org/dev/peps • http://www.jeffknupp.com/blog/ • http://docs.python-guide.org/en/latest/

How to deliver a Python project

Editor's Notes

  • #4 2 primary functions: Various project aspects are configured Command line interface for packaging task commands
  • #14 PyPA – Python Packaging Authority PyPI – Python Packaging Index
  • #20 PyPA – Python Packaging Authority PyPI – Python Packaging Index