diff options
| author | Robin Gloster <mail@glob.in> | 2021-05-24 09:55:24 -0500 |
|---|---|---|
| committer | Robin Gloster <mail@glob.in> | 2021-05-24 09:55:24 -0500 |
| commit | 4bc5fbef9d159e143fb7e2c3231932e6e76f667c (patch) | |
| tree | e2198f5c552e0667d838b8ec764ddb3a4d8f6dec /pkgs/development/python-modules/xgboost | |
| parent | jq: fix build with structured-attrs on darwin (diff) | |
| parent | Merge pull request #123802 from superherointj/package-virtmanager-bugfix (diff) | |
| download | nixpkgs-origin/structured-attrs.tar.gz | |
Merge remote-tracking branch 'upstream/master' into structured-attrsorigin/structured-attrs
Diffstat (limited to 'pkgs/development/python-modules/xgboost')
| -rw-r--r-- | pkgs/development/python-modules/xgboost/default.nix | 54 | ||||
| -rw-r--r-- | pkgs/development/python-modules/xgboost/lib-path-for-python.patch | 38 |
2 files changed, 39 insertions, 53 deletions
diff --git a/pkgs/development/python-modules/xgboost/default.nix b/pkgs/development/python-modules/xgboost/default.nix index 81a8d05f5bf0..4f02d72c9a18 100644 --- a/pkgs/development/python-modules/xgboost/default.nix +++ b/pkgs/development/python-modules/xgboost/default.nix @@ -1,8 +1,8 @@ { buildPythonPackage -, pytest -, nose +, pytestCheckHook +, cmake , scipy -, scikitlearn +, scikit-learn , stdenv , xgboost , substituteAll @@ -10,28 +10,52 @@ , matplotlib , graphviz , datatable +, hypothesis }: buildPythonPackage { pname = "xgboost"; inherit (xgboost) version src meta; - patches = [ - (substituteAll { - src = ./lib-path-for-python.patch; - libpath = "${xgboost}/lib"; - extention = stdenv.hostPlatform.extensions.sharedLibrary; - }) + nativeBuildInputs = [ cmake ]; + buildInputs = [ xgboost ]; + propagatedBuildInputs = [ scipy ]; + checkInputs = [ + pytestCheckHook + scikit-learn + pandas + matplotlib + graphviz + datatable + hypothesis ]; - postPatch = "cd python-package"; + # Override existing logic for locating libxgboost.so which is not appropriate for Nix + prePatch = let + libPath = "${xgboost}/lib/libxgboost${stdenv.hostPlatform.extensions.sharedLibrary}"; + in '' + echo 'find_lib_path = lambda: ["${libPath}"]' > python-package/xgboost/libpath.py + ''; - propagatedBuildInputs = [ scipy ]; - buildInputs = [ xgboost ]; - checkInputs = [ nose pytest scikitlearn pandas matplotlib graphviz datatable ]; + dontUseCmakeConfigure = true; - checkPhase = '' + postPatch = '' + cd python-package + ''; + + preCheck = '' ln -sf ../demo . - nosetests ../tests/python + ln -s ${xgboost}/bin/xgboost ../xgboost ''; + + pytestFlagsArray = ["../tests/python"]; + disabledTestPaths = [ + # Requires internet access: https://github.com/dmlc/xgboost/blob/03cd087da180b7dff21bd8ef34997bf747016025/tests/python/test_ranking.py#L81 + "../tests/python/test_ranking.py" + ]; + disabledTests = [ + "test_cli_binary_classification" + "test_model_compatibility" + ]; + } diff --git a/pkgs/development/python-modules/xgboost/lib-path-for-python.patch b/pkgs/development/python-modules/xgboost/lib-path-for-python.patch deleted file mode 100644 index c9252c12fed1..000000000000 --- a/pkgs/development/python-modules/xgboost/lib-path-for-python.patch +++ /dev/null @@ -1,38 +0,0 @@ -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@extention@"] |
