test_build.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. from __future__ import division, print_function, absolute_import
  2. from subprocess import call, PIPE, Popen
  3. import sys
  4. import re
  5. import pytest
  6. from numpy.testing import assert_
  7. from numpy.compat import asbytes
  8. from scipy.linalg import _flapack as flapack
  9. # XXX: this is copied from numpy trunk. Can be removed when we will depend on
  10. # numpy 1.3
  11. class FindDependenciesLdd:
  12. def __init__(self):
  13. self.cmd = ['ldd']
  14. try:
  15. st = call(self.cmd, stdout=PIPE, stderr=PIPE)
  16. except OSError:
  17. raise RuntimeError("command %s cannot be run" % self.cmd)
  18. def get_dependencies(self, file):
  19. p = Popen(self.cmd + [file], stdout=PIPE, stderr=PIPE)
  20. stdout, stderr = p.communicate()
  21. if not (p.returncode == 0):
  22. raise RuntimeError("Failed to check dependencies for %s" % file)
  23. return stdout
  24. def grep_dependencies(self, file, deps):
  25. stdout = self.get_dependencies(file)
  26. rdeps = dict([(asbytes(dep), re.compile(asbytes(dep))) for dep in deps])
  27. founds = []
  28. for l in stdout.splitlines():
  29. for k, v in rdeps.items():
  30. if v.search(l):
  31. founds.append(k)
  32. return founds
  33. class TestF77Mismatch(object):
  34. @pytest.mark.skipif(not(sys.platform[:5] == 'linux'),
  35. reason="Skipping fortran compiler mismatch on non Linux platform")
  36. def test_lapack(self):
  37. f = FindDependenciesLdd()
  38. deps = f.grep_dependencies(flapack.__file__,
  39. ['libg2c', 'libgfortran'])
  40. assert_(not (len(deps) > 1),
  41. """Both g77 and gfortran runtimes linked in scipy.linalg.flapack ! This is
  42. likely to cause random crashes and wrong results. See numpy INSTALL.rst.txt for
  43. more information.""")