You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.7 KiB
Python
56 lines
1.7 KiB
Python
5 years ago
|
from __future__ import division, absolute_import, print_function
|
||
|
|
||
|
from subprocess import PIPE, Popen
|
||
|
import sys
|
||
|
import re
|
||
|
import pytest
|
||
|
|
||
|
from numpy.linalg import lapack_lite
|
||
|
from numpy.testing import assert_
|
||
|
|
||
|
|
||
|
class FindDependenciesLdd(object):
|
||
|
|
||
|
def __init__(self):
|
||
|
self.cmd = ['ldd']
|
||
|
|
||
|
try:
|
||
|
p = Popen(self.cmd, stdout=PIPE, stderr=PIPE)
|
||
|
stdout, stderr = p.communicate()
|
||
|
except OSError:
|
||
|
raise RuntimeError("command %s cannot be run" % self.cmd)
|
||
|
|
||
|
def get_dependencies(self, lfile):
|
||
|
p = Popen(self.cmd + [lfile], stdout=PIPE, stderr=PIPE)
|
||
|
stdout, stderr = p.communicate()
|
||
|
if not (p.returncode == 0):
|
||
|
raise RuntimeError("failed dependencies check for %s" % lfile)
|
||
|
|
||
|
return stdout
|
||
|
|
||
|
def grep_dependencies(self, lfile, deps):
|
||
|
stdout = self.get_dependencies(lfile)
|
||
|
|
||
|
rdeps = dict([(dep, re.compile(dep)) for dep in deps])
|
||
|
founds = []
|
||
|
for l in stdout.splitlines():
|
||
|
for k, v in rdeps.items():
|
||
|
if v.search(l):
|
||
|
founds.append(k)
|
||
|
|
||
|
return founds
|
||
|
|
||
|
|
||
|
class TestF77Mismatch(object):
|
||
|
|
||
|
@pytest.mark.skipif(not(sys.platform[:5] == 'linux'),
|
||
|
reason="no fortran compiler on non-Linux platform")
|
||
|
def test_lapack(self):
|
||
|
f = FindDependenciesLdd()
|
||
|
deps = f.grep_dependencies(lapack_lite.__file__,
|
||
|
[b'libg2c', b'libgfortran'])
|
||
|
assert_(len(deps) <= 1,
|
||
|
"""Both g77 and gfortran runtimes linked in lapack_lite ! This is likely to
|
||
|
cause random crashes and wrong results. See numpy INSTALL.txt for more
|
||
|
information.""")
|