2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
stdenv,
|
|
|
|
buildPythonPackage,
|
2024-07-27 06:49:29 +00:00
|
|
|
pythonOlder,
|
|
|
|
fetchFromGitHub,
|
|
|
|
|
|
|
|
# build-system
|
|
|
|
numpy,
|
|
|
|
pybind11,
|
|
|
|
setuptools,
|
|
|
|
|
|
|
|
# dependencies
|
2024-06-05 15:53:02 +00:00
|
|
|
clarabel,
|
|
|
|
cvxopt,
|
|
|
|
ecos,
|
|
|
|
osqp,
|
|
|
|
scipy,
|
|
|
|
scs,
|
2024-07-27 06:49:29 +00:00
|
|
|
|
|
|
|
# checks
|
|
|
|
pytestCheckHook,
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
useOpenmp ? (!stdenv.isDarwin),
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "cvxpy";
|
2024-09-19 14:19:46 +00:00
|
|
|
version = "1.5.3";
|
2024-07-27 06:49:29 +00:00
|
|
|
pyproject = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
disabled = pythonOlder "3.9";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "cvxpy";
|
|
|
|
repo = "cvxpy";
|
|
|
|
rev = "refs/tags/v${version}";
|
2024-09-19 14:19:46 +00:00
|
|
|
hash = "sha256-6RaEyFckvF3WhbfeffysMB/zt+aU1NU6B7Nm06znt9k=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-08-22 20:05:09 +00:00
|
|
|
# we need to patch out numpy version caps from upstream
|
|
|
|
postPatch = ''
|
2024-07-27 06:49:29 +00:00
|
|
|
substituteInPlace pyproject.toml \
|
|
|
|
--replace-fail "numpy >= 2.0.0" "numpy"
|
2023-08-22 20:05:09 +00:00
|
|
|
'';
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
build-system = [
|
|
|
|
numpy
|
2023-11-16 04:20:00 +00:00
|
|
|
pybind11
|
2024-07-27 06:49:29 +00:00
|
|
|
setuptools
|
2023-08-22 20:05:09 +00:00
|
|
|
];
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
dependencies = [
|
2024-01-25 14:12:00 +00:00
|
|
|
clarabel
|
2020-04-24 23:36:52 +00:00
|
|
|
cvxopt
|
|
|
|
ecos
|
|
|
|
numpy
|
|
|
|
osqp
|
|
|
|
scipy
|
|
|
|
scs
|
|
|
|
];
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
nativeCheckInputs = [ pytestCheckHook ];
|
2023-05-24 13:37:59 +00:00
|
|
|
|
|
|
|
# Required flags from https://github.com/cvxpy/cvxpy/releases/tag/v1.1.11
|
2021-08-22 07:53:02 +00:00
|
|
|
preBuild = lib.optionalString useOpenmp ''
|
2021-04-13 19:44:15 +00:00
|
|
|
export CFLAGS="-fopenmp"
|
|
|
|
export LDFLAGS="-lgomp"
|
|
|
|
'';
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
pytestFlagsArray = [ "cvxpy" ];
|
2021-07-04 02:40:35 +00:00
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
disabledTests = [
|
|
|
|
# Disable the slowest benchmarking tests, cuts test time in half
|
|
|
|
"test_tv_inpainting"
|
|
|
|
"test_diffcp_sdp_example"
|
|
|
|
"test_huber"
|
|
|
|
"test_partial_problem"
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
pythonImportsCheck = [ "cvxpy" ];
|
2021-07-04 02:40:35 +00:00
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
meta = {
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "Domain-specific language for modeling convex optimization problems in Python";
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://www.cvxpy.org/";
|
2023-05-24 13:37:59 +00:00
|
|
|
downloadPage = "https://github.com/cvxpy/cvxpy//releases";
|
|
|
|
changelog = "https://github.com/cvxpy/cvxpy/releases/tag/v${version}";
|
2024-07-27 06:49:29 +00:00
|
|
|
license = lib.licenses.asl20;
|
|
|
|
maintainers = with lib.maintainers; [ drewrisinger ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|