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