diff options
Diffstat (limited to 'numpy/distutils/fcompiler')
-rw-r--r-- | numpy/distutils/fcompiler/__init__.py | 15 | ||||
-rw-r--r-- | numpy/distutils/fcompiler/absoft.py | 2 | ||||
-rw-r--r-- | numpy/distutils/fcompiler/compaq.py | 12 | ||||
-rw-r--r-- | numpy/distutils/fcompiler/environment.py | 5 | ||||
-rw-r--r-- | numpy/distutils/fcompiler/g95.py | 2 | ||||
-rw-r--r-- | numpy/distutils/fcompiler/gnu.py | 36 | ||||
-rw-r--r-- | numpy/distutils/fcompiler/hpux.py | 2 | ||||
-rw-r--r-- | numpy/distutils/fcompiler/ibm.py | 2 | ||||
-rw-r--r-- | numpy/distutils/fcompiler/intel.py | 2 | ||||
-rw-r--r-- | numpy/distutils/fcompiler/lahey.py | 2 | ||||
-rw-r--r-- | numpy/distutils/fcompiler/mips.py | 2 | ||||
-rw-r--r-- | numpy/distutils/fcompiler/nag.py | 2 | ||||
-rw-r--r-- | numpy/distutils/fcompiler/none.py | 2 | ||||
-rw-r--r-- | numpy/distutils/fcompiler/pathf95.py | 2 | ||||
-rw-r--r-- | numpy/distutils/fcompiler/pg.py | 98 | ||||
-rw-r--r-- | numpy/distutils/fcompiler/sun.py | 2 | ||||
-rw-r--r-- | numpy/distutils/fcompiler/vast.py | 2 |
17 files changed, 62 insertions, 128 deletions
diff --git a/numpy/distutils/fcompiler/__init__.py b/numpy/distutils/fcompiler/__init__.py index 3723470f3..1c3069363 100644 --- a/numpy/distutils/fcompiler/__init__.py +++ b/numpy/distutils/fcompiler/__init__.py @@ -13,15 +13,12 @@ should be a list. But note that FCompiler.executables is actually a dictionary of commands. """ -from __future__ import division, absolute_import, print_function - __all__ = ['FCompiler', 'new_fcompiler', 'show_fcompilers', 'dummy_fortran_file'] import os import sys import re -import types from numpy.compat import open_latin1 @@ -36,7 +33,6 @@ from numpy.distutils import log from numpy.distutils.misc_util import is_string, all_strings, is_sequence, \ make_temp_file, get_shared_lib_extension from numpy.distutils.exec_command import find_executable -from numpy.distutils.compat import get_exception from numpy.distutils import _shell_utils from .environment import EnvironmentConfig @@ -614,8 +610,8 @@ class FCompiler(CCompiler): src) try: self.spawn(command, display=display) - except DistutilsExecError: - msg = str(get_exception()) + except DistutilsExecError as e: + msg = str(e) raise CompileError(msg) def module_options(self, module_dirs, module_build_dir): @@ -682,8 +678,8 @@ class FCompiler(CCompiler): command = linker + ld_args try: self.spawn(command) - except DistutilsExecError: - msg = str(get_exception()) + except DistutilsExecError as e: + msg = str(e) raise LinkError(msg) else: log.debug("skipping %s (up-to-date)", output_filename) @@ -931,8 +927,7 @@ def show_fcompilers(dist=None): c = new_fcompiler(compiler=compiler, verbose=dist.verbose) c.customize(dist) v = c.get_version() - except (DistutilsModuleError, CompilerNotFound): - e = get_exception() + except (DistutilsModuleError, CompilerNotFound) as e: log.debug("show_fcompilers: %s not found" % (compiler,)) log.debug(repr(e)) diff --git a/numpy/distutils/fcompiler/absoft.py b/numpy/distutils/fcompiler/absoft.py index d14fee0e1..efe3a4cb5 100644 --- a/numpy/distutils/fcompiler/absoft.py +++ b/numpy/distutils/fcompiler/absoft.py @@ -5,8 +5,6 @@ # Notes: # - when using -g77 then use -DUNDERSCORE_G77 to compile f2py # generated extension modules (works for f2py v2.45.241_1936 and up) -from __future__ import division, absolute_import, print_function - import os from numpy.distutils.cpuinfo import cpu diff --git a/numpy/distutils/fcompiler/compaq.py b/numpy/distutils/fcompiler/compaq.py index 671b3a55f..6ce590c7c 100644 --- a/numpy/distutils/fcompiler/compaq.py +++ b/numpy/distutils/fcompiler/compaq.py @@ -1,12 +1,9 @@ #http://www.compaq.com/fortran/docs/ -from __future__ import division, absolute_import, print_function - import os import sys from numpy.distutils.fcompiler import FCompiler -from numpy.distutils.compat import get_exception from distutils.errors import DistutilsPlatformError compilers = ['CompaqFCompiler'] @@ -82,19 +79,16 @@ class CompaqVisualFCompiler(FCompiler): ar_exe = m.lib except DistutilsPlatformError: pass - except AttributeError: - msg = get_exception() + except AttributeError as e: if '_MSVCCompiler__root' in str(msg): print('Ignoring "%s" (I think it is msvccompiler.py bug)' % (msg)) else: raise - except IOError: - e = get_exception() + except IOError as e: if not "vcvarsall.bat" in str(e): print("Unexpected IOError in", __file__) raise e - except ValueError: - e = get_exception() + except ValueError as e: if not "'path'" in str(e): print("Unexpected ValueError in", __file__) raise e diff --git a/numpy/distutils/fcompiler/environment.py b/numpy/distutils/fcompiler/environment.py index bb362d483..21a5be003 100644 --- a/numpy/distutils/fcompiler/environment.py +++ b/numpy/distutils/fcompiler/environment.py @@ -1,12 +1,9 @@ -from __future__ import division, absolute_import, print_function - import os -import warnings from distutils.dist import Distribution __metaclass__ = type -class EnvironmentConfig(object): +class EnvironmentConfig: def __init__(self, distutils_section='ALL', **kw): self._distutils_section = distutils_section self._conf_keys = kw diff --git a/numpy/distutils/fcompiler/g95.py b/numpy/distutils/fcompiler/g95.py index e7c659b33..e109a972a 100644 --- a/numpy/distutils/fcompiler/g95.py +++ b/numpy/distutils/fcompiler/g95.py @@ -1,6 +1,4 @@ # http://g95.sourceforge.net/ -from __future__ import division, absolute_import, print_function - from numpy.distutils.fcompiler import FCompiler compilers = ['G95FCompiler'] diff --git a/numpy/distutils/fcompiler/gnu.py b/numpy/distutils/fcompiler/gnu.py index 965c67041..796dff351 100644 --- a/numpy/distutils/fcompiler/gnu.py +++ b/numpy/distutils/fcompiler/gnu.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import re import os import sys @@ -12,8 +10,6 @@ import subprocess from subprocess import Popen, PIPE, STDOUT from numpy.distutils.exec_command import filepath_from_subprocess_output from numpy.distutils.fcompiler import FCompiler -from numpy.distutils.compat import get_exception -from numpy.distutils.system_info import system_info compilers = ['GnuFCompiler', 'Gnu95FCompiler'] @@ -126,26 +122,17 @@ class GnuFCompiler(FCompiler): # error checking. if not target: # If MACOSX_DEPLOYMENT_TARGET is not set in the environment, - # we try to get it first from the Python Makefile and then we - # fall back to setting it to 10.3 to maximize the set of - # versions we can work with. This is a reasonable default + # we try to get it first from sysconfig and then + # fall back to setting it to 10.9 This is a reasonable default # even when using the official Python dist and those derived # from it. - import distutils.sysconfig as sc - g = {} - try: - get_makefile_filename = sc.get_makefile_filename - except AttributeError: - pass # i.e. PyPy - else: - filename = get_makefile_filename() - sc.parse_makefile(filename, g) - target = g.get('MACOSX_DEPLOYMENT_TARGET', '10.3') - os.environ['MACOSX_DEPLOYMENT_TARGET'] = target - if target == '10.3': - s = 'Env. variable MACOSX_DEPLOYMENT_TARGET set to 10.3' + import sysconfig + target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') + if not target: + target = '10.9' + s = f'Env. variable MACOSX_DEPLOYMENT_TARGET set to {target}' warnings.warn(s, stacklevel=2) - + os.environ['MACOSX_DEPLOYMENT_TARGET'] = target opt.extend(['-undefined', 'dynamic_lookup', '-bundle']) else: opt.append("-shared") @@ -415,8 +402,7 @@ class Gnu95FCompiler(GnuFCompiler): break h.update(block) text = base64.b32encode(h.digest()) - if sys.version_info[0] >= 3: - text = text.decode('ascii') + text = text.decode('ascii') return text.rstrip('=') def _link_wrapper_lib(self, objects, output_dir, extra_dll_dir, @@ -560,5 +546,5 @@ if __name__ == '__main__': print(customized_fcompiler('gnu').get_version()) try: print(customized_fcompiler('g95').get_version()) - except Exception: - print(get_exception()) + except Exception as e: + print(e) diff --git a/numpy/distutils/fcompiler/hpux.py b/numpy/distutils/fcompiler/hpux.py index 51bad548a..09e6483bf 100644 --- a/numpy/distutils/fcompiler/hpux.py +++ b/numpy/distutils/fcompiler/hpux.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - from numpy.distutils.fcompiler import FCompiler compilers = ['HPUXFCompiler'] diff --git a/numpy/distutils/fcompiler/ibm.py b/numpy/distutils/fcompiler/ibm.py index 70d2132e1..4a83682e5 100644 --- a/numpy/distutils/fcompiler/ibm.py +++ b/numpy/distutils/fcompiler/ibm.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os import re import sys diff --git a/numpy/distutils/fcompiler/intel.py b/numpy/distutils/fcompiler/intel.py index 51f681274..d84f38c76 100644 --- a/numpy/distutils/fcompiler/intel.py +++ b/numpy/distutils/fcompiler/intel.py @@ -1,6 +1,4 @@ # http://developer.intel.com/software/products/compilers/flin/ -from __future__ import division, absolute_import, print_function - import sys from numpy.distutils.ccompiler import simple_version_match diff --git a/numpy/distutils/fcompiler/lahey.py b/numpy/distutils/fcompiler/lahey.py index 1beb662f4..e92583826 100644 --- a/numpy/distutils/fcompiler/lahey.py +++ b/numpy/distutils/fcompiler/lahey.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os from numpy.distutils.fcompiler import FCompiler diff --git a/numpy/distutils/fcompiler/mips.py b/numpy/distutils/fcompiler/mips.py index da337b24a..a09738045 100644 --- a/numpy/distutils/fcompiler/mips.py +++ b/numpy/distutils/fcompiler/mips.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - from numpy.distutils.cpuinfo import cpu from numpy.distutils.fcompiler import FCompiler diff --git a/numpy/distutils/fcompiler/nag.py b/numpy/distutils/fcompiler/nag.py index cb71d548c..908e724e6 100644 --- a/numpy/distutils/fcompiler/nag.py +++ b/numpy/distutils/fcompiler/nag.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys import re from numpy.distutils.fcompiler import FCompiler diff --git a/numpy/distutils/fcompiler/none.py b/numpy/distutils/fcompiler/none.py index bdeea1560..ef411fffc 100644 --- a/numpy/distutils/fcompiler/none.py +++ b/numpy/distutils/fcompiler/none.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - from numpy.distutils.fcompiler import FCompiler from numpy.distutils import customized_fcompiler diff --git a/numpy/distutils/fcompiler/pathf95.py b/numpy/distutils/fcompiler/pathf95.py index 5de86f63a..0768cb12e 100644 --- a/numpy/distutils/fcompiler/pathf95.py +++ b/numpy/distutils/fcompiler/pathf95.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - from numpy.distutils.fcompiler import FCompiler compilers = ['PathScaleFCompiler'] diff --git a/numpy/distutils/fcompiler/pg.py b/numpy/distutils/fcompiler/pg.py index 9c51947fd..eb628cb63 100644 --- a/numpy/distutils/fcompiler/pg.py +++ b/numpy/distutils/fcompiler/pg.py @@ -1,9 +1,7 @@ # http://www.pgroup.com -from __future__ import division, absolute_import, print_function - import sys -from numpy.distutils.fcompiler import FCompiler, dummy_fortran_file +from numpy.distutils.fcompiler import FCompiler from sys import platform from os.path import join, dirname, normpath @@ -64,72 +62,60 @@ class PGroupFCompiler(FCompiler): return '-R%s' % dir -if sys.version_info >= (3, 5): - import functools - - class PGroupFlangCompiler(FCompiler): - compiler_type = 'flang' - description = 'Portland Group Fortran LLVM Compiler' - version_pattern = r'\s*(flang|clang) version (?P<version>[\d.-]+).*' - - ar_exe = 'lib.exe' - possible_executables = ['flang'] - - executables = { - 'version_cmd': ["<F77>", "--version"], - 'compiler_f77': ["flang"], - 'compiler_fix': ["flang"], - 'compiler_f90': ["flang"], - 'linker_so': [None], - 'archiver': [ar_exe, "/verbose", "/OUT:"], - 'ranlib': None - } +import functools - library_switch = '/OUT:' # No space after /OUT:! - module_dir_switch = '-module ' # Don't remove ending space! +class PGroupFlangCompiler(FCompiler): + compiler_type = 'flang' + description = 'Portland Group Fortran LLVM Compiler' + version_pattern = r'\s*(flang|clang) version (?P<version>[\d.-]+).*' - def get_libraries(self): - opt = FCompiler.get_libraries(self) - opt.extend(['flang', 'flangrti', 'ompstub']) - return opt + ar_exe = 'lib.exe' + possible_executables = ['flang'] - @functools.lru_cache(maxsize=128) - def get_library_dirs(self): - """List of compiler library directories.""" - opt = FCompiler.get_library_dirs(self) - flang_dir = dirname(self.executables['compiler_f77'][0]) - opt.append(normpath(join(flang_dir, '..', 'lib'))) + executables = { + 'version_cmd': ["<F77>", "--version"], + 'compiler_f77': ["flang"], + 'compiler_fix': ["flang"], + 'compiler_f90': ["flang"], + 'linker_so': [None], + 'archiver': [ar_exe, "/verbose", "/OUT:"], + 'ranlib': None + } - return opt + library_switch = '/OUT:' # No space after /OUT:! + module_dir_switch = '-module ' # Don't remove ending space! - def get_flags(self): - return [] + def get_libraries(self): + opt = FCompiler.get_libraries(self) + opt.extend(['flang', 'flangrti', 'ompstub']) + return opt - def get_flags_free(self): - return [] + @functools.lru_cache(maxsize=128) + def get_library_dirs(self): + """List of compiler library directories.""" + opt = FCompiler.get_library_dirs(self) + flang_dir = dirname(self.executables['compiler_f77'][0]) + opt.append(normpath(join(flang_dir, '..', 'lib'))) - def get_flags_debug(self): - return ['-g'] + return opt - def get_flags_opt(self): - return ['-O3'] + def get_flags(self): + return [] - def get_flags_arch(self): - return [] + def get_flags_free(self): + return [] - def runtime_library_dir_option(self, dir): - raise NotImplementedError + def get_flags_debug(self): + return ['-g'] -else: - from numpy.distutils.fcompiler import CompilerNotFound + def get_flags_opt(self): + return ['-O3'] - # No point in supporting on older Pythons because not ABI compatible - class PGroupFlangCompiler(FCompiler): - compiler_type = 'flang' - description = 'Portland Group Fortran LLVM Compiler' + def get_flags_arch(self): + return [] - def get_version(self): - raise CompilerNotFound('Flang unsupported on Python < 3.5') + def runtime_library_dir_option(self, dir): + raise NotImplementedError if __name__ == '__main__': diff --git a/numpy/distutils/fcompiler/sun.py b/numpy/distutils/fcompiler/sun.py index 561ea854f..d039f0b25 100644 --- a/numpy/distutils/fcompiler/sun.py +++ b/numpy/distutils/fcompiler/sun.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - from numpy.distutils.ccompiler import simple_version_match from numpy.distutils.fcompiler import FCompiler diff --git a/numpy/distutils/fcompiler/vast.py b/numpy/distutils/fcompiler/vast.py index adc1591bd..92a1647ba 100644 --- a/numpy/distutils/fcompiler/vast.py +++ b/numpy/distutils/fcompiler/vast.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os from numpy.distutils.fcompiler.gnu import GnuFCompiler |