From 7b25834667019e4d301fddc6e1002888b7951e5f Mon Sep 17 00:00:00 2001 From: phunterlau Date: Sun, 18 Oct 2015 17:28:07 -0700 Subject: [PATCH 1/3] fix data file shipping confusions, force system compiling, correct libpath for pip --- Makefile | 1 - python-package/MANIFEST.in | 7 +++++++ python-package/setup.py | 20 ++++++++++++-------- python-package/xgboost/build-python.sh | 2 ++ 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 6685b0c6d..9474ce31c 100644 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/python-package/MANIFEST.in b/python-package/MANIFEST.in index 2d93429a9..01ea397c1 100644 --- a/python-package/MANIFEST.in +++ b/python-package/MANIFEST.in @@ -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 diff --git a/python-package/setup.py b/python-package/setup.py index c9dfa415c..6b5ac2615 100644 --- a/python-package/setup.py +++ b/python-package/setup.py @@ -2,6 +2,7 @@ """Setup xgboost package.""" from __future__ import absolute_import import sys +import os from setuptools import setup, find_packages import subprocess sys.path.insert(0, '.') @@ -10,12 +11,14 @@ 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__) @@ -28,7 +31,6 @@ libpath = {'__file__': libpath_py} 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 @@ -36,7 +38,7 @@ LIB_PATH = libpath['find_lib_path']() #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', @@ -53,5 +55,7 @@ setup(name='xgboost', #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') diff --git a/python-package/xgboost/build-python.sh b/python-package/xgboost/build-python.sh index 398b076b8..ecc336e61 100755 --- a/python-package/xgboost/build-python.sh +++ b/python-package/xgboost/build-python.sh @@ -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 From 8ad58139cdec87ec0cba5fad7b4de24d97aef645 Mon Sep 17 00:00:00 2001 From: phunterlau Date: Sun, 18 Oct 2015 18:55:15 -0700 Subject: [PATCH 2/3] fix pylint warnings --- python-package/setup.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/python-package/setup.py b/python-package/setup.py index 6b5ac2615..652ef49a5 100644 --- a/python-package/setup.py +++ b/python-package/setup.py @@ -4,10 +4,9 @@ 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 @@ -55,7 +54,7 @@ setup(name='xgboost', #this will use MANIFEST.in during install where we specify additional files, #this is the golden line include_package_data=True, - #!!! don't use data_files, otherwise install_data process will copy it to + #!!! 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') From 24a92808dbcb58185d59bf6c529a361e74bacf5f Mon Sep 17 00:00:00 2001 From: phunterlau Date: Wed, 21 Oct 2015 14:32:35 -0700 Subject: [PATCH 3/3] correct print for python 3 --- python-package/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python-package/setup.py b/python-package/setup.py index 652ef49a5..0fa05d858 100644 --- a/python-package/setup.py +++ b/python-package/setup.py @@ -16,7 +16,7 @@ if False: if not os.name == 'nt': #if not windows os.system('sh ./xgboost/build-python.sh') else: - print 'Windows users please use github installation.' + print('Windows users please use github installation.') sys.exit()