summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/scikit-survival/default.nix
blob: b08e0bd6d89b9bf6b6dc19768b3469f311dc4d1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,
  eigen,

  # build-system
  cython,
  numpy,
  packaging,
  scikit-learn,
  setuptools,
  setuptools-scm,

  # dependencies
  ecos,
  joblib,
  numexpr,
  osqp,
  pandas,
  scipy,

  # tests
  pytestCheckHook,
}:

buildPythonPackage rec {
  pname = "scikit-survival";
  version = "0.26.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "sebp";
    repo = "scikit-survival";
    tag = "v${version}";
    hash = "sha256-xtrGFNRHF8bL8Q82gIQLayuCSDFMrBBkQ63F+Nmbdes=";
  };

  postPatch = ''
    ln -s ${lib.getInclude eigen}/include/eigen3/Eigen \
      sksurv/linear_model/src/eigen
  '';

  build-system = [
    cython
    numpy
    packaging
    scikit-learn
    setuptools
    setuptools-scm
  ];

  pythonRelaxDeps = [
    "osqp"
  ];
  dependencies = [
    ecos
    joblib
    numexpr
    numpy
    osqp
    pandas
    scikit-learn
    scipy
  ];

  pythonImportsCheck = [ "sksurv" ];

  nativeCheckInputs = [ pytestCheckHook ];

  # Hack needed to make pytest + cython work
  # https://github.com/NixOS/nixpkgs/pull/82410#issuecomment-827186298
  preCheck = ''
    rm -rf sksurv
  '';

  disabledTests = [
    # very long tests, unnecessary for a leaf package
    "test_coxph"
    "test_datasets"
    "test_ensemble_selection"
    "test_minlip"
    "test_pandas_inputs"
    "test_survival_svm"
    "test_tree"
  ]
  ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
    # floating point mismatch on aarch64
    # 27079905.88052468 to far from 27079905.880496684
    "test_coxnet"
  ];

  meta = {
    description = "Survival analysis built on top of scikit-learn";
    homepage = "https://github.com/sebp/scikit-survival";
    changelog = "https://github.com/sebp/scikit-survival/releases/tag/v${version}";
    license = lib.licenses.gpl3Plus;
    maintainers = [ ];
  };
}