我如何指定托克斯+ Python版本特定要求

发布于 2025-01-26 15:43:04 字数 1120 浏览 5 评论 0 原文

目前,我有以下内容:

[gh-actions]
python =
    3.7: py37
    3.8: py38
    3.9: py39
    3.10: py310
    pypy-3.7: pypy3
    pypy-3.8: pypy3

[tox]
minversion = 1.9
envlist =
    lint
    py{37,38,39,py3}-django22-{sqlite,postgres}
    py{37,38,39,310,py3}-django32-{sqlite,postgres}
    py{38,39,310,py3}-django40-{sqlite,postgres}
    py310-djangomain-{sqlite,postgres}
    docs
    examples
    linkcheck

toxworkdir = {env:TOX_WORKDIR:.tox}

[testenv]
deps =
    Pillow
    SQLAlchemy
    mongoengine
    django22: Django>=2.2,<2.3
    django32: Django>=3.2,<3.3
    django40: Django>=4.0,<4.1
    djangomain: https://github.com/django/django/archive/main.tar.gz
    py{37,38,39,310}-django{22,32,40,main}-postgres: psycopg2-binary
    py{py3}-django{22,32,40,main}-postgres: psycopg2cffi

我需要根据 cpython vs pypy 安装不同的 psycopg2 。我尝试了各种组合,什么也没有,这一切都以失败而结束。我无法获得任何要安装的* - Postgres env。

我在做什么错?

Currently I have the following:

[gh-actions]
python =
    3.7: py37
    3.8: py38
    3.9: py39
    3.10: py310
    pypy-3.7: pypy3
    pypy-3.8: pypy3

[tox]
minversion = 1.9
envlist =
    lint
    py{37,38,39,py3}-django22-{sqlite,postgres}
    py{37,38,39,310,py3}-django32-{sqlite,postgres}
    py{38,39,310,py3}-django40-{sqlite,postgres}
    py310-djangomain-{sqlite,postgres}
    docs
    examples
    linkcheck

toxworkdir = {env:TOX_WORKDIR:.tox}

[testenv]
deps =
    Pillow
    SQLAlchemy
    mongoengine
    django22: Django>=2.2,<2.3
    django32: Django>=3.2,<3.3
    django40: Django>=4.0,<4.1
    djangomain: https://github.com/django/django/archive/main.tar.gz
    py{37,38,39,310}-django{22,32,40,main}-postgres: psycopg2-binary
    py{py3}-django{22,32,40,main}-postgres: psycopg2cffi

I need to install a different psycopg2 depending on cpython vs pypy. I've tried all kinds of combinations, and nothing, it all ends in failure. I can't get any of the *-postgres envs to install.

What I'm doing wrong?

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

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

发布评论

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

评论(2

琴流音 2025-02-02 15:43:04

问题是您在github操作中不运行正确的环境。

例如。在您的 tox.ini 中,您可以创建一个名称的Env:

py37-django22-alchemy-mongoengine-postgres

然后,您将要求定义如下:

py{37,38,39,310}-postgres: psycopg2-binary

这意味着 - 安装 psycopg2 -binary 当env name包含因子<代码> py37 + postgres 。这与上述env匹配!到目前为止,一切都很好。

但是在您的GHA中,您的运行:

- python-version: "3.7"
  tox-environment: django22-postgres

...不包含 py37 因素 - 因此,没有匹配 - 没有安装。

sqlite 测试成功,因为 sqlite 与Python一起。

我建议您查看 https://github.com/ymyzk/tox-gh-actions 我也建议。

基本上,您只需在GHA上运行 tox ,然后让插件从TOX到GitHub进行匹配的Python环境的繁重提升。

免责声明:
我是托克斯维护者之一,您会为我见过的最复杂的因素设置而获得奖励:-)

The issue is that you do not run the correct environments in your GitHub Actions.

For example. In your tox.ini you create an env with the name:

py37-django22-alchemy-mongoengine-postgres

Then you define the requirements as following:

py{37,38,39,310}-postgres: psycopg2-binary

Which means - install psycopg2-binary when the env name contains the factors py37 + postgres. This matches the above env! So far so good.

But in your gha your run:

- python-version: "3.7"
  tox-environment: django22-postgres

... which does not contain the py37 factor - so no match - no installation.

The sqlite tests succeed as it sqlite comes along with Python.

I would suggest that you have a look at the django projects in the jazzband github organization. They all are heavy use of tox factors (the parts separated by dashes) and they also use gha - mostly via https://github.com/ymyzk/tox-gh-actions which I would recommend, too.

Basically you just run tox on gha and let the plugin do the heavy lifting of matching Python environments from tox to github.

Disclaimer:
I am one of the tox maintainers and you earn a prize for the most complex factor setup I have ever seen :-)

一枫情书 2025-02-02 15:43:04

该问题从不 tox tox 的配置。

问题是 github操作,当您使用 tox-environment python-version + tox-environment ,代码> tox-gh-actions 无法正确解析。使其永不匹配。

The issue was never tox or tox's configuration.

The issue was github actions, when you use tox-environment or python-version + tox-environment, tox-gh-actions won't parse it correctly. Causing it to never match.

This is what I removed.
This is what tox.ini looks like and what github actions looks like [and line 47]

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