A PDM plugin to run a command on multiple Python versions.
Project description
PDM Multirun
A PDM plugin to run a command on multiple Python versions.
Installation
With pipx
:
pipx install pdm
pipx inject pdm pdm-multirun
With PDM:
pdm self add pdm-multirun
As a local-only plugin:
# pyproject.toml
[tool.pdm]
plugins = [
"pdm-multirun",
]
pdm install --plugins
Usage
This plugin adds a multirun
command to PDM.
The command accepts the same parameters as the run
command,
with an additional -i
, --interpreters
, --versions
parameter
that allows to specify the interpreters to use.
pdm multirun pytest tests/
To specify interpreters, pass a comma-separated string of Python versions:
pdm multirun -i 3.10,3.11 pytest tests/
If you use virtual environments instead,
pass their names to the --interpreters
option
and add the -e
, --venvs
flag:
pdm multirun -ei 3.10,3.11 pytest tests/
pdm multirun -ei tests38,tests39 pytest tests/
By default, PDM Multirun reads Python versions (or venv names)
from the PDM_MULTIRUN_VERSIONS
environment variable.
It is a string of {major}.{minor}
versions (or venv names),
separated by spaces, that can be found and called by PDM.
export PDM_MULTIRUN_VERSIONS="3.8 3.9 3.10 3.11 3.12"
pdm multirun pytest tests/
export PDM_MULTIRUN_VERSIONS="tests38 tests39 tests310"
pdm multirun pytest tests/
PDM Multirun sets the PDM_MULTIRUN=1
environment variable
when running the specified command.
You can use it to decide if you should, for example,
print the current Python version in the output
of the command:
import os
import sys
MULTIRUN = os.getenv("PDM_MULTIRUN", "0") == "1"
if MULTIRUN:
py = f"{sys.version_info[0]}.{sys.version_info[1]}" # 3.8, 3.9, etc.
... # use `py` string accordingly
PDM Multirun successively runs the pdm use
then pdm run
internal actions.
By default, if PDM cannot "use" an interpreter/venv, it continues with the next.
# will continue with 3.8 even if 3.7 is not available
pdm multirun -i 3.7,3.8 pytest tests/
You can tell it to fail instead with the -f
, --fail-fast
flag:
# will stop at 3.7 if it's not available
pdm multirun -fi 3.7,3.8 pytest tests/
If the command you run fails on a Python version, PDM Multirun stops there.
In any case, PDM Multirun will restore the Python interpreter
saved in .pdm-python
(through the pdm use
command) before exiting.
Project details
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
Hashes for pdm_multirun-0.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be70837052c3accb073cee76316cc80dde7bcb67e29f5aca5f84dfeb84aebc26 |
|
MD5 | dd6d19a4e617d15c0b1e280dfd936c93 |
|
BLAKE2b-256 | ead745c6b5ed39ec21dfa058865e91019e7a49c7344583fb715f664ba1e36d08 |