Python packaging¶
Process Steps¶
- Develop setup.py and other distribution-related files
- Test distribution; should pass all distribution tests
- Register project with the Python Package Index (PyPI)
- Upload distribution(s) to PyPI
Distribution tests¶
python setup.py sdist
does not raise an exception- all expected files are included in the distribution tarball
python setup.py test
works in install environment- acceptance tests pass in install environment
python setup.py install
produces expected footprint insite-packages
- easy_install works
pip install python-pptx
works
Test can install with all popular methods¶
- manual
- easy_install
- pip
Distribution user stories¶
… some notions about who uses these and for what …
Roles¶
- naive end-user
Use Cases¶
Test build before distribution¶
“Just-works” installation¶
In order to enable a new capability in my computing environment
As a naive end-user
I would like installation to "just work" and not scare me with error
messages that don't indicate a real problem.
Install as a dependency¶
Verify installation¶
In order to verify a new installation
As a python developer
I want to be able to easily run the test suite without having to invest in
any additional discovery or configuration.
Resources¶
- The Hitchhiker’s Guide to Packaging
- Writing a Package in Python by Tarek Ziadé is an extract from his PACKT book Expert Python Programming and while being somewhat dated, contains some useful tidbits.
- Ian Bicking’s blog post Python’s Makefile discusses how to write
extensions to setup.py, for perhaps a command like
coverage
that would automatically runnosetests --with-coverage
. - tox documentation
- virtualenv documentation
- How To Package Your Python Code
- Python Packaging: Hate, hate, hate everywhere
- Building and Distributing Packages with setuptools
- A guide to Python packaging
- Python Packaging by Tarek Ziade