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.
This commit is contained in:
Dan Harbin 2016-08-26 16:00:11 -05:00 committed by Tianqi Chen
parent 170b349f3e
commit 78ae772f2c

View File

@ -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/'))