Skip to content

Commit

Permalink
travis osx support (#642)
Browse files Browse the repository at this point in the history
* support travis osx

* add task=pip

* add osx task=pip

* fix gpu build

* add if-else task

* fix if-else task
  • Loading branch information
wxchan authored and guolinke committed Jun 22, 2017
1 parent 8699357 commit d862b3e
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 56 deletions.
84 changes: 28 additions & 56 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,43 @@ language: cpp
sudo: required
dist: trusty

compiler:
- gcc

matrix:
include:
- os: linux
env: TASK=regular
- os: linux
env: TASK=mpi
- os: linux
env: TASK=gpu
- os: linux
env: TASK=pip
- os: linux
env: TASK=pylint
- os: linux
env: TASK=if-else
- os: osx
env: TASK=regular
- os: osx
env: TASK=mpi
- os: osx
env: TASK=pip

before_install:
- test -n $CC && unset CC
- test -n $CXX && unset CXX
- wget -O conda.sh https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
- chmod +x conda.sh

install:
- bash .travis/setup.sh
- bash conda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
- sudo add-apt-repository ppa:george-edison55/cmake-3.x -y
- sudo apt-get update -q
- bash .travis/amd_sdk.sh;
- tar -xjf AMD-SDK.tar.bz2;
- AMDAPPSDK=${HOME}/AMDAPPSDK;
- export OPENCL_VENDOR_PATH=${AMDAPPSDK}/etc/OpenCL/vendors;
- mkdir -p ${OPENCL_VENDOR_PATH};
- sh AMD-APP-SDK*.sh --tar -xf -C ${AMDAPPSDK};
- echo libamdocl64.so > ${OPENCL_VENDOR_PATH}/amdocl64.icd;
- export LD_LIBRARY_PATH=${AMDAPPSDK}/lib/x86_64:${LD_LIBRARY_PATH};
- chmod +x ${AMDAPPSDK}/bin/x86_64/clinfo;
- ${AMDAPPSDK}/bin/x86_64/clinfo;
- export LIBRARY_PATH="$HOME/miniconda/lib:$LIBRARY_PATH"
- export LD_RUN_PATH="$HOME/miniconda/lib:$LD_RUN_PATH"
- export CPLUS_INCLUDE_PATH="$HOME/miniconda/include:$AMDAPPSDK/include/:$CPLUS_INCLUDE_PATH"

install:
- sudo apt-get install -y libopenmpi-dev openmpi-bin build-essential
- sudo apt-get install -y cmake
- conda install --yes atlas numpy scipy scikit-learn pandas matplotlib
- conda install --yes -c conda-forge boost=1.63.0
- pip install pep8 pytest

script:
- cd $TRAVIS_BUILD_DIR
- mkdir build && cd build && cmake -DUSE_MPI=ON ..&& make _lightgbm
- cd $TRAVIS_BUILD_DIR/python-package && python setup.py install --precompile
- cd $TRAVIS_BUILD_DIR && pytest tests/c_api_test/test.py
- cd $TRAVIS_BUILD_DIR && pytest tests/python_package_test
- cd $TRAVIS_BUILD_DIR && pep8 --ignore=E501 --exclude=./compute,./docs .
- cd $TRAVIS_BUILD_DIR
- rm -rf build && mkdir build && cd build && cmake -DUSE_GPU=ON -DBOOST_ROOT="$HOME/miniconda/" -DOpenCL_INCLUDE_DIR=$AMDAPPSDK/include/ ..
- sed -i 's/std::string device_type = "cpu";/std::string device_type = "gpu";/' ../include/LightGBM/config.h
- make _lightgbm
- sed -i 's/std::string device_type = "gpu";/std::string device_type = "cpu";/' ../include/LightGBM/config.h
- cd $TRAVIS_BUILD_DIR/python-package && python setup.py install --precompile
- cd $TRAVIS_BUILD_DIR && pytest tests/c_api_test/test.py
- cd $TRAVIS_BUILD_DIR && pytest tests/python_package_test
- cd $TRAVIS_BUILD_DIR
- rm -rf build && rm -f lib_lightgbm.so
- cd $TRAVIS_BUILD_DIR/python-package && python setup.py install
- cd $TRAVIS_BUILD_DIR && pytest tests/python_package_test
- cd $TRAVIS_BUILD_DIR
- LGB_VER=$(head -n 1 VERSION.txt)
- cd $TRAVIS_BUILD_DIR/python-package && python setup.py sdist
- cd $TRAVIS_BUILD_DIR/python-package/dist && pip install lightgbm-$LGB_VER.tar.gz -v
- cd $TRAVIS_BUILD_DIR && pytest tests/python_package_test
- cd $TRAVIS_BUILD_DIR
- rm -rf build && mkdir build && cd build && cmake .. && make lightgbm
- cd $TRAVIS_BUILD_DIR/tests/cpp_test && ../../lightgbm config=train.conf && ../../lightgbm config=predict.conf output_result=origin.pred
- cd $TRAVIS_BUILD_DIR/build && make lightgbm
- cd $TRAVIS_BUILD_DIR/tests/cpp_test && ../../lightgbm config=predict.conf output_result=ifelse.pred && python test.py
- bash .travis/test.sh

notifications:
email: false

matrix:
include:
- compiler: gcc
16 changes: 16 additions & 0 deletions .travis/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

if [[ $TRAVIS_OS_NAME == "osx" ]]; then
brew install cmake
brew install openmpi
brew install gcc --without-multilib
wget -O conda.sh https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
else
if [[ ${TASK} != "pylint" ]]; then
sudo add-apt-repository ppa:george-edison55/cmake-3.x -y
sudo apt-get update -q
sudo apt-get install -y cmake
sudo apt-get install -y libopenmpi-dev openmpi-bin build-essential
fi
wget -O conda.sh https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
fi
63 changes: 63 additions & 0 deletions .travis/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
if [[ ${TASK} == "gpu" ]]; then
bash .travis/amd_sdk.sh;
tar -xjf AMD-SDK.tar.bz2;
AMDAPPSDK=${HOME}/AMDAPPSDK;
export OPENCL_VENDOR_PATH=${AMDAPPSDK}/etc/OpenCL/vendors;
mkdir -p ${OPENCL_VENDOR_PATH};
sh AMD-APP-SDK*.sh --tar -xf -C ${AMDAPPSDK};
echo libamdocl64.so > ${OPENCL_VENDOR_PATH}/amdocl64.icd;
export LD_LIBRARY_PATH=${AMDAPPSDK}/lib/x86_64:${LD_LIBRARY_PATH};
chmod +x ${AMDAPPSDK}/bin/x86_64/clinfo;
${AMDAPPSDK}/bin/x86_64/clinfo;
export LIBRARY_PATH="$HOME/miniconda/lib:$LIBRARY_PATH"
export LD_RUN_PATH="$HOME/miniconda/lib:$LD_RUN_PATH"
export CPLUS_INCLUDE_PATH="$HOME/miniconda/include:$AMDAPPSDK/include/:$CPLUS_INCLUDE_PATH"
fi

cd $TRAVIS_BUILD_DIR

if [[ ${TASK} == "pylint" ]]; then
pip install pep8
pep8 --ignore=E501 --exclude=./compute,./docs . || exit -1
exit 0
fi

if [[ ${TASK} == "if-else" ]]; then
conda install --yes numpy
mkdir build && cd build && cmake .. && make lightgbm || exit -1
cd $TRAVIS_BUILD_DIR/tests/cpp_test && ../../lightgbm config=train.conf && ../../lightgbm config=predict.conf output_result=origin.pred || exit -1
cd $TRAVIS_BUILD_DIR/build && make lightgbm || exit -1
cd $TRAVIS_BUILD_DIR/tests/cpp_test && ../../lightgbm config=predict.conf output_result=ifelse.pred && python test.py || exit -1
exit 0
fi

conda install --yes numpy scipy scikit-learn pandas matplotlib
pip install pytest

if [[ ${TASK} == "pip" ]]; then
LGB_VER=$(head -n 1 VERSION.txt)
cd $TRAVIS_BUILD_DIR/python-package && python setup.py sdist || exit -1
cd $TRAVIS_BUILD_DIR/python-package/dist && pip install lightgbm-$LGB_VER.tar.gz -v || exit -1
cd $TRAVIS_BUILD_DIR && pytest tests/python_package_test || exit -1
exit 0
fi

if [[ ${TASK} == "gpu" ]]; then
conda install --yes -c conda-forge boost=1.63.0
fi

mkdir build && cd build

if [[ ${TASK} == "mpi" ]]; then
cmake -DUSE_MPI=ON ..
elif [[ ${TASK} == "gpu" ]]; then
cmake -DUSE_GPU=ON -DBOOST_ROOT="$HOME/miniconda/" -DOpenCL_INCLUDE_DIR=$AMDAPPSDK/include/ ..
sed -i 's/std::string device_type = "cpu";/std::string device_type = "gpu";/' ../include/LightGBM/config.h
else
cmake ..
fi

make _lightgbm || exit -1

cd $TRAVIS_BUILD_DIR/python-package && python setup.py install --precompile || exit -1
cd $TRAVIS_BUILD_DIR && pytest . || exit -1

0 comments on commit d862b3e

Please sign in to comment.