2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
stdenv,
|
|
|
|
buildPythonPackage,
|
2024-07-27 06:49:29 +00:00
|
|
|
pythonOlder,
|
|
|
|
fetchFromGitHub,
|
|
|
|
fetchpatch,
|
|
|
|
|
|
|
|
# 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-07-27 06:49:29 +00:00
|
|
|
version = "1.5.2";
|
|
|
|
pyproject = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
disabled = pythonOlder "3.8";
|
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}";
|
|
|
|
hash = "sha256-g4JVgykGNFT4ZEi5f8hkVjd7eUVJ+LxvPvmiVa86r1Y=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
patches = [
|
|
|
|
# Fix invalid uses of the scipy library
|
|
|
|
# https://github.com/cvxpy/cvxpy/pull/2508
|
|
|
|
(fetchpatch {
|
|
|
|
name = "scipy-1-14-compat";
|
|
|
|
url = "https://github.com/cvxpy/cvxpy/pull/2508/commits/c343f4381c69f7e6b51a86b3eee8b42fbdda9d6a.patch";
|
|
|
|
hash = "sha256-SqIdPs9K+GuCLCEJMHUQ+QGWNH5B3tKuwr46tD9Ao2k=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
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-06-05 15:53:02 +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"
|
|
|
|
# https://github.com/cvxpy/cvxpy/issues/2174
|
|
|
|
"test_scipy_mi_time_limit_reached"
|
|
|
|
]
|
|
|
|
++ lib.optionals stdenv.isAarch64 [
|
|
|
|
"test_ecos_bb_mi_lp_2" # https://github.com/cvxpy/cvxpy/issues/1241#issuecomment-780912155
|
|
|
|
];
|
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
|
|
|
};
|
|
|
|
}
|