简体   繁体   English

让Travis-CI运行* Python 2和3

[英]Make Travis-CI run *both* Python 2 and 3

Should hopefully be a pretty basic question, but here is my .travis.yml file below: 应该是一个非常基本的问题,但这里是我的.travis.yml文件:

language: python

python:
    - "2.6"
    - "2.7"
    - "3.2"
    - "3.3"
    - "3.4"
    - "3.5"
    - "nightly"

matrix:
  allow_failures:
    - python: "2.6"
    - python: "3.2"
    - python: "3.3"
    - python: "3.4"
    - python: "nightly"

install:
    - pip install -r requirements.pip
    - pip install -r test/requirements.pip

script: python -B test/test.py

If you look at the script at the bottom, it's the Python 2 command, whereas python3 is for Python 3. As you can see up top, I choose to use versions from both Python 2 and 3. 如果你看一下底部的脚本,那就是Python 2命令,而python3适用于Python 3.正如你可以看到的那样,我选择使用Python 2 3中的版本。

I want to ask, will that bottom script argument suffice? 我想问一下, 底层脚本论证是否足够? I want Travis to run my script on every single version that I chose above. 我希望Travis在我上面选择的每个版本上运行我的脚本。

I also chose to ask before just uploading it and trying, because I just want to upload the .yml and have it work on the spot. 我还选择在上传和尝试之前询问,因为我只想上传.yml并让它在现场工作。 Without making several commits trying to cleanup small errors and putting build-fails everywhere. 没有做几次提交试图清理小错误并在任何地方放置构建失败。

Yes. 是。 python can be pointing to any version of Python, and in fact it defaults to 3 in some distros like Arch. python可以指向任何版本的Python,实际上它在某些像Symb这样的发行版中默认为3。 virtualenv which Travis uses links python to the specified version. virtualenv,Travis使用链接p​​ython到指定的版本。

Debugging tips: if you want to avoid polluting commit history, create a branch to work on it and squash/rebase merge later. 调试提示:如果您想避免污染提交历史记录,请创建一个分支来处理它并稍后压缩/重新合并。

The command python will always mean one of the Python versions from the matrix; 命令python将始终表示矩阵中的一个Python版本; ie your build will be executed 5 times, each time python pointing a different version from that list. 即你的构建将被执行5次,每次python指向该列表的不同版本。

The version number for the current sub-build available in the TRAVIS_PYTHON_VERSION environment variable. TRAVIS_PYTHON_VERSION环境变量中可用的当前子构建的版本号。

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

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