def _should_recompile(auxdir, parser, modules, compiler): """Determines whether the fpy_auxiliary module should be rewritten and recompiled. """ from os import path from shutil import copy recompile = False for modulename in modules: module = parser.modules[modulename] auxpath = path.join(auxdir, path.split(module.filepath)[1]) if not path.isfile(auxpath): copy(module.filepath, auxdir) recompile = True else: fmtime = path.getmtime(module.filepath) xmtime = path.getmtime(auxpath) if xmtime < fmtime: recompile = True copy(module.filepath, auxdir) #Also check the version numbers of the template fpy_auxiliary.f90 and the one present #in our directory (if it exists). fpyaux = path.join(auxdir, "fpy_auxiliary.f90") if path.isfile(fpyaux): from fortpy.testing.compilers import template_version, get_fortpy_version tversion = template_version(compiler, "fpy_auxiliary.f90") xversion = get_fortpy_version(compiler, fpyaux) recompile = recompile or (xversion != tversion) else: recompile = True return recompile
def get_fortpy_version(self, fortpath): """Gets the fortpy version number from the first line of the specified file.""" from fortpy.testing.compilers import get_fortpy_version return get_fortpy_version(self.compiler, fortpath)