如何在tox中为给定的作业指定特定的python版本

  • 本文关键字:作业 版本 python tox python tox
  • 更新时间 :
  • 英文 :


我有一个包含很多作业的tox配置,这里是一个缩写版本(我使用的是诗歌(:

[tox]
skipsdist = true
envlist =
format,
formatting,
imports,
flake8,
pylint,
docs,
package
isolated_build = True
whitelist_externals = poetry

; Builds the documentation
[testenv:docs]
deps =
sphinx
sphinx_rtd_theme
toml
commands =
sphinx-apidoc -o {[project-info]doc_dir} {[project-info]src_dir}
sphinx-build -b html {[project-info]doc_src_dir} {[project-info]doc_html_output_dir}

; Builds the package
[testenv:package]
deps = poetry
commands =
poetry install
poetry build

我希望docs作业在任何给定的python解释器上运行,因为我不关心它的版本,但我希望package作业在几个指定的解释器上运行(最好在一个地方指定(。我该怎么做?

您可以使用basepython设置,请参阅https://tox.wiki/en/3.24.5/example/general.html#basepython-默认值覆盖

; Builds the package
[testenv:package]
basepython = python3.9
deps = poetry
commands =
poetry install
poetry build

奖金

您不应该使用注释来描述tox-env,而应该使用描述设置,请参阅https://tox.wiki/en/3.24.5/config.html#conf-描述

[testenv:package]
description = Builds the package
basepython = python3.9
deps = poetry
commands =
poetry install
poetry build

运行tox -lv时,您可以获得有关可用环境的有用概述。

$ tox -lv
default environments:
...
docs       -> Builds the documentation
package    -> Builds the package

相关内容

最新更新