我如何指定托克斯+ Python版本特定要求
目前,我有以下内容:
[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。
我在做什么错?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题是您在github操作中不运行正确的环境。
例如。在您的
tox.ini
中,您可以创建一个名称的Env:然后,您将要求定义如下:
这意味着 - 安装
psycopg2 -binary
当env name包含因子<代码> py37 +postgres
。这与上述env匹配!到目前为止,一切都很好。但是在您的GHA中,您的运行:
...不包含
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:Then you define the requirements as following:
Which means - install
psycopg2-binary
when the env name contains the factorspy37
+postgres
. This matches the above env! So far so good.But in your gha your run:
... which does not contain the
py37
factor - so no match - no installation.The
sqlite
tests succeed as itsqlite
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 :-)
该问题从不
tox
或tox
的配置。问题是
github操作
,当您使用tox-environment
或python-version
+tox-environment
,代码> tox-gh-actions 无法正确解析。使其永不匹配。The issue was never
tox
ortox
's configuration.The issue was
github actions
, when you usetox-environment
orpython-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]