This template provides a basic template for a Python project, with out-of-the-box support for py.test, coverage, Sphinx, tox, and the standard Python flow for building and distributing projects.
An .editorconfig_ file is provided to ensure standard settings when working with multiple editors.
A travis.yml file is provided for easy integration with the travis CI system, which is free for open-source projects.
The default license included in the LICENSE
file is the MIT license.
- Sphinx automatically parses the package name and version number, so there
is no need to edit
conf.py
for most projects CHANGELOG.rst
andREADME.rst
are automatically included as the homepage of the Sphinx-generated documentationsetup.py
automatically parsesrequirements.txt
for requirements and the package version, so there is no need to update in multiple places- tox is configured by default to build the project documentation using Sphinx and autodoc, so all of your docstrings will be automatically documented
To get up and running, first check out the repo locally and copy it into your project root:
mkdir my_project
git clone https://github.com/mplanchard/python_skeleton
cp -r python_skeleton/* my_project/
cp python_skeleton/.editorconfig my_project/
cp python_skeleton/.gitignore my_project/
cd my_project
Then setup and activate a virtual environment for the project. A
create_venv.sh
script is provided for convenience. Note that the provided
script assumes you want to use "python3" as an interpreter. If you don't,
adjust the script to use your desired Python prior to running the following
commands:
./create_venv.sh
source venv/bin/activate
Then adjust the following as needed:
- Rename the
package_name
directory to your desired package name - Fill in the constants in
setup.py
, ensuring thatNAME
matches the directory name of your package - Assign your package name to the
PACKAGE_NAME
environment variables intox.ini
- If you don't want to support Python 2 (a more and more reasonable decision),
remove
py27
from the environments list intox.ini
, and then insetup.cfg
, comment outuniversal=1
and uncommentpython-tag=py3
. - If you're using type-hints and you intend to support anything less than
Python 3.5, uncomment the indicated line in
requirements.txt
You should now be able to:
Install your package in development mode:
pip install -e .
Run tests
py.test
Run tests against all configured Python interpreters and build documentation
tox
Build your project
python setup.py bdist_wheel
I use this repo as a skeleton for the majority of my projects, and you are welcome to do the same. If you'd like to fix something, improve the documentation, or add a new feature, please feel free to open a PR. If there's a feature you'd like to see added and you're unsure of how to contribute, raise an Issue.