- Multi python version support (pyenv, tox)
- Single config using the new standardized
pyproject.toml
(PEP518) - Simple build/publish/dependency management using poetry
- Continous integration (GitHub Actions)
- Code coverage reporting (Codecov)
- Code formatting (black)
- pyenv (for automatic installation use pyenv-installer)
- poetry
- Install pyenv and pyenv-virtualenv.
- Install the Python versions you want to support using
pyenv
.
pyenv install 3.6.9
pyenv install 3.8.0
- Clone repo:
git clone git@github.com:vikpe/python-package-starter.git [PACKAGE_NAME]
cd [PACKAGE NAME]
- Create a virtual env:
pyenv virtualenv 3.8.0 foo38
- Activate virtual env:
pyenv activate foo38
- Install poetry:
pip install poetry
- Install dependencies:
poetry install
- Edit
pyproject.toml
, update project name, description and author and any other settings you like.
Command | Description |
---|---|
poetry add [package] |
Add package to dependencies. |
poetry add -D [package] |
Add package to dev dependencies. |
poetry run pytest |
Run tests in local Python version. |
poetry run ptw tests foo --clear |
Watch for file changes and run tests in local Python version. |
poetry run tox |
Run tests in all Python versions defined in tox.ini . |
poetry run black . |
Run black code formatter. |
poetry build |
Build sdist and wheel to /dist . |
poetry publish |
Publish package to PyPi. |
Tests are run whenever there is a commit, see .github/workflows/test.yml
for details.
Enable code coverage reporting to Codecov by creating a secret with name CODECOV_TOKEN
in your repository settings (Settings -> Secrets -> New sectret) and value set to the token created by Codecov.