at master 2.1 kB view raw
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 fetchFromGitHub, 6 7 # build-system 8 numpy, 9 pybind11, 10 setuptools, 11 12 # dependencies 13 clarabel, 14 cvxopt, 15 osqp, 16 scipy, 17 scs, 18 19 # tests 20 hypothesis, 21 pytestCheckHook, 22 23 useOpenmp ? (!stdenv.hostPlatform.isDarwin), 24}: 25 26buildPythonPackage rec { 27 pname = "cvxpy"; 28 version = "1.7.3"; 29 pyproject = true; 30 31 src = fetchFromGitHub { 32 owner = "cvxpy"; 33 repo = "cvxpy"; 34 tag = "v${version}"; 35 hash = "sha256-ge1M5yAu7Dzkmun+Zy2rRyYVggcTZyG9JlI2B2Q6V38="; 36 }; 37 38 postPatch = 39 # too tight tolerance in tests (AssertionError) 40 '' 41 substituteInPlace cvxpy/tests/test_constant_atoms.py \ 42 --replace-fail \ 43 "CLARABEL: 1e-7," \ 44 "CLARABEL: 1e-6," 45 ''; 46 47 build-system = [ 48 numpy 49 pybind11 50 setuptools 51 ]; 52 53 dependencies = [ 54 clarabel 55 cvxopt 56 numpy 57 osqp 58 scipy 59 scs 60 ]; 61 62 nativeCheckInputs = [ 63 hypothesis 64 pytestCheckHook 65 ]; 66 67 # Required flags from https://github.com/cvxpy/cvxpy/releases/tag/v1.1.11 68 preBuild = lib.optionalString useOpenmp '' 69 export CFLAGS="-fopenmp" 70 export LDFLAGS="-lgomp" 71 ''; 72 73 enabledTestPaths = [ "cvxpy" ]; 74 75 disabledTests = [ 76 # Disable the slowest benchmarking tests, cuts test time in half 77 "test_tv_inpainting" 78 "test_diffcp_sdp_example" 79 "test_huber" 80 "test_partial_problem" 81 82 # cvxpy.error.SolverError: Solver 'CVXOPT' failed. Try another solver, or solve with verbose=True for more information. 83 # https://github.com/cvxpy/cvxpy/issues/1588 84 "test_oprelcone_1_m1_k3_complex" 85 "test_oprelcone_1_m3_k1_complex" 86 "test_oprelcone_2" 87 ]; 88 89 pythonImportsCheck = [ "cvxpy" ]; 90 91 meta = { 92 description = "Domain-specific language for modeling convex optimization problems in Python"; 93 homepage = "https://www.cvxpy.org/"; 94 downloadPage = "https://github.com/cvxpy/cvxpy//releases"; 95 changelog = "https://github.com/cvxpy/cvxpy/releases/tag/v${version}"; 96 license = lib.licenses.asl20; 97 maintainers = with lib.maintainers; [ drewrisinger ]; 98 }; 99}