Skip to content

Commit

Permalink
Merge pull request #549 from phunterlau/master
Browse files Browse the repository at this point in the history
Fix data file shipping confusions on pip install for #463
  • Loading branch information
tqchen committed Oct 25, 2015
2 parents d60ee84 + 24a9280 commit 06f502a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
1 change: 0 additions & 1 deletion Makefile
Expand Up @@ -189,7 +189,6 @@ pythonpack:
cp -r multi-node xgboost-deploy/xgboost
cp -r windows xgboost-deploy/xgboost
cp -r src xgboost-deploy/xgboost

#make python

pythonbuild:
Expand Down
7 changes: 7 additions & 0 deletions python-package/MANIFEST.in
Expand Up @@ -5,3 +5,10 @@ recursive-include xgboost/windows *
recursive-include xgboost/subtree *
recursive-include xgboost/src *
recursive-include xgboost/multi-node *
#exclude pre-compiled .o file for less confusions
#include the pre-compiled .so is needed as a placeholder
#since it will be copy after compiling on the fly
global-exclude xgboost/wrapper/*.so.gz
global-exclude xgboost/*.o
global-exclude *.pyo
global-exclude *.pyc
23 changes: 13 additions & 10 deletions python-package/setup.py
Expand Up @@ -2,20 +2,22 @@
"""Setup xgboost package."""
from __future__ import absolute_import
import sys
import os
from setuptools import setup, find_packages
import subprocess
#import subprocess
sys.path.insert(0, '.')

import os
#build on the fly if install in pip
#otherwise, use build.sh in the parent directory

if 'pip' in __file__:
#ugly solution since pip version transition and the old pip detection method not
#working. Manually turn on when packing up for pip installation
if False:
if not os.name == 'nt': #if not windows
build_sh = subprocess.Popen(['sh', 'xgboost/build-python.sh'])
build_sh.wait()
output = build_sh.communicate()
print(output)
os.system('sh ./xgboost/build-python.sh')
else:
print('Windows users please use github installation.')
sys.exit()


CURRENT_DIR = os.path.dirname(__file__)
Expand All @@ -28,15 +30,14 @@
exec(compile(open(libpath_py, "rb").read(), libpath_py, 'exec'), libpath, libpath)

LIB_PATH = libpath['find_lib_path']()
#print LIB_PATH

#to deploy to pip, please use
#make pythonpack
#python setup.py register sdist upload
#and be sure to test it firstly using "python setup.py register sdist upload -r pypitest"
setup(name='xgboost',
version=open(os.path.join(CURRENT_DIR, 'xgboost/VERSION')).read().strip(),
#version='0.4a13',
#version='0.4a23',
description=open(os.path.join(CURRENT_DIR, 'README.md')).read(),
install_requires=[
'numpy',
Expand All @@ -53,5 +54,7 @@
#this will use MANIFEST.in during install where we specify additional files,
#this is the golden line
include_package_data=True,
data_files=[('xgboost', LIB_PATH)],
#!!! don't use data_files, otherwise install_data process will copy it to
#root directory for some machines, and cause confusions on building
#data_files=[('xgboost', LIB_PATH)],
url='https://github.com/dmlc/xgboost')
2 changes: 2 additions & 0 deletions python-package/xgboost/build-python.sh
Expand Up @@ -11,6 +11,8 @@


pushd xgboost
#remove the pre-compiled .so and trigger the system's on-the-fly compiling
make clean
if make python; then
echo "Successfully build multi-thread xgboost"
else
Expand Down

0 comments on commit 06f502a

Please sign in to comment.