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, wheel
15, useOpenmp ? (!stdenv.isDarwin)
16}:
17
18buildPythonPackage rec {
19 pname = "cvxpy";
20 version = "1.3.2";
21 format = "pyproject";
22
23 disabled = pythonOlder "3.7";
24
25 src = fetchPypi {
26 inherit pname version;
27 hash = "sha256-C2heUEDxmfPXA/MPXSLR+GVZdiNFUVPR3ddwJFrvCXU=";
28 };
29
30 # we need to patch out numpy version caps from upstream
31 postPatch = ''
32 sed -i 's/\(numpy>=[0-9.]*\),<[0-9.]*;/\1;/g' pyproject.toml
33 '';
34
35 nativeBuildInputs = [
36 setuptools
37 wheel
38 ];
39
40 propagatedBuildInputs = [
41 cvxopt
42 ecos
43 numpy
44 osqp
45 scipy
46 scs
47 setuptools
48 ];
49
50 nativeCheckInputs = [
51 pytestCheckHook
52 ];
53
54 # Required flags from https://github.com/cvxpy/cvxpy/releases/tag/v1.1.11
55 preBuild = lib.optionalString useOpenmp ''
56 export CFLAGS="-fopenmp"
57 export LDFLAGS="-lgomp"
58 '';
59
60 pytestFlagsArray = [
61 "cvxpy"
62 ];
63
64 disabledTests = [
65 # Disable the slowest benchmarking tests, cuts test time in half
66 "test_tv_inpainting"
67 "test_diffcp_sdp_example"
68 "test_huber"
69 "test_partial_problem"
70 # https://github.com/cvxpy/cvxpy/issues/2174
71 "test_scipy_mi_time_limit_reached"
72 ] ++ lib.optionals stdenv.isAarch64 [
73 "test_ecos_bb_mi_lp_2" # https://github.com/cvxpy/cvxpy/issues/1241#issuecomment-780912155
74 ];
75
76 pythonImportsCheck = [
77 "cvxpy"
78 ];
79
80 meta = with lib; {
81 description = "A domain-specific language for modeling convex optimization problems in Python";
82 homepage = "https://www.cvxpy.org/";
83 downloadPage = "https://github.com/cvxpy/cvxpy//releases";
84 changelog = "https://github.com/cvxpy/cvxpy/releases/tag/v${version}";
85 license = licenses.asl20;
86 maintainers = with maintainers; [ drewrisinger ];
87 };
88}