testable-dependables
outputs the testable versions of Python
for use in a justfile
or CI/CD workflow instead of hardcoding them. Automatically stay on top of supported Python versions.
It supports modern Python packages that use the pyproject.toml
standard (aka PEP 621).
I wanted a command to automatically test all supported Python versions for a library based on its pyproject.toml
Python requirements, i.e. not hardcoding versions somewhere.
Here's an example justfile
that utilizes testable-dependables
and uv
to run unit tests in isolated environments for each supported Python version.
# Run tests across all supported Python versions
test-all-versions:
#!/usr/bin/env bash
set -euo pipefail
for version in $(uvx testable-dependables); do
echo -e "\n=== Testing with Python $version ==="
uv run --all-extras --python "$version" pytest
echo -e "\n=== Tests completed for Python $version ===\n"
done
echo "All tests completed successfully"
uv
is an extremely fast Python package and project manager, written in Rust. uvx
is an alias for uv tool run ...
.
- Install
uv
- Go to a directory with source code for a Python package
uvx testable-dependables
pipx
is a way to run install and run Python applications in isolated environments.
- Install
pipx
pipx install testable-dependables
- Go to a directory with source code for a Python package
testable-dependables
Install testable-dependables
to the Python user install directory. More details in the pip docs.
pip install --user testable-dependables
- Go to a directory with source code for a Python package
testable-dependables
testable-dependables
optionally accepts a path as the first argument. Defaults to .
for the current directory.
uvx testable-dependables /path/to/project
Output as json
.
uvx troml --json /path/to/project
Outputs more verbose information.
uvx troml --verbose /path/to/project/
- Install
just
: https://just.systems/man/en/packages.html just fetch
uv run testable-dependables [PATH-TO-PYPROJECT-TOML]
- unit tests (via
pytest
):just test
- linting (via
ruff
):just lint
- type checking (via
mypy
):just type
- unit test coverage (via
coverage.py
):just coverage
- run 'em all:
just dev