1{
2 lib,
3 buildPythonPackage,
4 fetchPypi,
5 numpy,
6 cvxopt,
7 python,
8 networkx,
9 scipy,
10 pythonOlder,
11 stdenv,
12}:
13
14buildPythonPackage rec {
15 pname = "picos";
16 version = "2.6.1";
17 format = "setuptools";
18
19 src = fetchPypi {
20 inherit pname version;
21 hash = "sha256-u9yaKeP34YW55+PyVy3wPR0p0jBmiLywvZzw2zWdd6g=";
22 };
23
24 # Needed only for the tests
25 nativeCheckInputs = [ networkx ];
26
27 dependencies = [
28 numpy
29 cvxopt
30 scipy
31 ];
32
33 postPatch =
34 lib.optionalString (pythonOlder "3.12") ''
35 substituteInPlace picos/modeling/problem.py \
36 --replace-fail "mappingproxy(OrderedDict({'x': <3×1 Real Variable: x>}))" "mappingproxy(OrderedDict([('x', <3×1 Real Variable: x>)]))"
37 ''
38 # TypeError: '<=' not supported between instances of 'ComplexAffineExpression' and 'float'
39 + lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) ''
40 rm tests/ptest_quantentr.py
41 '';
42
43 checkPhase = ''
44 runHook preCheck
45
46 ${python.interpreter} test.py
47
48 runHook postCheck
49 '';
50
51 meta = {
52 description = "Python interface to conic optimization solvers";
53 homepage = "https://gitlab.com/picos-api/picos";
54 license = lib.licenses.gpl3;
55 maintainers = with lib.maintainers; [ tobiasBora ];
56 };
57}