summaryrefslogtreecommitdiff
path: root/numpy/f2py/tests
diff options
context:
space:
mode:
authorPauli Virtanen <pav@iki.fi>2019-12-14 15:40:42 +0200
committerPauli Virtanen <pav@iki.fi>2019-12-14 17:09:06 +0200
commit66b17db5e9dd182812dfd1de77b2874cf070e00e (patch)
tree1d971004f5f8cbed3b1691119e972f71cbafdc3f /numpy/f2py/tests
parent5a4f62bbf7622530e2a43d1859ae496537e9f0f0 (diff)
downloadnumpy-66b17db5e9dd182812dfd1de77b2874cf070e00e.tar.gz
TST: f2py: fix race condition in f2py test _get_compiler_status
Distutils code needs to run in different temporary directories, probably because they create `_configtest.c` files for compiler detection in the current directory.
Diffstat (limited to 'numpy/f2py/tests')
-rw-r--r--numpy/f2py/tests/util.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/numpy/f2py/tests/util.py b/numpy/f2py/tests/util.py
index 8211a63f0..bf005df88 100644
--- a/numpy/f2py/tests/util.py
+++ b/numpy/f2py/tests/util.py
@@ -204,14 +204,20 @@ def _get_compiler_status():
""")
code = code % dict(syspath=repr(sys.path))
- with temppath(suffix='.py') as script:
+ tmpdir = tempfile.mkdtemp()
+ try:
+ script = os.path.join(tmpdir, 'setup.py')
+
with open(script, 'w') as f:
f.write(code)
- cmd = [sys.executable, script, 'config']
+ cmd = [sys.executable, 'setup.py', 'config']
p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT)
+ stderr=subprocess.STDOUT,
+ cwd=tmpdir)
out, err = p.communicate()
+ finally:
+ shutil.rmtree(tmpdir)
m = re.search(br'COMPILERS:(\d+),(\d+),(\d+)', out)
if m: