1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
class PyCvxopt(PythonPackage):
"""CVXOPT is a free software package for convex optimization based on the
Python programming language."""
homepage = "http://cvxopt.org/"
url = "https://pypi.io/packages/source/c/cvxopt/cvxopt-1.1.9.tar.gz"
import_modules = ['cvxopt']
version('1.2.5', sha256='94ec8c36bd6628a11de9014346692daeeef99b3b7bae28cef30c7490bbcb2d72')
version('1.1.9', sha256='8f157e7397158812cabd340b68546f1baa55a486ed0aad8bc26877593dc2983d')
variant('gsl', default=False, description='Use GSL random number generators for constructing random matrices')
variant('fftw', default=False, description='Install the cvxopt.fftw interface to FFTW')
variant('glpk', default=False, description='Enable support for the linear programming solver GLPK')
# variant('mosek', default=False, description='Enable support for the linear, second-order cone, and quadratic programming solvers in MOSEK') # noqa
variant('dsdp', default=False, description='Enable support for the semidefinite programming solver DSDP')
# Required dependencies
depends_on('python@2.7:', type=('build', 'link', 'run'))
depends_on('python@2.7:3.7.999', type=('build', 'link', 'run'), when='@:1.1.9')
depends_on('py-setuptools', type='build')
depends_on('blas')
depends_on('lapack')
depends_on('suite-sparse')
# Optional dependencies
depends_on('gsl', when='+gsl')
depends_on('fftw', when='+fftw')
depends_on('glpk', when='+glpk')
# depends_on('mosek@8:', when='+mosek')
depends_on('dsdp@5.8:', when='+dsdp')
def setup_build_environment(self, env):
spec = self.spec
# BLAS/LAPACK Libraries
# Default names of BLAS and LAPACK libraries
env.set('CVXOPT_BLAS_LIB', ';'.join(spec['blas'].libs.names))
env.set('CVXOPT_LAPACK_LIB', ';'.join(spec['lapack'].libs.names))
# Directory containing BLAS and LAPACK libraries
env.set('CVXOPT_BLAS_LIB_DIR', spec['blas'].libs.directories[0])
# SuiteSparse Libraries
# Directory containing SuiteSparse libraries
env.set('CVXOPT_SUITESPARSE_LIB_DIR',
spec['suite-sparse'].libs.directories[0])
# Directory containing SuiteSparse header files
env.set('CVXOPT_SUITESPARSE_INC_DIR',
spec['suite-sparse'].headers.directories[0])
# GSL Libraries
if '+gsl' in spec:
env.set('CVXOPT_BUILD_GSL', 1)
# Directory containing libgsl
env.set('CVXOPT_GSL_LIB_DIR', spec['gsl'].libs.directories[0])
# Directory containing the GSL header files
env.set('CVXOPT_GSL_INC_DIR', spec['gsl'].headers.directories[0])
else:
env.set('CVXOPT_BUILD_GSL', 0)
# FFTW Libraries
if '+fftw' in spec:
env.set('CVXOPT_BUILD_FFTW', 1)
# Directory containing libfftw3
env.set('CVXOPT_FFTW_LIB_DIR', spec['fftw'].libs.directories[0])
# Directory containing fftw.h
env.set('CVXOPT_FFTW_INC_DIR', spec['fftw'].headers.directories[0])
else:
env.set('CVXOPT_BUILD_FFTW', 0)
# GLPK Libraries
if '+glpk' in spec:
env.set('CVXOPT_BUILD_GLPK', 1)
# Directory containing libglpk
env.set('CVXOPT_GLPK_LIB_DIR', spec['glpk'].libs.directories[0])
# Directory containing glpk.h
env.set('CVXOPT_GLPK_INC_DIR', spec['glpk'].headers.directories[0])
else:
env.set('CVXOPT_BUILD_GLPK', 0)
# DSDP Libraries
if '+dsdp' in spec:
env.set('CVXOPT_BUILD_DSDP', 1)
# Directory containing libdsdp
env.set('CVXOPT_DSDP_LIB_DIR', spec['dsdp'].libs.directories[0])
# Directory containing dsdp5.h
env.set('CVXOPT_DSDP_INC_DIR', spec['dsdp'].headers.directories[0])
@run_after('install')
@on_package_attributes(run_tests=True)
def install_test(self):
"""Test that the installation was successful."""
python('-m', 'unittest', 'discover', '-s', 'tests')
|