简体   繁体   English

从tox.ini确定所需的Python版本并根据需要安装

[英]Determine required Python versions from tox.ini and install if required

tox documentation suggests that the versions of Python that you want to test against must already be installed in the environment, otherwise you'll experience errors. Tox 文档建议您要测试的Python版本必须已经安装在环境中,否则您将遇到错误。 With that in mind, is there a generally accepted practice of checking envlist in tox.ini and using that to then install the required versions. 考虑到这一点,有一种普遍接受的做法,即检查envlist中的tox.ini并使用它来安装所需的版本。 Eg for: 例如:

envlist = py27, py36

check if these are installed and if not, install them. 检查是否已安装,否则,请安装它们。

You can make a custom script in order to install desired versions of python using pyenv and then use them with tox. 您可以制作一个自定义脚本,以便使用pyenv安装所需的python版本,然后将其与tox一起使用。

Some useful links about how you can install python versions with pyenv can be found here: 在这里可以找到有关如何使用pyenv安装python版本的一些有用链接:

https://anil.io/blog/python/pyenv/using-pyenv-to-install-multiple-python-versions-tox/ https://anil.io/blog/python/pyenv/using-pyenv-to-install-multiple-python-versions-tox/

https://github.com/lablup/backend.ai/wiki/Install-Python-via-pyenv https://github.com/lablup/backend.ai/wiki/Install-Python-via-pyenv

For using tox along with pyenv you can check this links as well: 为了与pyenv一起使用tox,您还可以检查以下链接:

http://ishcray.com/supporting-multiple-python-versions-with-tox http://ishcray.com/supporting-multiple-python-versions-with-tox

http://blog.pinaxproject.com/2015/12/08/how-test-against-multiple-python-versions-parallel/ http://blog.pinaxproject.com/2015/12/08/how-test-against-multiple-python-versions-parallel/

Add this to section [tox] in your tox.ini file: 将此添加到tox.ini文件中的[tox]部分:

skip_missing_interpreters=true

With that tox simply ignores unavailable Python versions. 使用该tox只会忽略不可用的Python版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM