Cookiecutter template for a Python python library. This is largely designed to address this blog post about packaging python libraries.
There's a bare library using this template (if you're curious about the final result): https://github.com/ionelmc/python-nameless-minimal.
Note: | You should use cookiecutter-pylibrary instead - it's just like this
(just use no for the test_matrix_configurator option) but with py.test as the test runner. |
---|
- BSD 2-clause license.
- Tox for testing Python 2.6, 2.7, 3.3, PyPy etc.
- Travis-CI and Coveralls for continuous testing and coverage tracking (using Tox).
- Documentation with Sphinx, ready for ReadTheDocs.
- Configurations for:
Projects using this template have these minimal dependencies:
- Tox - for running the tests
- Setuptools - for building the package, wheels etc. Now-days Setuptools is widely available, it shouldn't pose a problem :)
Generate your project:
cookiecutter https://github.com/ionelmc/cookiecutter-pylibrary-minimal.git
The variables
project_name Verbose project name, used in headings (docs, readme, etc) repo_name Repository name on github package_name Python package name (whatever you would import) distribution_name PyPI distribution name (what you would pip install
)
After this you can create the initial repository (make sure you create an empty Github project):
git init . git add . git commit -m "Initial skel." git remote add origin git@github.com:ionelmc/python-nameless.git git push -u origin master
Then:
- Enable the repository in your Travis CI account.
- Enable the repository in your Coveralls account.
- Add the repo to your ReadTheDocs account + turn on the ReadTheDocs
service hook. Don't forget to enable virtualenv and specify
docs/requirements.txt
as the requirements file in Advanced Settings. - Release your package. This template comes with a tox environment (
check
) that will:- Check if your
README.rst
is valid. - Check if the
MANIFEST.in
has any issues. - Run
flake8
(a combo of PEP8, pyflakes and McCabe checks)
- Check if your
There's more intricate variant of this template that:
- Has a generator script for the test matrix (there's a
configure
script that generatestox.ini
/.travis.yml
). - Uses Pytest for the test runner.
- Has support for building C extensions.
If you have criticism or suggestions please open up an Issue or Pull Request.