From 78ae772f2c62754be0b3636f7845d03496469990 Mon Sep 17 00:00:00 2001 From: Dan Harbin Date: Fri, 26 Aug 2016 16:00:11 -0500 Subject: [PATCH] Make python package wheelable (#1500) Currently xgboost can only be installed by running: python setup.py install Now it can be packaged (in binary form) as a wheel and installed like: pip install xgboost-0.6-py2-none-any.whl distutils and wheel install `data_files` differently than setuptools. setuptools will install the `data_files` in the package directory whereas the others install it in `sys.prefix`. By adding `sys.prefix` to the list of directories to check for the shared library, xgboost can now be distributed as a wheel. --- python-package/xgboost/libpath.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python-package/xgboost/libpath.py b/python-package/xgboost/libpath.py index 2d69bda4d..fd53096ab 100644 --- a/python-package/xgboost/libpath.py +++ b/python-package/xgboost/libpath.py @@ -3,6 +3,7 @@ import os import platform +import sys class XGBoostLibraryNotFound(Exception): @@ -21,7 +22,8 @@ def find_lib_path(): curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) # make pythonpack hack: copy this directory one level upper for setup.py dll_path = [curr_path, os.path.join(curr_path, '../../lib/'), - os.path.join(curr_path, './lib/')] + os.path.join(curr_path, './lib/'), + os.path.join(sys.prefix, 'xgboost')] if os.name == 'nt': if platform.architecture()[0] == '64bit': dll_path.append(os.path.join(curr_path, '../../windows/x64/Release/'))