为什么 tox 面临 Pytest 版本冲突?

Why tox faces Pytest Version Conflict?

我要寻求帮助,因为非常相似的问题的答案[1], [2]无法帮助我解决问题。

tox 在我的本地环境中运行无错误,但在 travis ci 中使用相同版本的 toxpytest 等,它会抛出以下异常:

pluggy.manager.PluginValidationError: Plugin 'removestalebytecode' could not be loaded: (pytest 4.4.0 (XXX/.tox/py35/lib/python3.5/site-packages), Requirement.parse('pytest<3.10'))!

哪里来的pytest 4.4.0从哪里来的?
pytest --version shows version 3.7.4, which was explicitly installed by pip install 'pytest~=3.7.0' --force-reinstall travis ci setup.

Where comes pytest 4.4.0 from?

tox 完全独立于 pip install 'pytest~=3.7.0' --force-reinstall

安装

可以通过将 tox 环境粘贴到 tox.ini

中的特定 pytest 版本来解决
[py]
deps=
    pytest<3.10
    ...

它无法解决

的问题
pluggy.manager.PluginValidationError: Plugin 'removestalebytecode' could not be loaded: (pytest 4.4.0 (XXX/.tox/py35/lib/python3.5/site-packages), Requirement.parse('pytest<3.10'))!

因为在当前版本 3.0.1 中 pytest-remove-stale-bytecode 插件不适用于 py.test 3.10。

解决问题 tox.ini 应该限制版本 pytest-remove-stale-bytecode

[py]
deps=
    ...
    pytest-remove-stale-bytecode<3.0.1