88a35d8bb5
The setup.py of `python-package` contains some path resolution magic to find `libxgboost.so` which is needed for the python API. Unfortunately the code is incompatible with Nix as it isn't compatible with the store-based structure for each package and tries to express the location of the shared object with relative paths. The detection in `setup.py` and `xgboost/libpath.py` has been either removed entirely or patched to link to the proper store path of the `libxgboost` build input. See https://hydra.nixos.org/build/77702715 for further reference.
60 lines
3.1 KiB
Diff
60 lines
3.1 KiB
Diff
diff --git a/python-package/setup.py b/python-package/setup.py
|
|
index e6c3386f..4ed0a8bd 100644
|
|
--- a/python-package/setup.py
|
|
+++ b/python-package/setup.py
|
|
@@ -16,8 +16,6 @@ libpath_py = os.path.join(CURRENT_DIR, 'xgboost/libpath.py')
|
|
libpath = {'__file__': libpath_py}
|
|
exec(compile(open(libpath_py, "rb").read(), libpath_py, 'exec'), libpath, libpath)
|
|
|
|
-LIB_PATH = [os.path.relpath(libfile, CURRENT_DIR) for libfile in libpath['find_lib_path']()]
|
|
-print("Install libxgboost from: %s" % LIB_PATH)
|
|
# Please use setup_pip.py for generating and deploying pip installation
|
|
# detailed instruction in setup_pip.py
|
|
setup(name='xgboost',
|
|
@@ -35,7 +33,6 @@ 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)],
|
|
license='Apache-2.0',
|
|
classifiers=['License :: OSI Approved :: Apache Software License'],
|
|
url='https://github.com/dmlc/xgboost')
|
|
diff --git a/python-package/xgboost/libpath.py b/python-package/xgboost/libpath.py
|
|
index d87922c0..859a30fb 100644
|
|
--- a/python-package/xgboost/libpath.py
|
|
+++ b/python-package/xgboost/libpath.py
|
|
@@ -19,32 +19,4 @@ def find_lib_path():
|
|
lib_path: list(string)
|
|
List of all found library path to xgboost
|
|
"""
|
|
- 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(sys.prefix, 'xgboost')]
|
|
- if sys.platform == 'win32':
|
|
- if platform.architecture()[0] == '64bit':
|
|
- dll_path.append(os.path.join(curr_path, '../../windows/x64/Release/'))
|
|
- # hack for pip installation when copy all parent source directory here
|
|
- dll_path.append(os.path.join(curr_path, './windows/x64/Release/'))
|
|
- else:
|
|
- dll_path.append(os.path.join(curr_path, '../../windows/Release/'))
|
|
- # hack for pip installation when copy all parent source directory here
|
|
- dll_path.append(os.path.join(curr_path, './windows/Release/'))
|
|
- dll_path = [os.path.join(p, 'xgboost.dll') for p in dll_path]
|
|
- elif sys.platform.startswith('linux') or sys.platform.startswith('freebsd'):
|
|
- dll_path = [os.path.join(p, 'libxgboost.so') for p in dll_path]
|
|
- elif sys.platform == 'darwin':
|
|
- dll_path = [os.path.join(p, 'libxgboost.dylib') for p in dll_path]
|
|
-
|
|
- lib_path = [p for p in dll_path if os.path.exists(p) and os.path.isfile(p)]
|
|
-
|
|
- # From github issues, most of installation errors come from machines w/o compilers
|
|
- if not lib_path and not os.environ.get('XGBOOST_BUILD_DOC', False):
|
|
- raise XGBoostLibraryNotFound(
|
|
- 'Cannot find XGBoost Library in the candidate path, ' +
|
|
- 'did you install compilers and run build.sh in root path?\n'
|
|
- 'List of candidates:\n' + ('\n'.join(dll_path)))
|
|
- return lib_path
|
|
+ return ["@libpath@/libxgboost.so"]
|