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