summaryrefslogtreecommitdiff
path: root/numpy/distutils/fcompiler
diff options
context:
space:
mode:
authorDavid Cournapeau <cournape@gmail.com>2009-12-10 10:57:50 +0000
committerDavid Cournapeau <cournape@gmail.com>2009-12-10 10:57:50 +0000
commit8d24b14a7eed3fba60bab462e873214cc9fa2a1f (patch)
tree0ebc31cb1f8c6656d7b2e0c65ce147d440191a7f /numpy/distutils/fcompiler
parentdcd5238d0c6f07567cb94a932b4b9dfcf795e70b (diff)
downloadnumpy-8d24b14a7eed3fba60bab462e873214cc9fa2a1f.tar.gz
BUG: fix 1087, thanks to Leek for the fix.
Diffstat (limited to 'numpy/distutils/fcompiler')
-rw-r--r--numpy/distutils/fcompiler/gnu.py33
1 files changed, 17 insertions, 16 deletions
diff --git a/numpy/distutils/fcompiler/gnu.py b/numpy/distutils/fcompiler/gnu.py
index 74ea5db4d..cc9e1e7cb 100644
--- a/numpy/distutils/fcompiler/gnu.py
+++ b/numpy/distutils/fcompiler/gnu.py
@@ -3,6 +3,7 @@ import os
import sys
import warnings
import platform
+import tempfile
from subprocess import Popen, PIPE, STDOUT
from numpy.distutils.cpuinfo import cpu
@@ -15,13 +16,6 @@ compilers = ['GnuFCompiler', 'Gnu95FCompiler']
TARGET_R = re.compile("Target: ([a-zA-Z0-9_\-]*)")
-# XXX: do we really need to check for target ? If the arch is not supported,
-# the return code should be != 0
-_R_ARCHS = {"ppc": r"^Target: (powerpc-.*)$",
- "i686": r"^Target: (i686-.*)$",
- "x86_64": r"^Target: (i686-.*)$",
- "ppc64": r"^Target: (powerpc-.*)$",}
-
# XXX: handle cross compilation
def is_win64():
return sys.platform == "win32" and platform.architecture()[0] == "64bit"
@@ -329,20 +323,27 @@ class Gnu95FCompiler(GnuFCompiler):
return ['-O0']
else:
return GnuFCompiler.get_flags_opt(self)
+
def _can_target(cmd, arch):
"""Return true is the command supports the -arch flag for the given
architecture."""
newcmd = cmd[:]
- newcmd.extend(["-arch", arch, "-v"])
- p = Popen(newcmd, stderr=STDOUT, stdout=PIPE)
- stdout, stderr = p.communicate()
- if p.returncode == 0:
- for line in stdout.splitlines():
- m = re.search(_R_ARCHS[arch], line)
- if m:
- return True
+ fid, filename = tempfile.mkstemp(suffix=".f")
+ try:
+ d = os.path.dirname(filename)
+ output = os.path.splitext(filename)[0] + ".o"
+ try:
+ newcmd.extend(["-arch", arch, "-c", filename])
+ p = Popen(newcmd, stderr=STDOUT, stdout=PIPE, cwd=d)
+ p.communicate()
+ return p.returncode == 0
+ finally:
+ if os.path.exists(output):
+ os.remove(output)
+ finally:
+ os.remove(filename)
return False
-
+
if __name__ == '__main__':
from distutils import log
log.set_verbosity(2)