1{ lib
2, stdenv
3, pythonOlder
4, buildPythonPackage
5, fetchPypi
6, cvxopt
7, ecos
8, numpy
9, osqp
10, scipy
11, scs
12, useOpenmp ? (!stdenv.isDarwin)
13 # Check inputs
14, pytestCheckHook
15}:
16
17buildPythonPackage rec {
18 pname = "cvxpy";
19 version = "1.1.12";
20 format = "pyproject";
21
22 disabled = pythonOlder "3.5";
23
24 src = fetchPypi {
25 inherit pname version;
26 hash = "sha256-tJnr+uT8ZF6VI2IVc//LHFtoVKG1wM4dZqippFhgWAc=";
27 };
28
29 propagatedBuildInputs = [
30 cvxopt
31 ecos
32 numpy
33 osqp
34 scipy
35 scs
36 ];
37
38 # Required flags from https://github.com/cvxgrp/cvxpy/releases/tag/v1.1.11
39 preBuild = lib.optional useOpenmp ''
40 export CFLAGS="-fopenmp"
41 export LDFLAGS="-lgomp"
42 '';
43
44 checkInputs = [ pytestCheckHook ];
45 pytestFlagsArray = [ "./cvxpy" ];
46 # Disable the slowest benchmarking tests, cuts test time in half
47 disabledTests = [
48 "test_tv_inpainting"
49 "test_diffcp_sdp_example"
50 ] ++ lib.optionals stdenv.isAarch64 [
51 "test_ecos_bb_mi_lp_2" # https://github.com/cvxgrp/cvxpy/issues/1241#issuecomment-780912155
52 ];
53
54 meta = with lib; {
55 description = "A domain-specific language for modeling convex optimization problems in Python";
56 homepage = "https://www.cvxpy.org/";
57 downloadPage = "https://github.com/cvxgrp/cvxpy/releases";
58 changelog = "https://github.com/cvxgrp/cvxpy/releases/tag/v${version}";
59 license = licenses.asl20;
60 maintainers = with maintainers; [ drewrisinger ];
61 };
62}