Merge pull request #307098 from r-ryantm/auto-update/cilium-cli
[NixPkgs.git] / pkgs / development / python-modules / cvxpy / default.nix
blob16a5adbf15948b8e453f5578f857173d1b0e1e4a
1 { lib
2 , stdenv
3 , buildPythonPackage
4 , fetchpatch
5 , clarabel
6 , cvxopt
7 , ecos
8 , fetchPypi
9 , numpy
10 , osqp
11 , pytestCheckHook
12 , pythonOlder
13 , scipy
14 , scs
15 , setuptools
16 , wheel
17 , pybind11
18 , useOpenmp ? (!stdenv.isDarwin)
21 buildPythonPackage rec {
22   pname = "cvxpy";
23   version = "1.4.2";
24   format = "pyproject";
26   disabled = pythonOlder "3.7";
28   src = fetchPypi {
29     inherit pname version;
30     hash = "sha256-CjhqV4jb14t7IN0HFSTsY2yPpys2KOafGrxxTI+YEeU=";
31   };
33   patches = [
34     # fix QP tests. remove on next update
35     # https://github.com/cvxpy/cvxpy/pull/2343
36     (fetchpatch {
37       name = "fix-QP-tests.patch";
38       url = "https://github.com/cvxpy/cvxpy/commit/4c8549b9820e64c1b06f5d71c5d3f36528dd4a76.patch";
39       hash = "sha256-43zjS1STEBaGgj1jEOlX3XzMsE4wjoKAk8ApJo98AzY=";
40     })
41   ];
43   # we need to patch out numpy version caps from upstream
44   postPatch = ''
45     sed -i 's/\(numpy>=[0-9.]*\),<[0-9.]*;/\1;/g' pyproject.toml
46   '';
48   nativeBuildInputs = [
49     setuptools
50     wheel
51     pybind11
52   ];
54   propagatedBuildInputs = [
55     clarabel
56     cvxopt
57     ecos
58     numpy
59     osqp
60     scipy
61     scs
62   ];
64   nativeCheckInputs = [
65     pytestCheckHook
66   ];
68   # Required flags from https://github.com/cvxpy/cvxpy/releases/tag/v1.1.11
69   preBuild = lib.optionalString useOpenmp ''
70     export CFLAGS="-fopenmp"
71     export LDFLAGS="-lgomp"
72   '';
74   pytestFlagsArray = [
75     "cvxpy"
76   ];
78   disabledTests = [
79    # Disable the slowest benchmarking tests, cuts test time in half
80     "test_tv_inpainting"
81     "test_diffcp_sdp_example"
82     "test_huber"
83     "test_partial_problem"
84     # https://github.com/cvxpy/cvxpy/issues/2174
85     "test_scipy_mi_time_limit_reached"
86   ] ++ lib.optionals stdenv.isAarch64 [
87     "test_ecos_bb_mi_lp_2" # https://github.com/cvxpy/cvxpy/issues/1241#issuecomment-780912155
88   ];
90   pythonImportsCheck = [
91     "cvxpy"
92   ];
94   meta = with lib; {
95     description = "A domain-specific language for modeling convex optimization problems in Python";
96     homepage = "https://www.cvxpy.org/";
97     downloadPage = "https://github.com/cvxpy/cvxpy//releases";
98     changelog = "https://github.com/cvxpy/cvxpy/releases/tag/v${version}";
99     license = licenses.asl20;
100     maintainers = with maintainers; [ drewrisinger ];
101   };