Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 pythonOlder, 6 fetchFromGitHub, 7 fetchpatch, 8 9 # build-system 10 numpy, 11 pybind11, 12 setuptools, 13 14 # dependencies 15 clarabel, 16 cvxopt, 17 ecos, 18 osqp, 19 scipy, 20 scs, 21 22 # checks 23 pytestCheckHook, 24 25 useOpenmp ? (!stdenv.isDarwin), 26}: 27 28buildPythonPackage rec { 29 pname = "cvxpy"; 30 version = "1.5.2"; 31 pyproject = true; 32 33 disabled = pythonOlder "3.8"; 34 35 src = fetchFromGitHub { 36 owner = "cvxpy"; 37 repo = "cvxpy"; 38 rev = "refs/tags/v${version}"; 39 hash = "sha256-g4JVgykGNFT4ZEi5f8hkVjd7eUVJ+LxvPvmiVa86r1Y="; 40 }; 41 42 patches = [ 43 # Fix invalid uses of the scipy library 44 # https://github.com/cvxpy/cvxpy/pull/2508 45 (fetchpatch { 46 name = "scipy-1-14-compat"; 47 url = "https://github.com/cvxpy/cvxpy/pull/2508/commits/c343f4381c69f7e6b51a86b3eee8b42fbdda9d6a.patch"; 48 hash = "sha256-SqIdPs9K+GuCLCEJMHUQ+QGWNH5B3tKuwr46tD9Ao2k="; 49 }) 50 ]; 51 52 # we need to patch out numpy version caps from upstream 53 postPatch = '' 54 substituteInPlace pyproject.toml \ 55 --replace-fail "numpy >= 2.0.0" "numpy" 56 ''; 57 58 build-system = [ 59 numpy 60 pybind11 61 setuptools 62 ]; 63 64 dependencies = [ 65 clarabel 66 cvxopt 67 ecos 68 numpy 69 osqp 70 scipy 71 scs 72 ]; 73 74 nativeCheckInputs = [ pytestCheckHook ]; 75 76 # Required flags from https://github.com/cvxpy/cvxpy/releases/tag/v1.1.11 77 preBuild = lib.optionalString useOpenmp '' 78 export CFLAGS="-fopenmp" 79 export LDFLAGS="-lgomp" 80 ''; 81 82 pytestFlagsArray = [ "cvxpy" ]; 83 84 disabledTests = 85 [ 86 # Disable the slowest benchmarking tests, cuts test time in half 87 "test_tv_inpainting" 88 "test_diffcp_sdp_example" 89 "test_huber" 90 "test_partial_problem" 91 # https://github.com/cvxpy/cvxpy/issues/2174 92 "test_scipy_mi_time_limit_reached" 93 ] 94 ++ lib.optionals stdenv.isAarch64 [ 95 "test_ecos_bb_mi_lp_2" # https://github.com/cvxpy/cvxpy/issues/1241#issuecomment-780912155 96 ]; 97 98 pythonImportsCheck = [ "cvxpy" ]; 99 100 meta = { 101 description = "Domain-specific language for modeling convex optimization problems in Python"; 102 homepage = "https://www.cvxpy.org/"; 103 downloadPage = "https://github.com/cvxpy/cvxpy//releases"; 104 changelog = "https://github.com/cvxpy/cvxpy/releases/tag/v${version}"; 105 license = lib.licenses.asl20; 106 maintainers = with lib.maintainers; [ drewrisinger ]; 107 }; 108}