annotate DEPENDENCIES/mingw32/Python27/Lib/site-packages/numpy/linalg/tests/test_build.py @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2a2c65a20a8b
children
rev   line source
Chris@87 1 from __future__ import division, absolute_import, print_function
Chris@87 2
Chris@87 3 from subprocess import call, PIPE, Popen
Chris@87 4 import sys
Chris@87 5 import re
Chris@87 6
Chris@87 7 import numpy as np
Chris@87 8 from numpy.linalg import lapack_lite
Chris@87 9 from numpy.testing import TestCase, dec
Chris@87 10
Chris@87 11 from numpy.compat import asbytes_nested
Chris@87 12
Chris@87 13 class FindDependenciesLdd(object):
Chris@87 14 def __init__(self):
Chris@87 15 self.cmd = ['ldd']
Chris@87 16
Chris@87 17 try:
Chris@87 18 p = Popen(self.cmd, stdout=PIPE, stderr=PIPE)
Chris@87 19 stdout, stderr = p.communicate()
Chris@87 20 except OSError:
Chris@87 21 raise RuntimeError("command %s cannot be run" % self.cmd)
Chris@87 22
Chris@87 23 def get_dependencies(self, lfile):
Chris@87 24 p = Popen(self.cmd + [lfile], stdout=PIPE, stderr=PIPE)
Chris@87 25 stdout, stderr = p.communicate()
Chris@87 26 if not (p.returncode == 0):
Chris@87 27 raise RuntimeError("failed dependencies check for %s" % lfile)
Chris@87 28
Chris@87 29 return stdout
Chris@87 30
Chris@87 31 def grep_dependencies(self, lfile, deps):
Chris@87 32 stdout = self.get_dependencies(lfile)
Chris@87 33
Chris@87 34 rdeps = dict([(dep, re.compile(dep)) for dep in deps])
Chris@87 35 founds = []
Chris@87 36 for l in stdout.splitlines():
Chris@87 37 for k, v in rdeps.items():
Chris@87 38 if v.search(l):
Chris@87 39 founds.append(k)
Chris@87 40
Chris@87 41 return founds
Chris@87 42
Chris@87 43 class TestF77Mismatch(TestCase):
Chris@87 44 @dec.skipif(not(sys.platform[:5] == 'linux'),
Chris@87 45 "Skipping fortran compiler mismatch on non Linux platform")
Chris@87 46 def test_lapack(self):
Chris@87 47 f = FindDependenciesLdd()
Chris@87 48 deps = f.grep_dependencies(lapack_lite.__file__,
Chris@87 49 asbytes_nested(['libg2c', 'libgfortran']))
Chris@87 50 self.assertFalse(len(deps) > 1,
Chris@87 51 """Both g77 and gfortran runtimes linked in lapack_lite ! This is likely to
Chris@87 52 cause random crashes and wrong results. See numpy INSTALL.txt for more
Chris@87 53 information.""")