MCPcopy Create free account
hub / github.com/numpy/numpy / get_mathlibs

Function get_mathlibs

numpy/distutils/misc_util.py:205–230  ·  view source on GitHub ↗

Return the MATHLIB line from numpyconfig.h

(path=None)

Source from the content-addressed store, hash-verified

203 return minrelpath(joined)
204
205def get_mathlibs(path=None):
206 """Return the MATHLIB line from numpyconfig.h
207 """
208 if path is not None:
209 config_file = os.path.join(path, '_numpyconfig.h')
210 else:
211 # Look for the file in each of the numpy include directories.
212 dirs = get_numpy_include_dirs()
213 for path in dirs:
214 fn = os.path.join(path, '_numpyconfig.h')
215 if os.path.exists(fn):
216 config_file = fn
217 break
218 else:
219 raise DistutilsError('_numpyconfig.h not found in numpy include '
220 'dirs %r' % (dirs,))
221
222 with open(config_file) as fid:
223 mathlibs = []
224 s = '#define MATHLIB'
225 for line in fid:
226 if line.startswith(s):
227 value = line[len(s):].strip()
228 if value:
229 mathlibs.extend(value.split(','))
230 return mathlibs
231
232def minrelpath(path):
233 """Resolve `..` and '.' from path.

Callers 1

generate_librariesFunction · 0.90

Calls 7

get_numpy_include_dirsFunction · 0.85
openFunction · 0.85
startswithMethod · 0.80
stripMethod · 0.80
joinMethod · 0.45
existsMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected