Skip to main content

Creates the skeleton of your Python project.

Project description

.. image::

.. image::

Starting a new Python project from the scratch is boring and error prone:
* First create a script
* Create documentation
* Provide installation instructions
* A README file
* Write tests
* etc, etc, etc.

This time-consuming and error prone work gives little satisfaction, but is
necessary to make your project a good citizen in the open source community.

python-boilerplate produces skeletons for your Python projects so you can get
up and running fast. It is influenced by this blog post:,
although we do not follow these recommendations by the letter.

The filesystem structure

We start a python-boilerplate skeleton by calling the ``python-boilerplate init``
command on the root directory of your project. It creates the following tree::

|- .coveragerc
|- .gitignore
|- .travis.yml
|- INSTALL.rst
|- README.rst
|- requirements.txt
|- tox.ini
|- docs/
| |- index.rst
| |- apidoc.rst
| |- changelog.rst
| | ...
| |-
| |- make.bat
| |- Makefile
| |- _static/*
| \- _templates/*
\- src/
\- <package>
|- <package>.py
\- tests/
\- test_<package>.py

The main entry point for installation and management of your project. We provide
a minimum working script based on setuptools. In order to avoid duplication of
work, the script reuses the project description from README.rst and
uses the version string in a separate VERSION file. Users still have
to edit this file and provide the short description of the project.

Don't forget to ``python register`` your project to PyPI before someone
takes it name!


python-boilerplate puts all source code for your project under the ``src/<package>``
folder. This contrasts with the other typical approach of leaving the python
packages directly in the root of the the source tree. We believe that a separate
src folder is more organized and manageable in the long run.


We also create a "<package>.tests" module for unit testing and distribute it
with the main package. The drawback of this approach is a slightly larger
distribution. In most systems, this small price is greatly offset by the ability
to ask users to easily run the test suite when dealing with bug reports.
python-boilerplate creates a ```` file in the tests package that
enable anyone can run the test suite simply by calling ``python -m <package>.tests``.


python-boilerplate creates the skeleton for a Sphinx_-based documentation. The
documentation reuses both the README.rst and INSTALL.rst files. In most cases,
it is probably a good idea to create a relatively small README.rst with a
succinct overview of your project and leave most details of the documentation to
specific files inside the ``docs/`` directory.

The README.rst file in python-boilerplate itself is perhaps too big ;-)

_ Sphinx:

README.rst and INSTALL.rst

We provide a default INSTALL.rst file with generic installation instructions for
Python packages. Unless your project requires something fancy, this probably can
be left as is.

The README.rst file, however, provides a detailed overview of your project.
You should edit this file to provide a meaningful description, otherwise a not so
flattering default will be used. The contents of README.rst are also displayed in
the index page of the project's documentation.


Your project's version is conveniently centralized in a single file. The script uses this value to register you package and it also saves
the correct version in the <package>.__version__ attribute in your module.

You may bump version numbers using an invoke task::

$ inv bump-version

This method assumes that the version string is in the form "<major>.<minor>.<micro>".


The requirements.txt uses the ``- e .`` directive to tell pip to search for the
requirements in the script. As a general rule, dependencies should be
specified only in the ``install_requires`` flag in your

You may want to use your requirements.txt to freeze packages to specific
versions by adding lines such as::


Freezing makes sense for packages that are meant to run only on their own private
environments such as a Django project running in it own virtualenv or docker
container. Avoid freezing package versions in your main Python installation.

Define files to be included in the source distributions created by setuptools.


Python boilerplate accepts the most common open source licenses (or at least it
should). If the license you want to use is not supported, we gladly accept


The default .gitignore excludes python bytecode and all build directories.


The ```` define some invoke tasks for your project. You can define new
tasks by defining python functions just as the example given in this file. Think
of ```` as a Python replacement of a Makefile: it is used to define
commands that automate repetitive tasks and chores. We define a few general
purpose tasks. They are executed using the inv(oke) command.

``inv test``:
Runs py.test with the main test suite.
``inv coverage``:
Runs py.test and display a coverage report.
``inv build``:
Calls build and also builds the documentation.
``inv bump-version``:
Controls the version number in the VERSION file.

Continuous integration

python-boilerplate ships a working ``.travis.yml`` file and a ``tox.ini``. You
can use tox to run the test suite for different Python versions locally (but
you'll need several working interpreters simultaneously installed in your

Assuming that you are hosting your code at Github, enable Travis-CI integration
under "Settings > Integrations and services" option in your main repository
page. Also enable "Coveralls" integration to have good quality reports on code
coverage evolution.

You need to enable support for your repository both in `Travis-CI<>`
and `Coveralls<>` websites. Continuous integration tasks
will run every time you *push* something new to Github.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-boilerplate-0.4.10.tar.gz (37.4 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page