根据env var制作Python版本(使用travis-ci)

时间:2021-10-09 23:06:36

Is there a way to configure travis-ci to make the Python versions dependent on a certain env var?

有没有办法配置travis-ci使Python版本依赖于某个env var?

Please consider the following travis.yml config:

请考虑以下travis.yml配置:

language: python
python:
  - "2.5"
  - "2.6"
  - "2.7"
env:
  - DJANGO=1.3.4
  - DJANGO=1.4.2
  - DJANGO=https://github.com/django/django/zipball/master
install:
  - pip install -q Django==$DJANGO --use-mirrors
  - pip install -e . --use-mirrors
script:
  - python src/runtests.py

Among Django 1.3 (DJANGO=1.3.4) and 1.4 (DJANGO=1.4.2) i also want to test against the latest development version of Django (DJANGO=https://github.com/django/django/zipball/master), which is basically Django 1.5.

在Django 1.3(DJANGO = 1.3.4)和1.4(DJANGO = 1.4.2)中我还想测试Django的最新开发版本(DJANGO = https://github.com/django/django/zipball/master) ,这基本上是Django 1.5。

The problem i see is that travis-ci will automatically run the integration against all specified Python versions. Django 1.5 however doesn't support Python 2.5 anymore. Is it possible to omit it for the Django development version so that i get integrations like this only:

我看到的问题是travis-ci将自动运行针对所有指定Python版本的集成。然而,Django 1.5不再支持Python 2.5。是否可以省略它为Django开发版本,以便我得到这样的集成:

  • DJANGO=1.3.4 --> python "2.5", "2.6", "2.7"
  • DJANGO = 1.3.4 - > python“2.5”,“2.6”,“2.7”
  • DJANGO=1.4.2 --> python "2.5", "2.6", "2.7"
  • DJANGO = 1.4.2 - > python“2.5”,“2.6”,“2.7”
  • DJANGO=https://github.com/django/django/zipball/master --> python "2.6", "2.7"
  • DJANGO = https://github.com/django/django/zipball/master - > python“2.6”,“2.7”

UPDATE:

更新:

Here's a link to a live example based on Odi's answer which i've been using successfully for a few months: https://github.com/deschler/django-modeltranslation/blob/master/.travis.yml

这里有一个基于Odi答案的实例的链接,我已经成功使用了几个月:https://github.com/deschler/django-modeltranslation/blob/master/.travis.yml

1 个解决方案

#1


12  

You can specify configurations that you want to exclude from the build matrix (i.e. combinations that you don't want to test).

您可以指定要从构建矩阵中排除的配置(即您不想测试的组合)。

Add this to your .travis.yml:

将其添加到.travis.yml:

matrix:
  exclude:
   - python: "2.5"
     env: DJANGO=https://github.com/django/django/zipball/master

Note: only exact matches will be excluded.

注意:仅排除完全匹配。

See the build documentation (section The Build Matrix) for further information.

有关详细信息,请参阅构建文档(构建矩阵部分)。

#1


12  

You can specify configurations that you want to exclude from the build matrix (i.e. combinations that you don't want to test).

您可以指定要从构建矩阵中排除的配置(即您不想测试的组合)。

Add this to your .travis.yml:

将其添加到.travis.yml:

matrix:
  exclude:
   - python: "2.5"
     env: DJANGO=https://github.com/django/django/zipball/master

Note: only exact matches will be excluded.

注意:仅排除完全匹配。

See the build documentation (section The Build Matrix) for further information.

有关详细信息,请参阅构建文档(构建矩阵部分)。