Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Travis special requirements for each python version

I need unittest2 and importlib for python 2.6 that is not required for other python versions that travis tests against.

Is there a way to tell Travis-CI to have different requirements.txt files for each python version?

like image 852
fakedrake Avatar asked Dec 16 '13 17:12

fakedrake


2 Answers

Travis CI adds an environment variable called $TRAVIS_PYTHON_VERSION that can be referenced in your .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

This would cause unittest2 and importlib to be installed only for Python 2.6, with requirements.txt being installed for all versions listed. You can do as many of these checks as necessary. Tornado's .travis.yml file uses it quite a bit.

like image 153
dirn Avatar answered Nov 18 '22 11:11

dirn


The proper way to define conditional requirements is:

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

Yep, comments can be used to specify conditional requirements. If you get some errors you may be using an outdated version of pip.

like image 38
sorin Avatar answered Nov 18 '22 12:11

sorin