def get_flags_fix(self): opt = FCompiler.get_flags_fix(self) opt.extend( ["-YCFRL=1", "-YCOM_NAMES=LCS", "-YCOM_PFX", "-YEXT_PFX", "-YCOM_SFX=_", "-YEXT_SFX=_", "-YEXT_NAMES=LCS"] ) opt.extend(["-f", "fixed"]) return opt
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'))) return opt
def get_version(self,*args,**kwds): version = FCompiler.get_version(self,*args,**kwds) if version is None and sys.platform.startswith('aix'): # use lslpp to find out xlf version lslpp = find_executable('lslpp') xlf = find_executable('xlf') if os.path.exists(xlf) and os.path.exists(lslpp): s,o = exec_command(lslpp + ' -Lc xlfcmp') m = re.search('xlfcmp:(?P<version>\d+([.]\d+)+)', o) if m: version = m.group('version') xlf_dir = '/etc/opt/ibmcmp/xlf' if version is None and os.path.isdir(xlf_dir): # linux: # If the output of xlf does not contain version info # (that's the case with xlf 8.1, for instance) then # let's try another method: l = os.listdir(xlf_dir) l.sort() l.reverse() l = [d for d in l if os.path.isfile(os.path.join(xlf_dir,d,'xlf.cfg'))] if l: from distutils.version import LooseVersion self.version = version = LooseVersion(l[0]) return version
def get_flags(self): opt = FCompiler.get_flags(self) if os.name != 'nt': opt.extend(['-s']) if self.get_version(): if self.get_version()>='8.2': opt.append('-fpic') return opt
def get_flags_f90(self): opt = FCompiler.get_flags_f90(self) opt.extend(["-YCFRL=1","-YCOM_NAMES=LCS","-YCOM_PFX","-YEXT_PFX", "-YCOM_SFX=_","-YEXT_SFX=_","-YEXT_NAMES=LCS"]) if self.get_version(): if self.get_version()>'4.6': opt.extend(["-YDEALLOC=ALL"]) return opt
def get_flags(self): opt = FCompiler.get_flags(self) if os.name != "nt": opt.extend(["-s"]) if self.get_version(): if self.get_version() >= "8.2": opt.append("-fpic") return opt
def get_libraries(self): opt = FCompiler.get_libraries(self) if self.get_version() >= '10.0': opt.extend(['af90math', 'afio', 'af77math', 'U77']) elif self.get_version() >= '8.0': opt.extend(['f90math','fio','f77math','U77']) else: opt.extend(['fio','f90math','fmath','U77']) if os.name =='nt': opt.append('COMDLG32') return opt
def get_libraries(self): opt = FCompiler.get_libraries(self) if self.get_version() >= '10.0': opt.extend(['af90math', 'afio', 'af77math', 'U77']) elif self.get_version() >= '8.0': opt.extend(['f90math', 'fio', 'f77math', 'U77']) else: opt.extend(['fio', 'f90math', 'fmath', 'U77']) if os.name == 'nt': opt.append('COMDLG32') return opt
def get_libraries(self): opt = FCompiler.get_libraries(self) if self.get_version() >= "10.0": opt.extend(["af90math", "afio", "af77math", "U77"]) elif self.get_version() >= "8.0": opt.extend(["f90math", "fio", "f77math", "U77"]) else: opt.extend(["fio", "f90math", "fmath", "U77"]) if os.name == "nt": opt.append("COMDLG32") return opt
def configuration(parent_package='', top_path=None): """Configure all packages that need to be built.""" config = Configuration('', parent_package, top_path) F95FLAGS = get_compiler_flags() kwargs = {} kwargs['extra_compile_args'] = F95FLAGS kwargs['f2py_options'] = ['--quiet'] # numpy.distutils.fcompiler.FCompiler doesn't support .F95 extension compiler = FCompiler(get_default_fcompiler()) compiler.src_extensions.append('.F95') compiler.language_map['.F95'] = 'f90' # collect all Fortran sources files = os.listdir('src') exclude_sources = ['PlanetsConstants.f95', 'PythonWrapper.f95'] sources = [ os.path.join('src', file) for file in files if file.lower().endswith('.f95') and file not in exclude_sources ] # (from http://stackoverflow.com/questions/14320220/ # testing-python-c-libraries-get-build-path)): build_lib_dir = "{dirname}.{platform}-{version[0]}.{version[1]}" dirparams = { 'dirname': 'temp', 'platform': sysconfig.get_platform(), 'version': sys.version_info } libdir = os.path.join('build', build_lib_dir.format(**dirparams)) print('searching SHTOOLS in:', libdir) # Fortran compilation config.add_library('SHTOOLS', sources=sources, **kwargs) # SHTOOLS config.add_extension( 'pyshtools._SHTOOLS', include_dirs=[libdir], library_dirs=[libdir], libraries=['SHTOOLS', 'fftw3', 'm', 'lapack', 'blas'], sources=['src/pyshtools.pyf', 'src/PythonWrapper.f95'], **kwargs) # constants config.add_extension('pyshtools._constant', sources=['src/PlanetsConstants.f95'], **kwargs) return config
def get_flags_linker_so(self): opt = FCompiler.get_flags_linker_so(self) v = self.get_version() if v and v >= '8.0': opt.append('-nofor_main') if sys.platform == 'darwin': # Here, it's -dynamiclib try: idx = opt.index('-shared') opt.remove('-shared') except ValueError: idx = 0 opt[idx:idx] = ['-dynamiclib', '-Wl,-undefined,dynamic_lookup', '-Wl,-framework,Python'] return opt
def get_flags_linker_so(self): opt = FCompiler.get_flags_linker_so(self) v = self.get_version() if v and v >= "8.0": opt.append("-nofor_main") if sys.platform == "darwin": # Here, it's -dynamiclib try: idx = opt.index("-shared") opt.remove("-shared") except ValueError: idx = 0 opt[idx:idx] = ["-dynamiclib", "-Wl,-undefined,dynamic_lookup", "-Wl,-framework,Python"] return opt
def get_library_dirs(self): opt = FCompiler.get_library_dirs(self) d = os.environ.get("ABSOFT") if d: if self.get_version() >= "10.0": # use shared libraries, the static libraries were not compiled -fPIC prefix = "sh" else: prefix = "" if cpu.is_64bit(): suffix = "64" else: suffix = "" opt.append(os.path.join(d, "%slib%s" % (prefix, suffix))) return opt
def get_library_dirs(self): opt = FCompiler.get_library_dirs(self) d = os.environ.get('ABSOFT') if d: if self.get_version() >= '10.0': # use shared libraries, the static libraries were not compiled -fPIC prefix = 'sh' else: prefix = '' if cpu.is_64bit(): suffix = '64' else: suffix = '' opt.append(os.path.join(d, '%slib%s' % (prefix, suffix))) return opt
def get_flags_f77(self): opt = FCompiler.get_flags_f77(self) opt.extend(['-N22','-N90','-N110']) v = self.get_version() if os.name == 'nt': if v and v>='8.0': opt.extend(['-f','-N15']) else: opt.append('-f') if v: if v<='4.6': opt.append('-B108') else: # Though -N15 is undocumented, it works with # Absoft 8.0 on Linux opt.append('-N15') return opt
def get_flags_f77(self): opt = FCompiler.get_flags_f77(self) opt.extend(["-N22", "-N90", "-N110"]) v = self.get_version() if os.name == "nt": if v and v >= "8.0": opt.extend(["-f", "-N15"]) else: opt.append("-f") if v: if v <= "4.6": opt.append("-B108") else: # Though -N15 is undocumented, it works with # Absoft 8.0 on Linux opt.append("-N15") return opt
def get_flags_linker_so(self): opt = FCompiler.get_flags_linker_so(self) v = self.get_version() if v and v >= '8.0': opt.append('-nofor_main') return opt
def get_version(self, force=0, ok_status=[256,0,1]): # XXX status==256 may indicate 'unrecognized option' or # 'no input file'. So, version_cmd needs more work. return FCompiler.get_version(self,force,ok_status)
def get_libraries(self): opt = FCompiler.get_libraries(self) opt.extend(['flang', 'flangrti', 'ompstub']) return opt