1{
2 stdenv,
3 lib,
4 buildPythonPackage,
5 fetchFromGitHub,
6 cython,
7 ecos,
8 eigen,
9 joblib,
10 numexpr,
11 numpy,
12 osqp,
13 pandas,
14 setuptools-scm,
15 scikit-learn,
16 scipy,
17 pytestCheckHook,
18}:
19
20buildPythonPackage rec {
21 pname = "scikit-survival";
22 version = "0.23.1";
23 pyproject = true;
24
25 src = fetchFromGitHub {
26 owner = "sebp";
27 repo = "scikit-survival";
28 rev = "refs/tags/v${version}";
29 hash = "sha256-6902chXALa73/kTJ5UwV4CrB7/7wn+QXKpp2ej/Dnk8=";
30 };
31
32 nativeBuildInputs = [
33 cython
34 setuptools-scm
35 ];
36
37 propagatedBuildInputs = [
38 ecos
39 joblib
40 numexpr
41 numpy
42 osqp
43 pandas
44 scikit-learn
45 scipy
46 ];
47
48 pythonImportsCheck = [ "sksurv" ];
49
50 nativeCheckInputs = [ pytestCheckHook ];
51
52 # can remove scikit-learn after 0.23.1
53 postPatch = ''
54 ln -s ${lib.getInclude eigen}/include/eigen3/Eigen \
55 sksurv/linear_model/src/eigen
56 sed -i -e 's/numpy>=2.0.0/numpy/' \
57 -e 's/scikit-learn~=1.4.0/scikit-learn/' pyproject.toml
58 '';
59
60 # Hack needed to make pytest + cython work
61 # https://github.com/NixOS/nixpkgs/pull/82410#issuecomment-827186298
62 preCheck = ''
63 export HOME=$(mktemp -d)
64 cp -r $TMP/$sourceRoot/tests $HOME
65 pushd $HOME
66 '';
67 postCheck = "popd";
68
69 # very long tests, unnecessary for a leaf package
70 disabledTests =
71 [
72 "test_coxph"
73 "test_datasets"
74 "test_ensemble_selection"
75 "test_minlip"
76 "test_pandas_inputs"
77 "test_survival_svm"
78 "test_tree"
79 ]
80 ++ lib.optional (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)
81 # floating point mismatch on aarch64
82 # 27079905.88052468 to far from 27079905.880496684
83 "test_coxnet";
84
85 meta = with lib; {
86 description = "Survival analysis built on top of scikit-learn";
87 homepage = "https://github.com/sebp/scikit-survival";
88 license = licenses.gpl3Only;
89 maintainers = with maintainers; [ GuillaumeDesforges ];
90 };
91}