├── Dockerfile
├── README.md
├── mypy.ini
├── package
│ ├── __init__.py
│ ├── my_script.py
│ └── tests
│ └── test_test.py
├── poetry.lock
├── pyproject.toml
├── requirements.txt
├── requirements_dev.txt
├── scripts
│ ├── docker_bash.sh
│ ├── docker_build.sh
│ └── poetry_reqs.sh
├── setup.py
└── tox.ini
This repo is set up for a hypothetical Python package called package
.
pyproject.toml
sets up the package to be managed by Poetry. See PEP518 and this article for more info about pyproject.toml
files.
setup.py
is a shim to allow the package to be installed in editable mode (pip install -e .
) for development. Non-editable installs will use pyproject.toml
to build the package instead.
The package
directory contains an __init__.py
file with the version number and a tests directory as well as a sample script. The sample script becomes a CLI tool upon install thanks to pyproject.toml
.
The package/tests
directory contains a trivial test to be run by Pytest.
Type checking with mypy is configured via mypy.ini
. Mypy is listed as a dev dependency.
Code formatting with is handled by Black, which is listed as a dev dependency.
Testing with Pytest is configured in pyproject.toml
. Tests, formatting, and type-checking can all be run with Tox, which is configured in tox.ini
.
Version bumping is handled by bump2version and is configured in .bumpversion.cfg
. Bumping the version affects both __init__.py
and pyproject.toml
.
The Dockerfile
specifies a simple Docker image with the package's dependencies.
The scripts
directory has shell scripts for building the Docker image, opening a shell inside the image, and dumping the Poetry-specified requirements to a requirements.txt
and requirements_dev.txt
file.
The sample name "package" is used in three of the files:
pyproject.toml
lines 2, 18, and 22scripts/docker_bash.sh
line 1scripts/docker_build.sh
line 1
Replace this name with whatever your package is called.
Some of the practices in this template were inspired by Train in Data's excellent "Testing and Monitoring ML Deployments" course. See the course's Github repo.