【问题标题】:Travis special requirements for each python versionTravis 对每个 python 版本的特殊要求
【发布时间】:2014-01-04 05:42:48
【问题描述】:

我需要用于 python 2.6 的 unittest2 和 importlib,而其他用于 travis 测试的 python 版本不需要。

有没有办法告诉 Travis-CI 为每个 python 版本有不同的 requirements.txt 文件?

【问题讨论】:

标签: python travis-ci requirements.txt


【解决方案1】:

Travis CI 添加了一个名为 $TRAVIS_PYTHON_VERSION 的环境变量,可以在您的 .travis.yml 中引用:

python:
  - 2.6
  - 2.7
  - 3.2
  - 3.3
  - pypy
install:
  - if [[ $TRAVIS_PYTHON_VERSION == 2.6 ]]; then pip install importlib unittest2; fi
  - pip install -r requirements.txt

这将导致仅为 Python 2.6 安装 unittest2importlib,并为列出的所有版本安装 requirements.txt。您可以根据需要进行尽可能多的这些检查。 Tornado 的.travis.yml 文件使用了很多。

【讨论】:

    【解决方案2】:

    定义conditional requirements的正确方法是:

    # requirements.txt
    ordereddict; python_version == '2.6'
    

    是的,cmets 可用于指定条件要求。如果您遇到一些错误,您可能使用的是过时的 pip 版本。

    【讨论】:

    猜你喜欢
    • 2020-11-17
    • 2018-05-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多