Gentoo Archives: gentoo-commits

From: Michael Orlitzky <mjo@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/cvxopt/
Date: Wed, 13 May 2020 20:52:23
Message-Id: 1589403079.6fe375dda59821206f8af5da92369908184568b1.mjo@gentoo
1 commit: 6fe375dda59821206f8af5da92369908184568b1
2 Author: Michael Orlitzky <mjo <AT> gentoo <DOT> org>
3 AuthorDate: Wed May 13 20:38:14 2020 +0000
4 Commit: Michael Orlitzky <mjo <AT> gentoo <DOT> org>
5 CommitDate: Wed May 13 20:51:19 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6fe375dd
7
8 dev-python/cvxopt: new revision to cleanup and re-messup some things.
9
10 The original purpose of this revision was to refactor the three,
11 similar, convoluted pipelines that are used to parse the output from
12 pkg-config and populate cvxopt's FOO_LIB, FOO_LIB_DIR, and FOO_INC_DIR
13 variables. That was fairly easy: the code to strip out "pthread" and
14 "m" from `pkg-config --libs-only-l` never worked, so I've dropped
15 it. After that, the remaining three pipelines all did essentially the
16 same thing and were combined into a single function that is still
17 large but now only because it is documented.
18
19 Having solved that problem, I made things a bit messy again. I
20 discovered that most of these variables can be passed an empty string,
21 resulting in a command line with "empty" arguments like "-L
22 -L/path/to/wherever" and GCC will accept that. What it won't accept is
23 the empty "-I" arguments corresponding to the INC_DIR variables. Can
24 we leave those unset if pkg-config returns the empty string? No!
25 Because if we do that, then cvxopt will guess the wrong location
26 (outside of EPREFIX) and attempt to use that. So I added some code to
27 prepopulate those variables with the right location, and only append
28 to them when pkg-config gives us something to append.
29
30 I think this works better, but I guess we'll see. I've opened an
31 upstream issue about the empty string problem in these variables. If
32 they can make the "API" a bit nicer in the future, a lot of the new
33 ugliness can be reverted.
34
35 Package-Manager: Portage-2.3.99, Repoman-2.3.22
36 Signed-off-by: Michael Orlitzky <mjo <AT> gentoo.org>
37
38 dev-python/cvxopt/cvxopt-1.2.5-r1.ebuild | 174 +++++++++++++++++++++++++++++++
39 1 file changed, 174 insertions(+)
40
41 diff --git a/dev-python/cvxopt/cvxopt-1.2.5-r1.ebuild b/dev-python/cvxopt/cvxopt-1.2.5-r1.ebuild
42 new file mode 100644
43 index 00000000000..c4670120832
44 --- /dev/null
45 +++ b/dev-python/cvxopt/cvxopt-1.2.5-r1.ebuild
46 @@ -0,0 +1,174 @@
47 +# Copyright 1999-2020 Gentoo Authors
48 +# Distributed under the terms of the GNU General Public License v2
49 +
50 +EAPI=7
51 +
52 +PYTHON_COMPAT=( python3_6 python3_7 python3_8 )
53 +
54 +inherit distutils-r1 toolchain-funcs
55 +
56 +DESCRIPTION="Python package for convex optimization"
57 +HOMEPAGE="http://cvxopt.org/ https://github.com/cvxopt/cvxopt"
58 +SRC_URI="https://github.com/${PN}/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz"
59 +
60 +LICENSE="GPL-3"
61 +SLOT="0"
62 +KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
63 +IUSE="doc +dsdp examples fftw +glpk gsl test"
64 +RESTRICT="!test? ( test )"
65 +
66 +DEPEND="
67 + virtual/blas
68 + virtual/lapack
69 + sci-libs/amd:0=
70 + sci-libs/cholmod:0=
71 + sci-libs/colamd:0=
72 + sci-libs/suitesparseconfig:0=
73 + sci-libs/umfpack:0=
74 + dsdp? ( sci-libs/dsdp:0= )
75 + fftw? ( sci-libs/fftw:3.0= )
76 + glpk? ( >=sci-mathematics/glpk-4.49:0= )
77 + gsl? ( sci-libs/gsl:0= )"
78 +
79 +RDEPEND="${DEPEND}"
80 +
81 +BDEPEND="virtual/pkgconfig
82 + doc? ( dev-python/sphinx )
83 + test? ( ${RDEPEND} dev-python/nose[${PYTHON_USEDEP}] )"
84 +
85 +# The BLAS_LIB and LAPACK_LIB variables (among others) in cvxopt's
86 +# setup.py are passed in as colon-delimited strings. So, for example,
87 +# if your blas "l" flags are "-lblas -lcblas", then cvxopt wants
88 +# "blas;cblas" for BLAS_LIB.
89 +#
90 +# The following function takes a flag type ("l", "L", or "I") as its
91 +# first argument and a list of packages as its remaining arguments. It
92 +# outputs a list of libraries, library paths, or include paths,
93 +# respectively, for the given packages, retrieved using pkg-config and
94 +# deduplicated, in the appropriate format.
95 +#
96 +cvxopt_output() {
97 + local FLAGNAME="${1}"
98 + shift
99 + local PACKAGES="${@}"
100 +
101 + local PKGCONFIG_MODE
102 + case "${FLAGNAME}" in
103 + l) PKGCONFIG_MODE="--libs-only-l";;
104 + L) PKGCONFIG_MODE="--libs-only-L";;
105 + I) PKGCONFIG_MODE="--cflags-only-I";;
106 + *) echo "invalid flag name: ${FLAGNAME}"; exit 1;;
107 + esac
108 +
109 + local CVXOPT_OUTPUT=""
110 + local PKGCONFIG_ITEM
111 + for PKGCONFIG_ITEM in $($(tc-getPKG_CONFIG) ${PKGCONFIG_MODE} ${PACKAGES})
112 + do
113 + # First strip off the leading "-l", "-L", or "-I", and replace
114 + # it with a semicolon...
115 + PKGCONFIG_ITEM=";${PKGCONFIG_ITEM#-${FLAGNAME}}"
116 +
117 + # Now check to see if this element is already present in the
118 + # list, and skip it if it is. This eliminates multiple entries
119 + # from winding up in the list when multiple package arguments are
120 + # passed to this function.
121 + if [[ "${CVXOPT_OUTPUT}" != "${CVXOPT_OUTPUT%${PKGCONFIG_ITEM}}" ]]
122 + then
123 + # It was already the last entry in the list, so skip it.
124 + continue
125 + elif [[ "${CVXOPT_OUTPUT}" != "${CVXOPT_OUTPUT%${PKGCONFIG_ITEM};*}" ]]
126 + then
127 + # It was an earlier entry in the list. These two cases are
128 + # separate to ensure that we can e.g. find ";m" at the end
129 + # of the list, but that we don't find ";metis" in the process.
130 + continue
131 + fi
132 +
133 + # It isn't in the list yet, so append it.
134 + CVXOPT_OUTPUT+="${PKGCONFIG_ITEM}"
135 + done
136 +
137 + # Strip the leading ";" from ";foo;bar" before output.
138 + echo "${CVXOPT_OUTPUT#;}"
139 +}
140 +
141 +python_prepare_all() {
142 + # Mandatory dependencies.
143 + export CVXOPT_BLAS_LIB="$(cvxopt_output l blas)"
144 + export CVXOPT_BLAS_LIB_DIR="${EPREFIX}/usr/$(get_libdir);$(cvxopt_output L blas)"
145 + export CVXOPT_LAPACK_LIB="$(cvxopt_output l lapack)"
146 + export CVXOPT_SUITESPARSE_LIB_DIR="${EPREFIX}/usr/$(get_libdir);$(cvxopt_output L umfpack cholmod amd colamd suitesparseconfig)"
147 +
148 + # Most of these CVXOPT_* variables can be blank or have "empty"
149 + # entries and the resulting command-line with e.g. "-L -L/some/path"
150 + # won't hurt anything. The INC_DIR variables, however, cause
151 + # problems, because at least gcc doesn't like a bare "-I". We
152 + # pre-populate these variable with something safe so that setup.py
153 + # doesn't look in the wrong place if pkg-config doesn't return any
154 + # extra -I directories. This is
155 + #
156 + # https://github.com/cvxopt/cvxopt/issues/167
157 + #
158 + CVXOPT_SUITESPARSE_INC_DIR="${EPREFIX}/usr/include"
159 + local SUITESPARSE_LOCAL_INCS="$(cvxopt_output I umfpack cholmod amd colamd suitesparseconfig)"
160 + if [[ -n "${SUITESPARSE_LOCAL_INCS}" ]]; then
161 + CVXOPT_SUITESPARSE_INC_DIR+=";${SUITESPARSE_LOCAL_INCS}"
162 + fi
163 + export CVXOPT_SUITESPARSE_INC_DIR
164 +
165 + # optional dependencies
166 + if use dsdp; then
167 + # no pkg-config file at the moment
168 + export CVXOPT_BUILD_DSDP=1
169 + export CVXOPT_DSDP_LIB_DIR="${EPREFIX}/usr/$(get_libdir)"
170 + export CVXOPT_DSDP_INC_DIR="${EPREFIX}/usr/include"
171 + fi
172 +
173 + if use fftw; then
174 + export CVXOPT_BUILD_FFTW=1
175 + export CVXOPT_FFTW_LIB_DIR="${EPREFIX}/usr/$(get_libdir);$(cvxopt_output L fftw3)"
176 + CVXOPT_FFTW_INC_DIR="${EPREFIX}/usr/include"
177 + FFTW_LOCAL_INCS="$(cvxopt_output I fftw3)"
178 + if [[ -n "${FFTW_LOCAL_INCS}" ]]; then
179 + CVXOPT_FFTW_INC_DIR+=";${FFTW_LOCAL_INCS}"
180 + fi
181 + export CVXOPT_FFTW_INC_DIR
182 + fi
183 +
184 + if use glpk; then
185 + # no pkg-config file at the moment
186 + export CVXOPT_BUILD_GLPK=1
187 + export CVXOPT_GLPK_LIB_DIR="${EPREFIX}/usr/$(get_libdir)"
188 + export CVXOPT_GLPK_INC_DIR="${EPREFIX}/usr/include"
189 + fi
190 +
191 + if use gsl; then
192 + export CVXOPT_BUILD_GSL=1
193 + export CVXOPT_GSL_LIB_DIR="${EPREFIX}/usr/$(get_libdir);$(cvxopt_output L gsl)"
194 + CVXOPT_GSL_INC_DIR="${EPREFIX}/usr/include"
195 + GSL_LOCAL_INCS="$(cvxopt_output I gsl)"
196 + if [[ -n "${GSL_LOCAL_INCS}" ]]; then
197 + CVXOPT_GSL_INC_DIR+=";${GSL_LOCAL_INCS}"
198 + fi
199 + export CVXOPT_GSL_INC_DIR
200 + fi
201 +
202 + distutils-r1_python_prepare_all
203 +}
204 +
205 +python_compile_all() {
206 + use doc && VARTEXFONTS="${T}/fonts" emake -C doc -B html
207 +}
208 +
209 +python_test() {
210 + PYTHONPATH="${BUILD_DIR}"/lib nosetests -v || die
211 +}
212 +
213 +python_install_all() {
214 + use doc && HTML_DOCS=( doc/build/html/. )
215 + distutils-r1_python_install_all
216 + if use examples; then
217 + dodoc -r examples
218 + docompress -x "/usr/share/doc/${PF}/examples"
219 + fi
220 +}