11

I am trying to build osx support for a project on Travis. The problem is osx don't ship python virtualenv natively. Here is the issue for that. I have gone through that issue and modified my travis file accordingly. Still my builds are failing with osx. Here is a travis build link. Here is my travis.yml file

language: python
matrix:
    include:
        # Use the built in venv for linux builds
        - os: linux
          sudo: required
          python: "2.7"
          dist: trusty

        - os: linux
          sudo: required
          python: "3.5"
          dist: trusty

        - os: linux
          sudo: required
          python: "3.6"
          dist: trusty

        # Use generic language for osx
        - os: osx
          language: generic
          python: "2.7"

        - os: osx
          language: generic
          python: "3.5"

        - os: osx
          language: generic
          python: "3.6"

before_install:
 - .travis/before_install.sh
 - mkdir $HOME/data
 - echo $PWD
 - cd $HOME/data && wget ftp://ftp.astron.nl/outgoing/Measures/WSRT_Measures.ztar && tar xf WSRT_Measures.ztar && cd -
 - echo $PWD
install:
 - export PATH="$HOME/miniconda/bin:$PATH"
 - source activate testenv
 - export CPATH="$HOME/miniconda/envs/testenv/include:$CPATH"
 - echo $CPATH
 - python setup.py develop
 - pip install -r tests/requirements.txt
 - pip install coveralls travis-sphinx
script:
 - nosetests --with-coverage
 - travis-sphinx --nowarn -s doc build

and Here is my before_install.sh file.

set -e
set -v

if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then 
    if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
        brew install python;
        virtualenv venv -p python;
        source venv/bin/activate;
    else
        brew install python3;
        virtualenv venv -p python3;
        source venv/bin/activate;
    fi
fi


if [ "$TRAVIS_OS_NAME" = linux ]; then
    sudo apt-get update
    MINICONDAVERSION="Linux"
else
    MINICONDAVERSION="MacOSX"
fi

if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
  wget https://repo.continuum.io/miniconda/Miniconda2-latest-$MINICONDAVERSION-x86_64.sh -O miniconda.sh;
else
  wget https://repo.continuum.io/miniconda/Miniconda3-latest-$MINICONDAVERSION-x86_64.sh -O miniconda.sh;
  fi

bash miniconda.sh -b -p $HOME/miniconda
export PATH="$HOME/miniconda/bin:$PATH"
hash -r
conda config --set always_yes yes --set changeps1 no
conda update -q conda
conda config --add channels conda-forge
# Useful for debugging any issues with conda
conda info -a
which python
conda create -q -n testenv python=$TRAVIS_PYTHON_VERSION casacore=2.3.0

echo "measures.directory: /home/travis/data" > $HOME/.casarc

It states the following error when I tried to build a conda environment.

CondaValueError: invalid package specification: python=
Shibasis Patel
  • 315
  • 2
  • 14
  • 1
    Looks like your `TRAVIS_PYTHON_VERSION` variable is undefined. Try putting `env` at the beginning of the `before_install.sh` file and inspect the build output. – randomir Jul 22 '17 at 17:59
  • 1
    Also, you can have a look [here](https://github.com/randomir/envie/blob/master/.travis.yml) to see how I handled Python 2 & 3 tests on OS X. – randomir Jul 22 '17 at 18:06
  • 1
    I didn't get what you wanted to say. Can you please explain a bit more? Should I use TOXENV like you used? Sorry, I am a bit newbie. – Shibasis Patel Jul 22 '17 at 19:28
  • 3
    See [Travis docs, section on running (unsupported) Python on OS X](https://docs.travis-ci.com/user/multi-os/#Python-example-(unsupported-languages)). Regarding my first comment, see `man env`. By calling `env` in your script, you can inspect all environment variables defined when your Travis task is run. – randomir Jul 22 '17 at 19:59
  • Thanks for the explaination @randomir, However the build is still failing. I have added TOXENV and `install.sh` file as mentioned in the travis docs and added `env` in the `before_install.sh` file. [Here](https://github.com/shibasisp/python-casacore/blob/osx-travis/.travis.yml) is my updated .travis.yml file and [Here](https://travis-ci.org/shibasisp/python-casacore/builds/256455684) is the travis build log. – Shibasis Patel Jul 22 '17 at 21:50
  • 1
    @randomir Thanks!! I defined `TRAVIS_PYTHON_VERSION` in travis and it worked!! – Shibasis Patel Jul 23 '17 at 10:46

1 Answers1

1

Like @randomir recommended in the comments,
Look at the Travis docs running python on OSX
and be sure you define your TRAVIS_PYTHON_VERSION

joshkmartinez
  • 654
  • 1
  • 12
  • 35