tox-pdm
tox-pdm copied to clipboard
A plugin for tox that utilizes PDM as the package manager and installer
tox-pdm
A plugin for tox that utilizes PDM as the package manager and installer.
With this plugin, you can migrate your project to PDM while retaining the ability to test against multiple versions.
Installation
$ pip install tox-pdm
Or,
$ pdm add -d tox-pdm
Or if you installed tox via pipx, you can inject the plugin by:
$ pipx inject tox tox-pdm
Example tox.ini
The following simple example installs dev and test dependencies into the venv created by Tox and uses pytest to execute the tests, on both Python 3.7 and 3.8.
[tox]
min_version = 4.0
envlist = py37,py38
[testenv]
groups = ; Dependency groups in pyproject.toml
dev
test
deps = ; Additional dependencies, it will be installed into the library path via normal pip method
flake8
commands =
pytest test/
Here is another one installing the test dependencies and executing the test PDM script
[tox]
min_version = 4.0
envlist = py3{8,9,10}
[testenv]
groups = test
commands = test
If no groups are specified, the pdm install will be skipped.
A real-world example can be found at this repository's tox.ini and GitHub Action workflow.
Some best practices:
pdmexecutable must be exposed inPATH, if it is not the case, give the absolute path to tox bytox --pdm <path_to_pdm>.- Make sure you have generated
pdm.lockbefore running the test, it will greatly accelerate the testing. - If you don't set
skip_install = true, the current package will be built and installed into the testing environment together with thedependenciesfrompyproject.toml. - Reuse your PDM scripts to avoid duplication