diff options
author | Kristofor Maynard <kristofor.maynard@gmail.com> | 2017-11-07 12:23:17 -0500 |
---|---|---|
committer | Kristofor Maynard <kristofor.maynard@gmail.com> | 2017-11-07 12:45:37 -0500 |
commit | fa06bee7418408a6645134a2ce8edae49c9fef64 (patch) | |
tree | 908b32f21685cab3ed95979a6dba6d00f17df14e /numpy | |
parent | ece0c5d2107143532df4f1abdb56d74212a47c7e (diff) | |
download | numpy-fa06bee7418408a6645134a2ce8edae49c9fef64.tar.gz |
ENH: let f2py discover location of libgfortran
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/distutils/fcompiler/gnu.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/numpy/distutils/fcompiler/gnu.py b/numpy/distutils/fcompiler/gnu.py index 10c60dc6f..ca0e34171 100644 --- a/numpy/distutils/fcompiler/gnu.py +++ b/numpy/distutils/fcompiler/gnu.py @@ -166,6 +166,23 @@ class GnuFCompiler(FCompiler): return os.path.dirname(output) return None + def get_libgfortran_dir(self): + if sys.platform[:5] == 'linux': + libgfortran_name = 'libgfortran.so' + elif sys.platform == 'darwin': + libgfortran_name = 'libgfortran.dylib' + else: + libgfortran_name = None + + libgfortran_dir = None + if libgfortran_name: + find_lib_arg = ['-print-file-name={0}'.format(libgfortran_name)] + status, output = exec_command( + self.compiler_f77 + find_lib_arg, use_tee=0) + if not status: + libgfortran_dir = os.path.dirname(output) + return libgfortran_dir + def get_library_dirs(self): opt = [] if sys.platform[:5] != 'linux': @@ -182,6 +199,11 @@ class GnuFCompiler(FCompiler): if os.path.exists(path): opt.append(d2) opt.append(d) + # For Macports / Linux, libgfortran and libgcc are not co-located + if sys.platform[:5] == 'linux' or sys.platform == 'darwin': + lib_gfortran_dir = self.get_libgfortran_dir() + if lib_gfortran_dir: + opt.append(lib_gfortran_dir) return opt def get_libraries(self): @@ -327,6 +349,11 @@ class Gnu95FCompiler(GnuFCompiler): mingwdir = os.path.normpath(path) if os.path.exists(os.path.join(mingwdir, "libmingwex.a")): opt.append(mingwdir) + # For Macports / Linux, libgfortran and libgcc are not co-located + if sys.platform[:5] == 'linux' or sys.platform == 'darwin': + lib_gfortran_dir = self.get_libgfortran_dir() + if lib_gfortran_dir: + opt.append(lib_gfortran_dir) return opt def get_libraries(self): |