Skip to main content

A PDM plugin to run a command on multiple Python versions.

Project description

PDM Multirun

ci documentation pypi version gitpod gitter

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

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/

By default, PDM Multirun reads Python versions from the PDM_MULTIRUN_VERSIONS environment variable. It is a string of {major}.{minor} versions, separated by spaces, that can be found and called by PDM.

export PDM_MULTIRUN_VERSIONS="3.7 3.8 3.9 3.10 3.11"
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. If the command fails on a Python version, PDM Multirun stops there. It any case, PDM Multirun will restore the Python version saved in .pdm.toml (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

pdm_multirun-0.3.0.tar.gz (4.5 kB view hashes)

Uploaded Source

Built Distribution

pdm_multirun-0.3.0-py3-none-any.whl (4.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page