Cookiecutter PyPackage
This is a cookiecutter template for a Python package. Its features include:
- Uses
mypy
for type checking. - Uses
pytest
andtox
for local testing. - Uses
black
andflake8
for formatting and linting. - Uses Github Actions for CI.
- Testing on Ubuntu and Windows.
- Documentation via Github Pages.
- Automatic release to PyPI from
stable
.
It is based off AllenCellModeling/cookiecutter-pypackage and DAI-Lab/cookiecutter-pypackage but has been heavily modified to remove unwanted functionality and add features such as type checking.
Quickstart
To use this template use the following commands and then follow the prompts from the terminal.
pip install cookiecutter
cookiecutter gh:k15z/cookiecutter-pypackage
Once your project is set up, here are the commands you will need to know for everyday development:
make install # install the package in development mode
make test # run type checks and tests
make view-docs # generate and view docs
make fix-lint # automatically format and fix lint issues
Configuration
To take advantage of the other features - continuous integration, documentation, etc. - you will need to perform some additional steps:
- Add your repository to GitHub:
- Register your project with Codecov:
- Make an account on codecov.io and click
Add new repository
- Copy the token provided, go to your GitHub repository's settings and under the
Secrets
tab, add a secret calledCODECOV_TOKEN
with the token you just copied.
- Make an account on codecov.io and click
- Generate an access token for documentation generation:
- Go to your GitHub account's Personal Access Tokens page
- Click:
Generate new token
- Give the token access to:
repo:status
,repo_deployment
, andpublic_repo
. - Go to your GitHub repository's settings and under the
Secrets
tab, add a secret calledACCESS_TOKEN
with the personal access token you just created.
- Register your project with PyPI:
- Go to your GitHub repository's settings and under the
Secrets
tab, add a secret calledPYPI_TOKEN
with your password for your PyPI account. - Next time you push to the branch:
stable
, GitHub actions will build and deploy your Python package to PyPI.
- Go to your GitHub repository's settings and under the