简体   繁体   English

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

[英]Make Python version depending on env var (using travis-ci)

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. 我看到的问题是travis-ci将自动运行针对所有指定Python版本的集成。 Django 1.5 however doesn't support Python 2.5 anymore. 但是Django 1.5不再支持Python 2.5了。 Is it possible to omit it for the Django development version so that i get integrations like this only: 是否可以省略它为Django开发版本,以便我只有这样的集成:

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

You can specify configurations that you want to exclude from the build matrix (ie 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. 有关详细信息,请参阅构建文档( 构建矩阵部分)

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

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