Commit 88c89e9a authored by Ben Darwin's avatar Ben Darwin Committed by Rick van Schijndel
Browse files

python3Packages.xgboost: unbreak

- disable remaining tests as these now access network
- add pythonImportsCheck
- unbreaks package on Python 3.10 due to removing broken datatables checkInput
parent a6886cf9
Loading
Loading
Loading
Loading
+11 −34
Original line number Diff line number Diff line
{ lib
, buildPythonPackage
, pytestCheckHook
, pythonOlder
, cmake
, numpy
, scipy
, scikit-learn
, stdenv
, xgboost
, pandas
, matplotlib
, graphviz
, datatable
, hypothesis
}:

buildPythonPackage {
  pname = "xgboost";
  inherit (xgboost) version src meta;

  disabled = pythonOlder "3.8";

  nativeBuildInputs = [ cmake ];
  buildInputs = [ xgboost ];
  propagatedBuildInputs = [ scipy ];
  checkInputs = [
    pytestCheckHook
    scikit-learn
    pandas
    matplotlib
    graphviz
    datatable
    hypothesis
  ];
  propagatedBuildInputs = [ numpy scipy ];

  # Override existing logic for locating libxgboost.so which is not appropriate for Nix
  prePatch = let
@@ -43,24 +31,13 @@ buildPythonPackage {
    cd python-package
  '';

  preCheck = ''
    ln -sf ../demo .
    ln -s ${xgboost}/bin/xgboost ../xgboost
  '';
  # test setup tries to download test data with no option to disable
  # (removing sklearn from checkInputs causes all previously enabled tests to be skipped)
  # and are extremely cpu intensive anyway
  doCheck = false;

  # tests are extremely cpu intensive, only run basic tests to ensure package is working
  pytestFlagsArray = ["../tests/python/test_basic.py"];
  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"
  ] ++ lib.optionals stdenv.isDarwin [
    # fails to connect to the com.apple.fonts daemon in sandboxed mode
    "test_plotting"
    "test_sklearn_plotting"
  pythonImportsCheck = [
    "xgboost"
  ];

  __darwinAllowLocalNetworking = true;