如何为 tox 中的给定作业指定某些 python 版本?

发布于 2025-01-13 15:41:07 字数 712 浏览 5 评论 0原文

我有一个包含很多作业的毒物配置,这是一个缩短的版本(我使用诗歌):

[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 作业在几个指定的作业上运行(最好在一个地方指定)。我怎样才能做到这一点?

I have a tox config with quite a few jobs, here is a shortened version (Im using poetry):

[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

I would like the docs job to run on any given python interpreter because I don't care about its version but I would like the package job to run on a few specified ones (preferably in specified in one place). How can I do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

静水深流 2025-01-20 15:41:07

您可以使用 basepython 设置,请参阅 https://tox.wiki/en/3.24.5/example/general.html#basepython-defaults-overriding

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

奖励

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

[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

You can use the basepython setting, see https://tox.wiki/en/3.24.5/example/general.html#basepython-defaults-overriding

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

bonus

Instead of using a comment to describe the tox env, you should use the description setting, see https://tox.wiki/en/3.24.5/config.html#conf-description

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

When you run tox -lv, you get a helpful overview over the available environments.

$ tox -lv

default environments:
...
docs       -> Builds the documentation
package    -> Builds the package
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文