Chris@87: from __future__ import division, absolute_import, print_function Chris@87: Chris@87: from subprocess import call, PIPE, Popen Chris@87: import sys Chris@87: import re Chris@87: Chris@87: import numpy as np Chris@87: from numpy.linalg import lapack_lite Chris@87: from numpy.testing import TestCase, dec Chris@87: Chris@87: from numpy.compat import asbytes_nested Chris@87: Chris@87: class FindDependenciesLdd(object): Chris@87: def __init__(self): Chris@87: self.cmd = ['ldd'] Chris@87: Chris@87: try: Chris@87: p = Popen(self.cmd, stdout=PIPE, stderr=PIPE) Chris@87: stdout, stderr = p.communicate() Chris@87: except OSError: Chris@87: raise RuntimeError("command %s cannot be run" % self.cmd) Chris@87: Chris@87: def get_dependencies(self, lfile): Chris@87: p = Popen(self.cmd + [lfile], stdout=PIPE, stderr=PIPE) Chris@87: stdout, stderr = p.communicate() Chris@87: if not (p.returncode == 0): Chris@87: raise RuntimeError("failed dependencies check for %s" % lfile) Chris@87: Chris@87: return stdout Chris@87: Chris@87: def grep_dependencies(self, lfile, deps): Chris@87: stdout = self.get_dependencies(lfile) Chris@87: Chris@87: rdeps = dict([(dep, re.compile(dep)) for dep in deps]) Chris@87: founds = [] Chris@87: for l in stdout.splitlines(): Chris@87: for k, v in rdeps.items(): Chris@87: if v.search(l): Chris@87: founds.append(k) Chris@87: Chris@87: return founds Chris@87: Chris@87: class TestF77Mismatch(TestCase): Chris@87: @dec.skipif(not(sys.platform[:5] == 'linux'), Chris@87: "Skipping fortran compiler mismatch on non Linux platform") Chris@87: def test_lapack(self): Chris@87: f = FindDependenciesLdd() Chris@87: deps = f.grep_dependencies(lapack_lite.__file__, Chris@87: asbytes_nested(['libg2c', 'libgfortran'])) Chris@87: self.assertFalse(len(deps) > 1, Chris@87: """Both g77 and gfortran runtimes linked in lapack_lite ! This is likely to Chris@87: cause random crashes and wrong results. See numpy INSTALL.txt for more Chris@87: information.""")