A small matrix task runner for Python projects using Astral uv.
Project description
uv-matrix
A small matrix task runner for Python projects using Astral uv.
Status: early development.
uv-matrix runs the same project tasks across Python versions, dependency variants, extras, dependency groups, and arbitrary task variants defined in pyproject.toml.
Documentation: https://uv-matrix.readthedocs.io/
Why uv-matrix?
Many Python projects need to run checks like this:
- run tests on Python 3.12 and 3.13
- run tests with different optional dependencies
- run lint, docs, and test tasks from one project configuration
- pass the same matrix setup to local development and CI
Installation
uv-matrix requires Python 3.10+ and a working uv installation.
Add it to a project:
uv add --dev uv-matrix
uv run uv-matrix --help
Or run it directly:
uvx uv-matrix --help
Quick start
Add a matrix and a task to pyproject.toml:
[tool.uv-matrix.matrix.test] # a matrix named "test"
python-version = ["3.12", "3.13"] # run the job on Python 3.12 and 3.13
tasks = ["run_test"] # run the "run_test" task in every cell
[tool.uv-matrix.tasks.run_test] # a task named "run_test"
run = "pytest" # command run through `uv run`
Run all jobs:
uv run uv-matrix run
List the jobs without running them:
uv run uv-matrix list
The matrix above expands to:
test:run_test python-version=3.12
test:run_test python-version=3.13
Each job is executed through uv run. For example, the first job runs roughly like this:
uv run --python 3.12 sh -c "pytest"
Matrices
In this matrix, python-version and webui are axes.
[tool.uv-matrix.matrix.test]
python-version = ["3.12", "3.13"] # reserved axis -> uv run --python
webui = ["django", "flask"] # a custom axis (any name)
tasks = ["test"] # 2 x 2 = 4 jobs
Axes are combined as a cartesian product. In the example above, python-version has 2 values and webui has 2 values, so the test matrix creates 4 jobs.
python-version is a reserved axis. It is inherited by tasks that do not set their own Python version and is passed to uv run --python.
Tasks
Tasks are reusable command definitions.
[tool.uv-matrix.tasks.run_test]
run = "pytest {{ posargs }}" # {{ posargs }}: args after `--`
extras = ["{{ webui }}"] # include the current webui extra. ignored if webui is blank.
when = "platform != 'win32'" # skip this task on Windows
Common task fields include:
run: command to executeextras: optional project extras to includegroups: dependency groups to includecwd: working directory for the commandwhen: condition that decides whether the job should run
Task fields can use Jinja2 templates such as {{ webui }} and {{ posargs }}.
{{ posargs }} expands to arguments passed after --:
uv-matrix run --task run_test -- -k slow
Conditions
when specifies a Python expression. If it evaluates to False, the task is skipped.
Templates and when expressions are evaluated only when running jobs. Commands that only enumerate jobs, such as list, expand the matrix without rendering templates or evaluating when.
Usage
uv-matrix run # run every job from every matrix
uv-matrix run --matrix test # run one matrix
uv-matrix run --filter webui=django # select jobs by axis value
uv-matrix run --task lint # run one task wherever it appears
uv-matrix run --max-jobs 4 # run up to 4 jobs at once
uv-matrix run --dry-run # print commands without running them
uv-matrix run --task run_test -- -k slow # pass extra args as {{ posargs }}
uv-matrix list # list selectable jobs
By default, uv-matrix finds pyproject.toml by walking up from the current directory, then runs from the project root.
Use --config PATH to point to a specific config file, or --project DIR to set the project directory.
How it relates to tox
tox is a mature test environment manager.
uv-matrix is intentionally smaller. It delegates interpreter discovery, environment creation, and dependency resolution to uv, then focuses on one job: expanding matrix definitions into commands.
Instead of encoding combinations into environment names, uv-matrix keeps matrix axes explicit in pyproject.toml.
License
MIT License. See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file uv_matrix-0.0.4.tar.gz.
File metadata
- Download URL: uv_matrix-0.0.4.tar.gz
- Upload date:
- Size: 17.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b072d52affd24686dc54c6fd7a95622c1e1f3ab957428f4c7bf7ce9148913b6
|
|
| MD5 |
897cc92d8cf83f564e1753e21a572ffa
|
|
| BLAKE2b-256 |
5d90ae172e77090b820ae78cf263649fc40ba4144a427cd334a5c0f52962f0eb
|
Provenance
The following attestation bundles were made for uv_matrix-0.0.4.tar.gz:
Publisher:
build-release.yml on atsuoishimoto/uv-matrix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
uv_matrix-0.0.4.tar.gz -
Subject digest:
4b072d52affd24686dc54c6fd7a95622c1e1f3ab957428f4c7bf7ce9148913b6 - Sigstore transparency entry: 2070893477
- Sigstore integration time:
-
Permalink:
atsuoishimoto/uv-matrix@eb629b2a3d15ac57c0e228097f6dba377bede898 -
Branch / Tag:
refs/tags/0.0.4 - Owner: https://github.com/atsuoishimoto
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-release.yml@eb629b2a3d15ac57c0e228097f6dba377bede898 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file uv_matrix-0.0.4-py3-none-any.whl.
File metadata
- Download URL: uv_matrix-0.0.4-py3-none-any.whl
- Upload date:
- Size: 21.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1eecbf615e55e0b8c96c78c025b3f92baa042ad87e2a3d6ab14429f3b64e64b7
|
|
| MD5 |
b80f5c6d740825f3cfa5b3adef9931c3
|
|
| BLAKE2b-256 |
e8ee3b5c67aefe98af468198cc710720cfc4db83b84452996e8b8bd2edcfaadb
|
Provenance
The following attestation bundles were made for uv_matrix-0.0.4-py3-none-any.whl:
Publisher:
build-release.yml on atsuoishimoto/uv-matrix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
uv_matrix-0.0.4-py3-none-any.whl -
Subject digest:
1eecbf615e55e0b8c96c78c025b3f92baa042ad87e2a3d6ab14429f3b64e64b7 - Sigstore transparency entry: 2070893593
- Sigstore integration time:
-
Permalink:
atsuoishimoto/uv-matrix@eb629b2a3d15ac57c0e228097f6dba377bede898 -
Branch / Tag:
refs/tags/0.0.4 - Owner: https://github.com/atsuoishimoto
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-release.yml@eb629b2a3d15ac57c0e228097f6dba377bede898 -
Trigger Event:
workflow_dispatch
-
Statement type: