Make pip install xgboost*.tar.gz work by fixing build-python.sh (#5241)
* Make pip install xgboost*.tar.gz work by fixing build-python.sh * Simplify install doc * Add test * Install Miniconda for Linux target too * Build XGBoost only once in sdist * Try importing xgboost after installation * Don't set PYTHONPATH env var for sdist test
This commit is contained in:
parent
cb3ed404cf
commit
4240daed4e
15
.travis.yml
15
.travis.yml
@ -3,20 +3,33 @@ sudo: required
|
|||||||
|
|
||||||
# Enabling test OS X
|
# Enabling test OS X
|
||||||
os:
|
os:
|
||||||
|
- linux
|
||||||
- osx
|
- osx
|
||||||
|
|
||||||
osx_image: xcode10.3
|
osx_image: xcode10.3
|
||||||
|
dist: bionic
|
||||||
|
|
||||||
# Use Build Matrix to do lint and build seperately
|
# Use Build Matrix to do lint and build seperately
|
||||||
env:
|
env:
|
||||||
matrix:
|
matrix:
|
||||||
# python package test
|
# python package test
|
||||||
- TASK=python_test
|
- TASK=python_test
|
||||||
|
# test installation of Python source distribution
|
||||||
|
- TASK=python_sdist_test
|
||||||
# java package test
|
# java package test
|
||||||
- TASK=java_test
|
- TASK=java_test
|
||||||
# cmake test
|
# cmake test
|
||||||
- TASK=cmake_test
|
- TASK=cmake_test
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
exclude:
|
||||||
|
- os: linux
|
||||||
|
env: TASK=python_test
|
||||||
|
- os: linux
|
||||||
|
env: TASK=java_test
|
||||||
|
- os: linux
|
||||||
|
env: TASK=cmake_test
|
||||||
|
|
||||||
# dependent brew packages
|
# dependent brew packages
|
||||||
addons:
|
addons:
|
||||||
homebrew:
|
homebrew:
|
||||||
@ -32,7 +45,7 @@ addons:
|
|||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- source dmlc-core/scripts/travis/travis_setup_env.sh
|
- source dmlc-core/scripts/travis/travis_setup_env.sh
|
||||||
- export PYTHONPATH=${PYTHONPATH}:${PWD}/python-package
|
- if [ "${TASK}" != "python_sdist_test" ]; then export PYTHONPATH=${PYTHONPATH}:${PWD}/python-package; fi
|
||||||
- echo "MAVEN_OPTS='-Xmx2g -XX:MaxPermSize=1024m -XX:ReservedCodeCacheSize=512m -Dorg.slf4j.simpleLogger.defaultLogLevel=error'" > ~/.mavenrc
|
- echo "MAVEN_OPTS='-Xmx2g -XX:MaxPermSize=1024m -XX:ReservedCodeCacheSize=512m -Dorg.slf4j.simpleLogger.defaultLogLevel=error'" > ~/.mavenrc
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
|||||||
4
Makefile
4
Makefile
@ -221,7 +221,9 @@ pippack: clean_all
|
|||||||
rm -rf python-package/xgboost/rabit
|
rm -rf python-package/xgboost/rabit
|
||||||
rm -rf python-package/xgboost/src
|
rm -rf python-package/xgboost/src
|
||||||
cp -r python-package xgboost-python
|
cp -r python-package xgboost-python
|
||||||
cp -r Makefile xgboost-python/xgboost/
|
cp -r CMakeLists.txt xgboost-python/xgboost/
|
||||||
|
cp -r cmake xgboost-python/xgboost/
|
||||||
|
cp -r plugin xgboost-python/xgboost/
|
||||||
cp -r make xgboost-python/xgboost/
|
cp -r make xgboost-python/xgboost/
|
||||||
cp -r src xgboost-python/xgboost/
|
cp -r src xgboost-python/xgboost/
|
||||||
cp -r tests xgboost-python/xgboost/
|
cp -r tests xgboost-python/xgboost/
|
||||||
|
|||||||
@ -98,11 +98,11 @@ Building on OSX
|
|||||||
Install with pip: simple method
|
Install with pip: simple method
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
First, obtain ``gcc-9`` and ``OpenMP`` with Homebrew (https://brew.sh/) to enable multi-threading (i.e. using multiple CPU threads for training). The default Apple Clang compiler does not support OpenMP, so using the default compiler would have disabled multi-threading.
|
First, obtain the OpenMP library (``libomp``) with Homebrew (https://brew.sh/) to enable multi-threading (i.e. using multiple CPU threads for training):
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
brew install gcc@9 libomp
|
brew install libomp
|
||||||
|
|
||||||
Then install XGBoost with ``pip``:
|
Then install XGBoost with ``pip``:
|
||||||
|
|
||||||
@ -115,11 +115,11 @@ You might need to run the command with ``--user`` flag if you run into permissio
|
|||||||
Build from the source code - advanced method
|
Build from the source code - advanced method
|
||||||
--------------------------------------------
|
--------------------------------------------
|
||||||
|
|
||||||
Obtain ``gcc-9`` and ``OpenMP`` from Homebrew:
|
Obtain ``libomp`` from Homebrew:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
brew install gcc@9 libomp
|
brew install libomp
|
||||||
|
|
||||||
|
|
||||||
Now clone the repository:
|
Now clone the repository:
|
||||||
@ -128,13 +128,13 @@ Now clone the repository:
|
|||||||
|
|
||||||
git clone --recursive https://github.com/dmlc/xgboost
|
git clone --recursive https://github.com/dmlc/xgboost
|
||||||
|
|
||||||
Create the ``build/`` directory and invoke CMake. Make sure to add ``CC=gcc-9 CXX=g++-9`` so that Homebrew GCC is selected. After invoking CMake, you can build XGBoost with ``make``:
|
Create the ``build/`` directory and invoke CMake. After invoking CMake, you can build XGBoost with ``make``:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
CC=gcc-9 CXX=g++-9 cmake ..
|
cmake ..
|
||||||
make -j4
|
make -j4
|
||||||
|
|
||||||
You may now continue to `Python Package Installation`_.
|
You may now continue to `Python Package Installation`_.
|
||||||
|
|||||||
@ -12,47 +12,22 @@
|
|||||||
set -e
|
set -e
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
#pushd xgboost
|
|
||||||
oldpath=`pwd`
|
oldpath=`pwd`
|
||||||
cd ./xgboost/
|
cd ./xgboost/
|
||||||
|
|
||||||
GCC_PATH=""
|
|
||||||
if echo "${OSTYPE}" | grep -q "darwin"; then
|
|
||||||
# Use OpenMP-capable compiler if possible
|
|
||||||
if [ "v"`sw_vers -buildVersion` -ge "v17G65" ]; then
|
|
||||||
if which g++-9; then
|
|
||||||
GCC_PATH="CC=gcc-9 CXX=g++-9"
|
|
||||||
else
|
|
||||||
echo "For MacOS version higher than High Sierra, please install gcc@9 first."
|
|
||||||
fi
|
|
||||||
elif which g++-5; then
|
|
||||||
GCC_PATH="CC=gcc-5 CXX=g++-5"
|
|
||||||
elif which g++-7; then
|
|
||||||
GCC_PATH="CC=gcc-7 CXX=g++-7"
|
|
||||||
elif which g++-8; then
|
|
||||||
GCC_PATH="CC=gcc-8 CXX=g++-8"
|
|
||||||
elif which clang++; then
|
|
||||||
GCC_PATH="CC=clang CXX=clang++"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
#remove the pre-compiled .so and trigger the system's on-the-fly compiling
|
#remove the pre-compiled .so and trigger the system's on-the-fly compiling
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
cd build
|
cd build
|
||||||
if [ -f * ]; then
|
if cmake .. && make -j4; then
|
||||||
rm -r *
|
echo "Successfully built multi-thread xgboost"
|
||||||
fi
|
|
||||||
if eval $GCC_PATH" cmake .." && eval $GCC_PATH" make -j4"; then
|
|
||||||
echo "Successfully build multi-thread xgboost"
|
|
||||||
else
|
else
|
||||||
echo "-----------------------------"
|
echo "-----------------------------"
|
||||||
echo "Building multi-thread xgboost failed"
|
echo "Building multi-thread xgboost failed"
|
||||||
echo "Start to build single-thread xgboost"
|
echo "Start to build single-thread xgboost"
|
||||||
eval $GCC_PATH" cmake .. -DUSE_OPENMP=0"
|
cmake .. -DUSE_OPENMP=0
|
||||||
eval $GCC_PATH" make -j4"
|
make -j4
|
||||||
echo "Successfully build single-thread xgboost"
|
echo "Successfully built single-thread xgboost; training speed may be suboptimal."
|
||||||
echo "If you want multi-threaded version"
|
echo "To use all CPU cores for training jobs, install libomp package from Homebrew and re-install XGBoost"
|
||||||
echo "See additional instructions in doc/build.md"
|
|
||||||
fi
|
fi
|
||||||
cd $oldpath
|
cd $oldpath
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,18 @@ make -f dmlc-core/scripts/packages.mk lz4
|
|||||||
|
|
||||||
source $HOME/miniconda/bin/activate
|
source $HOME/miniconda/bin/activate
|
||||||
|
|
||||||
|
if [ ${TASK} == "python_sdist_test" ]; then
|
||||||
|
set -e
|
||||||
|
make pippack
|
||||||
|
|
||||||
|
conda activate python3
|
||||||
|
python --version
|
||||||
|
conda install numpy scipy
|
||||||
|
|
||||||
|
python -m pip install xgboost-*.tar.gz -v --user
|
||||||
|
python -c 'import xgboost' || exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ${TASK} == "python_test" ]; then
|
if [ ${TASK} == "python_test" ]; then
|
||||||
set -e
|
set -e
|
||||||
# Build/test
|
# Build/test
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [ ${TASK} == "python_test" ]; then
|
if [ ${TASK} == "python_test" ] || [ ${TASK} == "python_sdist_test" ]; then
|
||||||
if [ ${TRAVIS_OS_NAME} == "osx" ]; then
|
if [ ${TRAVIS_OS_NAME} == "osx" ]; then
|
||||||
wget -O conda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
|
wget -O conda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
|
||||||
else
|
else
|
||||||
echo "We are no longer running Linux test on Travis."
|
wget -O conda.sh https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
bash conda.sh -b -p $HOME/miniconda
|
bash conda.sh -b -p $HOME/miniconda
|
||||||
source $HOME/miniconda/bin/activate
|
source $HOME/miniconda/bin/activate
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user