diff options
author | Frederik Rietdijk <freddyrietdijk@fridh.nl> | 2018-07-21 11:05:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-21 11:05:44 +0200 |
commit | 7db4c3617ff4e7a0d88320952e320599e75b39db (patch) | |
tree | 3996a31563eb3c33ac62892e3db27811a6970930 | |
parent | 7c8af7e9f9816249d9a174db57e090d56d2c90e7 (diff) | |
parent | 88a35d8bb5e8809e19afca23076c49f23151e187 (diff) | |
download | nixlib-7db4c3617ff4e7a0d88320952e320599e75b39db.tar nixlib-7db4c3617ff4e7a0d88320952e320599e75b39db.tar.gz nixlib-7db4c3617ff4e7a0d88320952e320599e75b39db.tar.bz2 nixlib-7db4c3617ff4e7a0d88320952e320599e75b39db.tar.lz nixlib-7db4c3617ff4e7a0d88320952e320599e75b39db.tar.xz nixlib-7db4c3617ff4e7a0d88320952e320599e75b39db.tar.zst nixlib-7db4c3617ff4e7a0d88320952e320599e75b39db.zip |
Merge pull request #43809 from Ma27/fix-python-xgboost
pythonPackages.xgboost: fix build
-rw-r--r-- | pkgs/development/libraries/xgboost/default.nix | 4 | ||||
-rw-r--r-- | pkgs/development/python-modules/xgboost/default.nix | 30 | ||||
-rw-r--r-- | pkgs/development/python-modules/xgboost/lib-path-for-python.patch | 59 |
3 files changed, 75 insertions, 18 deletions
diff --git a/pkgs/development/libraries/xgboost/default.nix b/pkgs/development/libraries/xgboost/default.nix index 7865724efa40..6ebfd1359dca 100644 --- a/pkgs/development/libraries/xgboost/default.nix +++ b/pkgs/development/libraries/xgboost/default.nix @@ -9,13 +9,13 @@ assert ncclSupport -> cudaSupport; stdenv.mkDerivation rec { name = "xgboost-${version}"; - version = "0.7"; + version = "0.72"; # needs submodules src = fetchgit { url = "https://github.com/dmlc/xgboost"; rev = "refs/tags/v${version}"; - sha256 = "1wxh020l4q037hc5z7vgxflb70l41a97anl8g6y4wxb74l5zv61l"; + sha256 = "1d4kw2jm7d12g8qwi7p9r3429y7sjks9xp9yhvfpx5jh7qakkxj6"; }; enableParallelBuilding = true; diff --git a/pkgs/development/python-modules/xgboost/default.nix b/pkgs/development/python-modules/xgboost/default.nix index 9b53c180397d..d9b8fc892c16 100644 --- a/pkgs/development/python-modules/xgboost/default.nix +++ b/pkgs/development/python-modules/xgboost/default.nix @@ -3,30 +3,28 @@ , nose , scipy , xgboost +, substituteAll }: buildPythonPackage rec { pname = "xgboost"; inherit (xgboost) version src meta; - propagatedBuildInputs = [ scipy ]; - checkInputs = [ nose ]; - - postPatch = let - libname = "libxgboost.${stdenv.hostPlatform.extensions.sharedLibrary}"; + patches = [ + (substituteAll { + src = ./lib-path-for-python.patch; + libpath = "${xgboost}/lib"; + }) + ]; - in '' - cd python-package + postPatch = "cd python-package"; - sed "s/CURRENT_DIR = os.path.dirname(__file__)/CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))/g" -i setup.py - sed "/^LIB_PATH.*/a LIB_PATH = [os.path.relpath(LIB_PATH[0], CURRENT_DIR)]" -i setup.py - cat <<EOF >xgboost/libpath.py - def find_lib_path(): - return ["${xgboost}/lib/${libname}"] - EOF - ''; + propagatedBuildInputs = [ scipy ]; + buildInputs = [ xgboost ]; + checkInputs = [ nose ]; - postInstall = '' - rm -rf $out/xgboost + checkPhase = '' + ln -sf ../demo . + nosetests ../tests/python ''; } diff --git a/pkgs/development/python-modules/xgboost/lib-path-for-python.patch b/pkgs/development/python-modules/xgboost/lib-path-for-python.patch new file mode 100644 index 000000000000..68b39dee53e9 --- /dev/null +++ b/pkgs/development/python-modules/xgboost/lib-path-for-python.patch @@ -0,0 +1,59 @@ +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"] |