summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/osqp/default.nix
blob: 393da071a313fc7d8e57b05477e9444f3a90ffb0 (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
102
103
104
105
106
107
108
109
110
111
112
113
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  replaceVars,
  applyPatches,

  # build-system
  cmake,
  ninja,
  scikit-build-core,
  pybind11,
  setuptools-scm,

  # dependencies
  jinja2,
  joblib,
  numpy,
  scipy,

  # tests
  cvxopt,
  pytestCheckHook,
  torch,
}:

let
  qdldl_src = fetchFromGitHub {
    owner = "osqp";
    repo = "qdldl";
    tag = "v0.1.8";
    hash = "sha256-qCeOs4UjZLuqlbiLgp6BMxvw4niduCPDOOqFt05zi2E=";
  };

  osqp_src = applyPatches {
    src = fetchFromGitHub {
      owner = "osqp";
      repo = "osqp";
      tag = "v1.0.0";
      hash = "sha256-BOAytzJzHcggncQzeDrXwJOq8B3doWERJ6CKIVg1yJY=";
    };
    patches = [
      (replaceVars ./dont-fetch-qdldl.patch {
        inherit qdldl_src;
      })
    ];
  };
in

buildPythonPackage rec {
  pname = "osqp";
  version = "1.0.5";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "osqp";
    repo = "osqp-python";
    tag = "v${version}";
    hash = "sha256-i05e0GUQm9DbmF4SDZntKIssrYxC755qG3rRZjYEsiw=";
  };

  patches = [
    (replaceVars ./dont-fetch-osqp.patch {
      inherit osqp_src;
    })
  ];

  build-system = [
    cmake
    ninja
    pybind11
    scikit-build-core
    setuptools-scm
  ];
  dontUseCmakeConfigure = true;

  dependencies = [
    jinja2
    joblib
    numpy
    scipy
  ];

  nativeCheckInputs = [
    cvxopt
    pytestCheckHook
    torch
  ];

  pythonImportsCheck = [ "osqp" ];

  disabledTestPaths = [
    # CalledProcessError
    # Try to invoke `python setup.py build_ext --inplace`
    "src/osqp/tests/codegen_matrices_test.py"
    "src/osqp/tests/codegen_vectors_test.py"
  ];

  meta = {
    description = "Operator Splitting QP Solver";
    longDescription = ''
      Numerical optimization package for solving problems in the form
        minimize        0.5 x' P x + q' x
        subject to      l <= A x <= u

      where x in R^n is the optimization variable
    '';
    homepage = "https://osqp.org/";
    downloadPage = "https://github.com/oxfordcontrol/osqp-python/releases";
    license = lib.licenses.asl20;
    maintainers = [ ];
  };
}