1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 fetchpatch,
7 meson-python,
8 pkg-config,
9 Accelerate,
10 blas,
11 lapack,
12 numpy,
13 scipy,
14 # check inputs
15 pytestCheckHook,
16}:
17
18buildPythonPackage rec {
19 pname = "scs";
20 version = "3.2.4";
21 pyproject = true;
22
23 src = fetchFromGitHub {
24 owner = "bodono";
25 repo = "scs-python";
26 rev = version;
27 hash = "sha256-UmMbnj7QZSvHWSUk1Qa0VP4i3iDCYHxoa+qBmEdFjRs=";
28 fetchSubmodules = true;
29 };
30
31 patches = [
32 # needed for building against netlib's reference blas implementation and
33 # the pkg-config patch. remove on next update
34 (fetchpatch {
35 name = "find-and-ld-lapack.patch";
36 url = "https://github.com/bodono/scs-python/commit/a0aea80e7d490770d6a47d2c79396f6c3341c1f9.patch";
37 hash = "sha256-yHF8f7SLoG7veZ6DEq1HVH6rT2KtFONwJtqSiKcxOdg=";
38 })
39 # add support for pkg-config. remove on next update
40 (fetchpatch {
41 name = "use-pkg-config.patch";
42 url = "https://github.com/bodono/scs-python/commit/dd17e2e5282ebe85f2df8a7c6b25cfdeb894970d.patch";
43 hash = "sha256-vSeSJeeu5Wx3RXPyB39YTo0RU8HtAojrUw85Q76/QzA=";
44 })
45 # fix test_solve_random_cone_prob on linux after scipy 1.12 update
46 # https://github.com/bodono/scs-python/pull/82
47 (fetchpatch {
48 name = "scipy-1.12-fix.patch";
49 url = "https://github.com/bodono/scs-python/commit/4baf4effdc2ce7ac2dd1beaf864f1a5292eb06c6.patch";
50 hash = "sha256-U/F5MakwYZN5hCaeAkcCG38WQxX9mXy9OvhyEQqN038=";
51 })
52 ];
53
54 nativeBuildInputs = [
55 meson-python
56 pkg-config
57 ];
58
59 buildInputs =
60 if stdenv.isDarwin then
61 [ Accelerate ]
62 else
63 [
64 blas
65 lapack
66 ];
67
68 propagatedBuildInputs = [
69 numpy
70 scipy
71 ];
72
73 nativeCheckInputs = [ pytestCheckHook ];
74 pythonImportsCheck = [ "scs" ];
75
76 meta = with lib; {
77 description = "Python interface for SCS: Splitting Conic Solver";
78 longDescription = ''
79 Solves convex cone programs via operator splitting.
80 Can solve: linear programs (LPs), second-order cone programs (SOCPs), semidefinite programs (SDPs),
81 exponential cone programs (ECPs), and power cone programs (PCPs), or problems with any combination of those cones.
82 '';
83 homepage = "https://github.com/cvxgrp/scs"; # upstream C package
84 downloadPage = "https://github.com/bodono/scs-python";
85 license = licenses.mit;
86 maintainers = with maintainers; [ drewrisinger ];
87 };
88}