Return the MATHLIB line from numpyconfig.h
(path=None)
| 203 | return minrelpath(joined) |
| 204 | |
| 205 | def 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 | |
| 232 | def minrelpath(path): |
| 233 | """Resolve `..` and '.' from path. |
no test coverage detected