Cookiecutter template for a Python package.
- Testing setup with
pytest - Measuring code coverage with
pytest-cov - Tox testing
- isort and prettier pre-commit hooks for formatting
- Flake8 and MyPy pre-commit hooks for linting
- Auto-release to PyPI when you push a new tag to master
- Simple Django app for testing purposes (optional)
Install the latest Cookiecutter
pip install -U cookiecutterInstall pre-commit framework
pip install -U pre-commitInstall Tox and Twine (optionally)
sudo apt-get -y install tox twineGenerate a Python package project:
cookiecutter https://github.com/dldevinc/cookiecutter-pypackage.gitThen:
- Create a virtual environment.
python3 -m venv --prompt="env" .venv- Install the requirements into a virtualenv
pip install -r requirements.txt- Write some code.
- Install
pre-commithooks (optionally):
pre-commit install- ... or run formatters and linters manualy:
pre-commit run -a- Test your code:
tox -s- Analyze code coverage:
pytest --cov- Create a GitHub repo.
- Register your project with PyPI.
python3 setup.py sdist bdist_wheel
twine upload --skip-existing dist/*- Create a new PyPI API token and save it
as GitHub repository secret named
PYPI_PASSWORD. - Release your package by pushing a new tag to master.