summaryrefslogtreecommitdiff
path: root/numpy/distutils
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/distutils')
-rw-r--r--numpy/distutils/_shell_utils.py4
-rw-r--r--numpy/distutils/ccompiler.py60
-rw-r--r--numpy/distutils/command/build_ext.py4
-rw-r--r--numpy/distutils/command/build_src.py62
-rw-r--r--numpy/distutils/command/install.py19
-rw-r--r--numpy/distutils/exec_command.py23
-rw-r--r--numpy/distutils/fcompiler/environment.py12
-rw-r--r--numpy/distutils/fcompiler/ibm.py17
-rw-r--r--numpy/distutils/line_endings.py10
-rw-r--r--numpy/distutils/misc_util.py128
-rw-r--r--numpy/distutils/system_info.py65
-rw-r--r--numpy/distutils/tests/test_exec_command.py31
12 files changed, 185 insertions, 250 deletions
diff --git a/numpy/distutils/_shell_utils.py b/numpy/distutils/_shell_utils.py
index 5ef874900..82abd5f4e 100644
--- a/numpy/distutils/_shell_utils.py
+++ b/numpy/distutils/_shell_utils.py
@@ -24,12 +24,12 @@ class CommandLineParser:
@staticmethod
def join(argv):
""" Join a list of arguments into a command line string """
- raise NotImplemented
+ raise NotImplementedError
@staticmethod
def split(cmd):
""" Split a command line string into a list of arguments """
- raise NotImplemented
+ raise NotImplementedError
class WindowsParser:
diff --git a/numpy/distutils/ccompiler.py b/numpy/distutils/ccompiler.py
index 552b9566f..14451fa66 100644
--- a/numpy/distutils/ccompiler.py
+++ b/numpy/distutils/ccompiler.py
@@ -796,63 +796,3 @@ for _cc in ['msvc9', 'msvc', '_msvc', 'bcpp', 'cygwinc', 'emxc', 'unixc']:
if _m is not None:
setattr(_m, 'gen_lib_options', gen_lib_options)
-
-##Fix distutils.util.split_quoted:
-# NOTE: I removed this fix in revision 4481 (see ticket #619), but it appears
-# that removing this fix causes f2py problems on Windows XP (see ticket #723).
-# Specifically, on WinXP when gfortran is installed in a directory path, which
-# contains spaces, then f2py is unable to find it.
-import string
-_wordchars_re = re.compile(r'[^\\\'\"%s ]*' % string.whitespace)
-_squote_re = re.compile(r"'(?:[^'\\]|\\.)*'")
-_dquote_re = re.compile(r'"(?:[^"\\]|\\.)*"')
-_has_white_re = re.compile(r'\s')
-def split_quoted(s):
- s = s.strip()
- words = []
- pos = 0
-
- while s:
- m = _wordchars_re.match(s, pos)
- end = m.end()
- if end == len(s):
- words.append(s[:end])
- break
-
- if s[end] in string.whitespace: # unescaped, unquoted whitespace: now
- words.append(s[:end]) # we definitely have a word delimiter
- s = s[end:].lstrip()
- pos = 0
-
- elif s[end] == '\\': # preserve whatever is being escaped;
- # will become part of the current word
- s = s[:end] + s[end+1:]
- pos = end+1
-
- else:
- if s[end] == "'": # slurp singly-quoted string
- m = _squote_re.match(s, end)
- elif s[end] == '"': # slurp doubly-quoted string
- m = _dquote_re.match(s, end)
- else:
- raise RuntimeError("this can't happen (bad char '%c')" % s[end])
-
- if m is None:
- raise ValueError("bad string (mismatched %s quotes?)" % s[end])
-
- (beg, end) = m.span()
- if _has_white_re.search(s[beg+1:end-1]):
- s = s[:beg] + s[beg+1:end-1] + s[end:]
- pos = m.end() - 2
- else:
- # Keeping quotes when a quoted word does not contain
- # white-space. XXX: send a patch to distutils
- pos = m.end()
-
- if pos >= len(s):
- words.append(s)
- break
-
- return words
-ccompiler.split_quoted = split_quoted
-##Fix distutils.util.split_quoted:
diff --git a/numpy/distutils/command/build_ext.py b/numpy/distutils/command/build_ext.py
index ab9d585a5..ef54fb25e 100644
--- a/numpy/distutils/command/build_ext.py
+++ b/numpy/distutils/command/build_ext.py
@@ -281,8 +281,8 @@ class build_ext (old_build_ext):
runtime_lib = os.path.join(self.extra_dll_dir, fn)
copy_file(runtime_lib, shared_lib_dir)
- def swig_sources(self, sources):
- # Do nothing. Swig sources have beed handled in build_src command.
+ def swig_sources(self, sources, extensions=None):
+ # Do nothing. Swig sources have been handled in build_src command.
return sources
def build_extension(self, ext):
diff --git a/numpy/distutils/command/build_src.py b/numpy/distutils/command/build_src.py
index 668bc23fe..6d5d305d2 100644
--- a/numpy/distutils/command/build_src.py
+++ b/numpy/distutils/command/build_src.py
@@ -28,20 +28,14 @@ def subst_vars(target, source, d):
"""Substitute any occurrence of @foo@ by d['foo'] from source file into
target."""
var = re.compile('@([a-zA-Z_]+)@')
- fs = open(source, 'r')
- try:
- ft = open(target, 'w')
- try:
+ with open(source, 'r') as fs:
+ with open(target, 'w') as ft:
for l in fs:
m = var.search(l)
if m:
ft.write(l.replace('@%s@' % m.group(1), d[m.group(1)]))
else:
ft.write(l)
- finally:
- ft.close()
- finally:
- fs.close()
class build_src(build_ext.build_ext):
@@ -425,9 +419,8 @@ class build_src(build_ext.build_ext):
else:
log.info("conv_template:> %s" % (target_file))
outstr = process_c_file(source)
- fid = open(target_file, 'w')
- fid.write(outstr)
- fid.close()
+ with open(target_file, 'w') as fid:
+ fid.write(outstr)
if _header_ext_match(target_file):
d = os.path.dirname(target_file)
if d not in include_dirs:
@@ -723,25 +716,23 @@ _has_c_header = re.compile(r'-[*]-\s*c\s*-[*]-', re.I).search
_has_cpp_header = re.compile(r'-[*]-\s*c[+][+]\s*-[*]-', re.I).search
def get_swig_target(source):
- f = open(source, 'r')
- result = None
- line = f.readline()
- if _has_cpp_header(line):
- result = 'c++'
- if _has_c_header(line):
- result = 'c'
- f.close()
+ with open(source, 'r') as f:
+ result = None
+ line = f.readline()
+ if _has_cpp_header(line):
+ result = 'c++'
+ if _has_c_header(line):
+ result = 'c'
return result
def get_swig_modulename(source):
- f = open(source, 'r')
- name = None
- for line in f:
- m = _swig_module_name_match(line)
- if m:
- name = m.group('name')
- break
- f.close()
+ with open(source, 'r') as f:
+ name = None
+ for line in f:
+ m = _swig_module_name_match(line)
+ if m:
+ name = m.group('name')
+ break
return name
def _find_swig_target(target_dir, name):
@@ -760,15 +751,14 @@ _f2py_user_module_name_match = re.compile(r'\s*python\s*module\s*(?P<name>[\w_]*
def get_f2py_modulename(source):
name = None
- f = open(source)
- for line in f:
- m = _f2py_module_name_match(line)
- if m:
- if _f2py_user_module_name_match(line): # skip *__user__* names
- continue
- name = m.group('name')
- break
- f.close()
+ with open(source) as f:
+ for line in f:
+ m = _f2py_module_name_match(line)
+ if m:
+ if _f2py_user_module_name_match(line): # skip *__user__* names
+ continue
+ name = m.group('name')
+ break
return name
##########################################
diff --git a/numpy/distutils/command/install.py b/numpy/distutils/command/install.py
index a1dd47755..c74ae9446 100644
--- a/numpy/distutils/command/install.py
+++ b/numpy/distutils/command/install.py
@@ -64,16 +64,15 @@ class install(old_install):
# bdist_rpm fails when INSTALLED_FILES contains
# paths with spaces. Such paths must be enclosed
# with double-quotes.
- f = open(self.record, 'r')
- lines = []
- need_rewrite = False
- for l in f:
- l = l.rstrip()
- if ' ' in l:
- need_rewrite = True
- l = '"%s"' % (l)
- lines.append(l)
- f.close()
+ with open(self.record, 'r') as f:
+ lines = []
+ need_rewrite = False
+ for l in f:
+ l = l.rstrip()
+ if ' ' in l:
+ need_rewrite = True
+ l = '"%s"' % (l)
+ lines.append(l)
if need_rewrite:
self.execute(write_file,
(self.record, lines),
diff --git a/numpy/distutils/exec_command.py b/numpy/distutils/exec_command.py
index ede347b03..2e7b9e463 100644
--- a/numpy/distutils/exec_command.py
+++ b/numpy/distutils/exec_command.py
@@ -57,6 +57,7 @@ import os
import sys
import subprocess
import locale
+import warnings
from numpy.distutils.misc_util import is_sequence, make_temp_file
from numpy.distutils import log
@@ -105,6 +106,9 @@ def forward_bytes_to_stdout(val):
def temp_file_name():
+ # 2019-01-30, 1.17
+ warnings.warn('temp_file_name is deprecated since NumPy v1.17, use '
+ 'tempfile.mkstemp instead', DeprecationWarning, stacklevel=1)
fo, name = make_temp_file()
fo.close()
return name
@@ -179,24 +183,14 @@ def _update_environment( **env ):
for name, value in env.items():
os.environ[name] = value or ''
-def _supports_fileno(stream):
- """
- Returns True if 'stream' supports the file descriptor and allows fileno().
- """
- if hasattr(stream, 'fileno'):
- try:
- stream.fileno()
- return True
- except IOError:
- return False
- else:
- return False
-
def exec_command(command, execute_in='', use_shell=None, use_tee=None,
_with_python = 1, **env ):
"""
Return (status,output) of executed command.
+ .. deprecated:: 1.17
+ Use subprocess.Popen instead
+
Parameters
----------
command : str
@@ -220,6 +214,9 @@ def exec_command(command, execute_in='', use_shell=None, use_tee=None,
Wild cards will not work for non-posix systems or when use_shell=0.
"""
+ # 2019-01-30, 1.17
+ warnings.warn('exec_command is deprecated since NumPy v1.17, use '
+ 'subprocess.Popen instead', DeprecationWarning, stacklevel=1)
log.debug('exec_command(%r,%s)' % (command,\
','.join(['%s=%r'%kv for kv in env.items()])))
diff --git a/numpy/distutils/fcompiler/environment.py b/numpy/distutils/fcompiler/environment.py
index 4238f35cb..73a5e98e1 100644
--- a/numpy/distutils/fcompiler/environment.py
+++ b/numpy/distutils/fcompiler/environment.py
@@ -51,13 +51,16 @@ class EnvironmentConfig(object):
def _get_var(self, name, conf_desc):
hook, envvar, confvar, convert, append = conf_desc
+ if convert is None:
+ convert = lambda x: x
var = self._hook_handler(name, hook)
if envvar is not None:
envvar_contents = os.environ.get(envvar)
if envvar_contents is not None:
+ envvar_contents = convert(envvar_contents)
if var and append:
if os.environ.get('NPY_DISTUTILS_APPEND_FLAGS', '0') == '1':
- var = var + [envvar_contents]
+ var.extend(envvar_contents)
else:
var = envvar_contents
if 'NPY_DISTUTILS_APPEND_FLAGS' not in os.environ.keys():
@@ -70,11 +73,12 @@ class EnvironmentConfig(object):
else:
var = envvar_contents
if confvar is not None and self._conf:
- var = self._conf.get(confvar, (None, var))[1]
- if convert is not None:
- var = convert(var)
+ if confvar in self._conf:
+ source, confvar_contents = self._conf[confvar]
+ var = convert(confvar_contents)
return var
+
def clone(self, hook_handler):
ec = self.__class__(distutils_section=self._distutils_section,
**self._conf_keys)
diff --git a/numpy/distutils/fcompiler/ibm.py b/numpy/distutils/fcompiler/ibm.py
index c4cb2fca7..70d2132e1 100644
--- a/numpy/distutils/fcompiler/ibm.py
+++ b/numpy/distutils/fcompiler/ibm.py
@@ -78,15 +78,14 @@ class IBMFCompiler(FCompiler):
xlf_cfg = '/etc/opt/ibmcmp/xlf/%s/xlf.cfg' % version
fo, new_cfg = make_temp_file(suffix='_xlf.cfg')
log.info('Creating '+new_cfg)
- fi = open(xlf_cfg, 'r')
- crt1_match = re.compile(r'\s*crt\s*[=]\s*(?P<path>.*)/crt1.o').match
- for line in fi:
- m = crt1_match(line)
- if m:
- fo.write('crt = %s/bundle1.o\n' % (m.group('path')))
- else:
- fo.write(line)
- fi.close()
+ with open(xlf_cfg, 'r') as fi:
+ crt1_match = re.compile(r'\s*crt\s*[=]\s*(?P<path>.*)/crt1.o').match
+ for line in fi:
+ m = crt1_match(line)
+ if m:
+ fo.write('crt = %s/bundle1.o\n' % (m.group('path')))
+ else:
+ fo.write(line)
fo.close()
opt.append('-F'+new_cfg)
return opt
diff --git a/numpy/distutils/line_endings.py b/numpy/distutils/line_endings.py
index 5ecb104ff..2420798ab 100644
--- a/numpy/distutils/line_endings.py
+++ b/numpy/distutils/line_endings.py
@@ -19,9 +19,8 @@ def dos2unix(file):
newdata = re.sub("\r\n", "\n", data)
if newdata != data:
print('dos2unix:', file)
- f = open(file, "wb")
- f.write(newdata)
- f.close()
+ with open(file, "wb") as f:
+ f.write(newdata)
return file
else:
print(file, 'ok')
@@ -53,9 +52,8 @@ def unix2dos(file):
newdata = re.sub("\n", "\r\n", newdata)
if newdata != data:
print('unix2dos:', file)
- f = open(file, "wb")
- f.write(newdata)
- f.close()
+ with open(file, "wb") as f:
+ f.write(newdata)
return file
else:
print(file, 'ok')
diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py
index 67a5f7234..cba84bffa 100644
--- a/numpy/distutils/misc_util.py
+++ b/numpy/distutils/misc_util.py
@@ -218,15 +218,14 @@ def get_mathlibs(path=None):
raise DistutilsError('_numpyconfig.h not found in numpy include '
'dirs %r' % (dirs,))
- fid = open(config_file)
- mathlibs = []
- s = '#define MATHLIB'
- for line in fid:
- if line.startswith(s):
- value = line[len(s):].strip()
- if value:
- mathlibs.extend(value.split(','))
- fid.close()
+ with open(config_file) as fid:
+ mathlibs = []
+ s = '#define MATHLIB'
+ for line in fid:
+ if line.startswith(s):
+ value = line[len(s):].strip()
+ if value:
+ mathlibs.extend(value.split(','))
return mathlibs
def minrelpath(path):
@@ -443,14 +442,13 @@ def _get_f90_modules(source):
if not f90_ext_match(source):
return []
modules = []
- f = open(source, 'r')
- for line in f:
- m = f90_module_name_match(line)
- if m:
- name = m.group('name')
- modules.append(name)
- # break # XXX can we assume that there is one module per file?
- f.close()
+ with open(source, 'r') as f:
+ for line in f:
+ m = f90_module_name_match(line)
+ if m:
+ name = m.group('name')
+ modules.append(name)
+ # break # XXX can we assume that there is one module per file?
return modules
def is_string(s):
@@ -1833,67 +1831,53 @@ class Configuration(object):
def _get_svn_revision(self, path):
"""Return path's SVN revision number.
"""
- revision = None
- m = None
- cwd = os.getcwd()
try:
- os.chdir(path or '.')
- p = subprocess.Popen(['svnversion'], shell=True,
- stdout=subprocess.PIPE, stderr=None,
- close_fds=True)
- sout = p.stdout
- m = re.match(r'(?P<revision>\d+)', sout.read())
- except Exception:
+ output = subprocess.check_output(
+ ['svnversion'], shell=True, cwd=path)
+ except (subprocess.CalledProcessError, OSError):
pass
- os.chdir(cwd)
- if m:
- revision = int(m.group('revision'))
- return revision
+ else:
+ m = re.match(rb'(?P<revision>\d+)', output)
+ if m:
+ return int(m.group('revision'))
+
if sys.platform=='win32' and os.environ.get('SVN_ASP_DOT_NET_HACK', None):
entries = njoin(path, '_svn', 'entries')
else:
entries = njoin(path, '.svn', 'entries')
if os.path.isfile(entries):
- f = open(entries)
- fstr = f.read()
- f.close()
+ with open(entries) as f:
+ fstr = f.read()
if fstr[:5] == '<?xml': # pre 1.4
m = re.search(r'revision="(?P<revision>\d+)"', fstr)
if m:
- revision = int(m.group('revision'))
+ return int(m.group('revision'))
else: # non-xml entries file --- check to be sure that
m = re.search(r'dir[\n\r]+(?P<revision>\d+)', fstr)
if m:
- revision = int(m.group('revision'))
- return revision
+ return int(m.group('revision'))
+ return None
def _get_hg_revision(self, path):
"""Return path's Mercurial revision number.
"""
- revision = None
- m = None
- cwd = os.getcwd()
try:
- os.chdir(path or '.')
- p = subprocess.Popen(['hg identify --num'], shell=True,
- stdout=subprocess.PIPE, stderr=None,
- close_fds=True)
- sout = p.stdout
- m = re.match(r'(?P<revision>\d+)', sout.read())
- except Exception:
+ output = subprocess.check_output(
+ ['hg identify --num'], shell=True, cwd=path)
+ except (subprocess.CalledProcessError, OSError):
pass
- os.chdir(cwd)
- if m:
- revision = int(m.group('revision'))
- return revision
+ else:
+ m = re.match(rb'(?P<revision>\d+)', output)
+ if m:
+ return int(m.group('revision'))
+
branch_fn = njoin(path, '.hg', 'branch')
branch_cache_fn = njoin(path, '.hg', 'branch.cache')
if os.path.isfile(branch_fn):
branch0 = None
- f = open(branch_fn)
- revision0 = f.read().strip()
- f.close()
+ with open(branch_fn) as f:
+ revision0 = f.read().strip()
branch_map = {}
for line in file(branch_cache_fn, 'r'):
@@ -1906,8 +1890,9 @@ class Configuration(object):
continue
branch_map[branch1] = revision1
- revision = branch_map.get(branch0)
- return revision
+ return branch_map.get(branch0)
+
+ return None
def get_version(self, version_file=None, version_variable=None):
@@ -2005,9 +1990,8 @@ class Configuration(object):
if not os.path.isfile(target):
version = str(revision)
self.info('Creating %s (version=%r)' % (target, version))
- f = open(target, 'w')
- f.write('version = %r\n' % (version))
- f.close()
+ with open(target, 'w') as f:
+ f.write('version = %r\n' % (version))
def rm_file(f=target,p=self.info):
if delete:
@@ -2046,9 +2030,8 @@ class Configuration(object):
if not os.path.isfile(target):
version = str(revision)
self.info('Creating %s (version=%r)' % (target, version))
- f = open(target, 'w')
- f.write('version = %r\n' % (version))
- f.close()
+ with open(target, 'w') as f:
+ f.write('version = %r\n' % (version))
def rm_file(f=target,p=self.info):
if delete:
@@ -2284,13 +2267,13 @@ def generate_config_py(target):
from numpy.distutils.system_info import system_info
from distutils.dir_util import mkpath
mkpath(os.path.dirname(target))
- f = open(target, 'w')
- f.write('# This file is generated by numpy\'s %s\n' % (os.path.basename(sys.argv[0])))
- f.write('# It contains system_info results at the time of building this package.\n')
- f.write('__all__ = ["get_info","show"]\n\n')
+ with open(target, 'w') as f:
+ f.write('# This file is generated by numpy\'s %s\n' % (os.path.basename(sys.argv[0])))
+ f.write('# It contains system_info results at the time of building this package.\n')
+ f.write('__all__ = ["get_info","show"]\n\n')
- # For gfortran+msvc combination, extra shared libraries may exist
- f.write("""
+ # For gfortran+msvc combination, extra shared libraries may exist
+ f.write("""
import os
import sys
@@ -2303,9 +2286,9 @@ if sys.platform == 'win32' and os.path.isdir(extra_dll_dir):
""")
- for k, i in system_info.saved_results.items():
- f.write('%s=%r\n' % (k, i))
- f.write(r'''
+ for k, i in system_info.saved_results.items():
+ f.write('%s=%r\n' % (k, i))
+ f.write(r'''
def get_info(name):
g = globals()
return g.get(name, g.get(name + "_info", {}))
@@ -2321,9 +2304,8 @@ def show():
if k == "sources" and len(v) > 200:
v = v[:60] + " ...\n... " + v[-60:]
print(" %s = %s" % (k,v))
- ''')
+ ''')
- f.close()
return target
def msvc_version(compiler):
diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py
index 242494331..8a42434ff 100644
--- a/numpy/distutils/system_info.py
+++ b/numpy/distutils/system_info.py
@@ -906,7 +906,6 @@ class fftw_info(system_info):
== len(ver_param['includes']):
dict_append(info, include_dirs=[d])
flag = 1
- incl_dirs = [d]
break
if flag:
dict_append(info, define_macros=ver_param['macros'])
@@ -1058,9 +1057,9 @@ class mkl_info(system_info):
for d in paths:
dirs = glob(os.path.join(d, 'mkl', '*'))
dirs += glob(os.path.join(d, 'mkl*'))
- for d in dirs:
- if os.path.isdir(os.path.join(d, 'lib')):
- return d
+ for sub_dir in dirs:
+ if os.path.isdir(os.path.join(sub_dir, 'lib')):
+ return sub_dir
return None
def __init__(self):
@@ -1690,23 +1689,46 @@ class blas_info(system_info):
else:
info['include_dirs'] = self.get_include_dirs()
if platform.system() == 'Windows':
- # The check for windows is needed because has_cblas uses the
+ # The check for windows is needed because get_cblas_libs uses the
# same compiler that was used to compile Python and msvc is
# often not installed when mingw is being used. This rough
# treatment is not desirable, but windows is tricky.
info['language'] = 'f77' # XXX: is it generally true?
else:
- lib = self.has_cblas(info)
+ lib = self.get_cblas_libs(info)
if lib is not None:
info['language'] = 'c'
- info['libraries'] = [lib]
+ info['libraries'] = lib
info['define_macros'] = [('HAVE_CBLAS', None)]
self.set_info(**info)
- def has_cblas(self, info):
+ def get_cblas_libs(self, info):
+ """ Check whether we can link with CBLAS interface
+
+ This method will search through several combinations of libraries
+ to check whether CBLAS is present:
+
+ 1. Libraries in ``info['libraries']``, as is
+ 2. As 1. but also explicitly adding ``'cblas'`` as a library
+ 3. As 1. but also explicitly adding ``'blas'`` as a library
+ 4. Check only library ``'cblas'``
+ 5. Check only library ``'blas'``
+
+ Parameters
+ ----------
+ info : dict
+ system information dictionary for compilation and linking
+
+ Returns
+ -------
+ libraries : list of str or None
+ a list of libraries that enables the use of CBLAS interface.
+ Returns None if not found or a compilation error occurs.
+
+ Since 1.17 returns a list.
+ """
# primitive cblas check by looking for the header and trying to link
# cblas or blas
- res = False
c = customized_ccompiler()
tmpdir = tempfile.mkdtemp()
s = """#include <cblas.h>
@@ -1725,27 +1747,26 @@ class blas_info(system_info):
# check we can compile (find headers)
obj = c.compile([src], output_dir=tmpdir,
include_dirs=self.get_include_dirs())
+ except (distutils.ccompiler.CompileError, distutils.ccompiler.LinkError):
+ return None
- # check we can link (find library)
- # some systems have separate cblas and blas libs. First
- # check for cblas lib, and if not present check for blas lib.
+ # check we can link (find library)
+ # some systems have separate cblas and blas libs.
+ for libs in [info['libraries'], ['cblas'] + info['libraries'],
+ ['blas'] + info['libraries'], ['cblas'], ['blas']]:
try:
c.link_executable(obj, os.path.join(tmpdir, "a.out"),
- libraries=["cblas"],
+ libraries=libs,
library_dirs=info['library_dirs'],
extra_postargs=info.get('extra_link_args', []))
- res = "cblas"
+ return libs
+ # This breaks the for loop
+ break
except distutils.ccompiler.LinkError:
- c.link_executable(obj, os.path.join(tmpdir, "a.out"),
- libraries=["blas"],
- library_dirs=info['library_dirs'],
- extra_postargs=info.get('extra_link_args', []))
- res = "blas"
- except distutils.ccompiler.CompileError:
- res = None
+ pass
finally:
shutil.rmtree(tmpdir)
- return res
+ return None
class openblas_info(blas_info):
diff --git a/numpy/distutils/tests/test_exec_command.py b/numpy/distutils/tests/test_exec_command.py
index 8bd265007..37912f5ba 100644
--- a/numpy/distutils/tests/test_exec_command.py
+++ b/numpy/distutils/tests/test_exec_command.py
@@ -6,7 +6,7 @@ from tempfile import TemporaryFile
from numpy.distutils import exec_command
from numpy.distutils.exec_command import get_pythonexe
-from numpy.testing import tempdir, assert_
+from numpy.testing import tempdir, assert_, assert_warns
# In python 3 stdout, stderr are text (unicode compliant) devices, so to
# emulate them import StringIO from the io module.
@@ -71,27 +71,31 @@ def test_exec_command_stdout():
# Test posix version:
with redirect_stdout(StringIO()):
with redirect_stderr(TemporaryFile()):
- exec_command.exec_command("cd '.'")
+ with assert_warns(DeprecationWarning):
+ exec_command.exec_command("cd '.'")
if os.name == 'posix':
# Test general (non-posix) version:
with emulate_nonposix():
with redirect_stdout(StringIO()):
with redirect_stderr(TemporaryFile()):
- exec_command.exec_command("cd '.'")
+ with assert_warns(DeprecationWarning):
+ exec_command.exec_command("cd '.'")
def test_exec_command_stderr():
# Test posix version:
with redirect_stdout(TemporaryFile(mode='w+')):
with redirect_stderr(StringIO()):
- exec_command.exec_command("cd '.'")
+ with assert_warns(DeprecationWarning):
+ exec_command.exec_command("cd '.'")
if os.name == 'posix':
# Test general (non-posix) version:
with emulate_nonposix():
with redirect_stdout(TemporaryFile()):
with redirect_stderr(StringIO()):
- exec_command.exec_command("cd '.'")
+ with assert_warns(DeprecationWarning):
+ exec_command.exec_command("cd '.'")
class TestExecCommand(object):
@@ -205,11 +209,12 @@ class TestExecCommand(object):
def test_basic(self):
with redirect_stdout(StringIO()):
with redirect_stderr(StringIO()):
- if os.name == "posix":
- self.check_posix(use_tee=0)
- self.check_posix(use_tee=1)
- elif os.name == "nt":
- self.check_nt(use_tee=0)
- self.check_nt(use_tee=1)
- self.check_execute_in(use_tee=0)
- self.check_execute_in(use_tee=1)
+ with assert_warns(DeprecationWarning):
+ if os.name == "posix":
+ self.check_posix(use_tee=0)
+ self.check_posix(use_tee=1)
+ elif os.name == "nt":
+ self.check_nt(use_tee=0)
+ self.check_nt(use_tee=1)
+ self.check_execute_in(use_tee=0)
+ self.check_execute_in(use_tee=1)