1{ stdenv
2, lib
3, buildPythonPackage
4, fetchPypi
5, isPyPy
6, python
7, openblas
8, blas
9, lapack # build segfaults with 64-bit blas
10, suitesparse
11, unittestCheckHook
12, glpk ? null
13, gsl ? null
14, fftw ? null
15, withGlpk ? true
16, withGsl ? true
17, withFftw ? true
18}:
19
20assert (!blas.isILP64) && (!lapack.isILP64);
21
22buildPythonPackage rec {
23 pname = "cvxopt";
24 version = "1.3.2";
25
26 disabled = isPyPy; # hangs at [translation:info]
27
28 src = fetchPypi {
29 inherit pname version;
30 hash = "sha256-NGH6QsGyJAuk2h2YXKc1A5FBV/xMd0FzJ+1tfYWs2+Y=";
31 };
32
33 buildInputs = (if stdenv.isDarwin then [ openblas ] else [ blas lapack ]);
34 doCheck = !stdenv.isDarwin;
35
36 # similar to Gsl, glpk, fftw there is also a dsdp interface
37 # but dsdp is not yet packaged in nixpkgs
38 preConfigure = (if stdenv.isDarwin then
39 ''
40 export CVXOPT_BLAS_LIB=openblas
41 export CVXOPT_LAPACK_LIB=openblas
42 ''
43 else
44 ''
45 export CVXOPT_BLAS_LIB=blas
46 export CVXOPT_LAPACK_LIB=lapack
47 '') +
48 ''
49 export CVXOPT_BUILD_DSDP=0
50 export CVXOPT_SUITESPARSE_LIB_DIR=${lib.getLib suitesparse}/lib
51 export CVXOPT_SUITESPARSE_INC_DIR=${lib.getDev suitesparse}/include
52 '' + lib.optionalString withGsl ''
53 export CVXOPT_BUILD_GSL=1
54 export CVXOPT_GSL_LIB_DIR=${lib.getLib gsl}/lib
55 export CVXOPT_GSL_INC_DIR=${lib.getDev gsl}/include
56 '' + lib.optionalString withGlpk ''
57 export CVXOPT_BUILD_GLPK=1
58 export CVXOPT_GLPK_LIB_DIR=${lib.getLib glpk}/lib
59 export CVXOPT_GLPK_INC_DIR=${lib.getDev glpk}/include
60 '' + lib.optionalString withFftw ''
61 export CVXOPT_BUILD_FFTW=1
62 export CVXOPT_FFTW_LIB_DIR=${lib.getLib fftw}/lib
63 export CVXOPT_FFTW_INC_DIR=${lib.getDev fftw}/include
64 '';
65
66 nativeCheckInputs = [ unittestCheckHook ];
67
68 unittestFlagsArray = [ "-s" "tests" ];
69
70 meta = with lib; {
71 homepage = "https://cvxopt.org/";
72 description = "Python Software for Convex Optimization";
73 longDescription = ''
74 CVXOPT is a free software package for convex optimization based on the
75 Python programming language. It can be used with the interactive
76 Python interpreter, on the command line by executing Python scripts,
77 or integrated in other software via Python extension modules. Its main
78 purpose is to make the development of software for convex optimization
79 applications straightforward by building on Python's extensive
80 standard library and on the strengths of Python as a high-level
81 programming language.
82 '';
83 maintainers = with maintainers; [ edwtjo ];
84 license = licenses.gpl3Plus;
85 };
86}