Fix up make pippack command for building source package for PyPI (#3199)

* Now `make pippack` works without any manual action: it will produce
  xgboost-[version].tar.gz, which one can use by typing
  `pip3 install xgboost-[version].tar.gz`.
* Detect OpenMP-capable compilers (clang, gcc-5, gcc-7) on MacOS
This commit is contained in:
Philip Hyunsu Cho
2018-03-28 10:32:52 -07:00
committed by GitHub
parent ace4016c36
commit 017acf54d9
3 changed files with 53 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# This is a simple script to make xgboost in MAC and Linux for python wrapper only
# Basically, it first try to make with OpenMP, if fails, disable OpenMP and make it again.
# This will automatically make xgboost for MAC users who don't have OpenMP support.
@@ -9,22 +9,44 @@
# note: this script is build for python package only, and it might have some filename
# conflict with build.sh which is for everything.
set -e
set -x
#pushd xgboost
oldpath=`pwd`
cd ./xgboost/
if echo "${OSTYPE}" | grep -q "darwin"; then
LIB_XGBOOST=libxgboost.dylib
# Use OpenMP-capable compiler if possible
if which g++-5; then
export CC=gcc-5
export CXX=g++-5
elif which g++-7; then
export CC=gcc-7
export CXX=g++-7
elif which clang++; then
export CC=clang
export CXX=clang++
fi
else
LIB_XGBOOST=libxgboost.so
fi
#remove the pre-compiled .so and trigger the system's on-the-fly compiling
make clean
if make lib/libxgboost.so -j4; then
if make lib/${LIB_XGBOOST} -j4; then
echo "Successfully build multi-thread xgboost"
else
echo "-----------------------------"
echo "Building multi-thread xgboost failed"
echo "Start to build single-thread xgboost"
make clean
make lib/libxgboost.so -j4 USE_OPENMP=0
make lib/${LIB_XGBOOST} -j4 USE_OPENMP=0
echo "Successfully build single-thread xgboost"
echo "If you want multi-threaded version"
echo "See additional instructions in doc/build.md"
fi
cd $oldpath
set +x