使用平台时,指定 Python 版本特定的 testenv 设置
Specify Python version-specific testenv settings, when platform is used
如何设置 testenv 以指定特定 Python 版本的设置?作为一个最小的例子,
[tox]
envlist = py{36,37,38,39}-{mylinux,macos,mywindows}
skipsdist = True
[testenv]
platform = mylinux: linux
mymacos: darwin
mywindows: win32
setenv =
mylinux: PLATFORM = linux
mymacos: PLATFORM = macos
mywindows: PLATFORM = windows
commands =
{envpython} -c "print('{env:PLATFORM}')" # This env is used in setup.py
# other commands
[testenv:py36]
deps =
pydantic # No dataclasses until py37
如果我运行 tox -e py36-mylinux
, pydantic
将不会被安装。如果我运行tox -e py36
,它会说
ERROR: py36: unresolvable substitution(s):
commands: 'PLATFORM'
Environment variables are missing or defined recursively.
如何为特定 Python 版本指定 testenv 设置,而不必在环境名称中指定所有其他信息(尤其是当 envlist 变长时)?
同理;将其放入 [testenv]
(并删除 [testenv:py36]
):
deps =
py36: pydantic # No dataclasses until py37
使用 tox --showconfig
验证配置
PS。 tox
不结合环境;一旦你有一个单独的 [testenv:py36]
它将不会与 mylinux
.
合并
如何设置 testenv 以指定特定 Python 版本的设置?作为一个最小的例子,
[tox]
envlist = py{36,37,38,39}-{mylinux,macos,mywindows}
skipsdist = True
[testenv]
platform = mylinux: linux
mymacos: darwin
mywindows: win32
setenv =
mylinux: PLATFORM = linux
mymacos: PLATFORM = macos
mywindows: PLATFORM = windows
commands =
{envpython} -c "print('{env:PLATFORM}')" # This env is used in setup.py
# other commands
[testenv:py36]
deps =
pydantic # No dataclasses until py37
如果我运行 tox -e py36-mylinux
, pydantic
将不会被安装。如果我运行tox -e py36
,它会说
ERROR: py36: unresolvable substitution(s):
commands: 'PLATFORM'
Environment variables are missing or defined recursively.
如何为特定 Python 版本指定 testenv 设置,而不必在环境名称中指定所有其他信息(尤其是当 envlist 变长时)?
同理;将其放入 [testenv]
(并删除 [testenv:py36]
):
deps =
py36: pydantic # No dataclasses until py37
使用 tox --showconfig
PS。 tox
不结合环境;一旦你有一个单独的 [testenv:py36]
它将不会与 mylinux
.