Exemplo n.º 1
0
def show_fcompilers(dist=None):
    """Print list of available compilers (used by the "--help-fcompiler"
    option to "config_fc").
    """
    from numpy.distutils import fcompiler, log
    if dist is None:
        from distutils.dist import Distribution
        from numpy.distutils.command.config_compiler import config_fc
        dist = Distribution()
        dist.script_name = os.path.basename(sys.argv[0])
        dist.script_args = ['config_fc'] + sys.argv[1:]
        try:
            dist.script_args.remove('--help-fcompiler')
        except ValueError:
            pass
        dist.cmdclass['config_fc'] = config_fc
        dist.parse_config_files()
        dist.parse_command_line()
    compilers = {}
    compilers_na = []
    compilers_ni = []
    if not fcompiler.fcompiler_class:
        fcompiler.load_all_fcompiler_classes()
    platform_compilers = fcompiler.available_fcompilers_for_platform()
    for compiler in platform_compilers:
        v = None
        log.set_verbosity(-2)
        try:
            c = fcompiler.new_fcompiler(compiler=compiler, verbose=dist.verbose)
            c.customize(dist)
            v = c.get_version()
        except (fcompiler.DistutilsModuleError, fcompiler.CompilerNotFound), e:
            log.debug("show_fcompilers: %s not found" % (compiler,))
            log.debug(repr(e))

        if v is None:
            compilers_na.append(("fcompiler="+compiler, None,
                              fcompiler.fcompiler_class[compiler][2]))
        else:
            c.dump_properties()
            compilers[compiler] = c
Exemplo n.º 2
0
def run_compile():
    """
    Do it all in one call!
    """
    import tempfile

    i = sys.argv.index('-c')
    del sys.argv[i]

    remove_build_dir = 0
    try:
        i = sys.argv.index('--build-dir')
    except ValueError:
        i = None
    if i is not None:
        build_dir = sys.argv[i + 1]
        del sys.argv[i + 1]
        del sys.argv[i]
    else:
        remove_build_dir = 1
        build_dir = tempfile.mkdtemp()

    _reg1 = re.compile(r'[-][-]link[-]')
    sysinfo_flags = [_m for _m in sys.argv[1:] if _reg1.match(_m)]
    sys.argv = [_m for _m in sys.argv if _m not in sysinfo_flags]
    if sysinfo_flags:
        sysinfo_flags = [f[7:] for f in sysinfo_flags]

    _reg2 = re.compile(
        r'[-][-]((no[-]|)(wrap[-]functions|lower)|debug[-]capi|quiet)|[-]include')
    f2py_flags = [_m for _m in sys.argv[1:] if _reg2.match(_m)]
    sys.argv = [_m for _m in sys.argv if _m not in f2py_flags]
    f2py_flags2 = []
    fl = 0
    for a in sys.argv[1:]:
        if a in ['only:', 'skip:']:
            fl = 1
        elif a == ':':
            fl = 0
        if fl or a == ':':
            f2py_flags2.append(a)
    if f2py_flags2 and f2py_flags2[-1] != ':':
        f2py_flags2.append(':')
    f2py_flags.extend(f2py_flags2)

    sys.argv = [_m for _m in sys.argv if _m not in f2py_flags2]
    _reg3 = re.compile(
        r'[-][-]((f(90)?compiler([-]exec|)|compiler)=|help[-]compiler)')
    flib_flags = [_m for _m in sys.argv[1:] if _reg3.match(_m)]
    sys.argv = [_m for _m in sys.argv if _m not in flib_flags]
    _reg4 = re.compile(
        r'[-][-]((f(77|90)(flags|exec)|opt|arch)=|(debug|noopt|noarch|help[-]fcompiler))')
    fc_flags = [_m for _m in sys.argv[1:] if _reg4.match(_m)]
    sys.argv = [_m for _m in sys.argv if _m not in fc_flags]

    if 1:
        del_list = []
        for s in flib_flags:
            v = '--fcompiler='
            if s[:len(v)] == v:
                from numpy.distutils import fcompiler
                fcompiler.load_all_fcompiler_classes()
                allowed_keys = list(fcompiler.fcompiler_class.keys())
                nv = ov = s[len(v):].lower()
                if ov not in allowed_keys:
                    vmap = {}  # XXX
                    try:
                        nv = vmap[ov]
                    except KeyError:
                        if ov not in vmap.values():
                            print('Unknown vendor: "%s"' % (s[len(v):]))
                    nv = ov
                i = flib_flags.index(s)
                flib_flags[i] = '--fcompiler=' + nv
                continue
        for s in del_list:
            i = flib_flags.index(s)
            del flib_flags[i]
        assert len(flib_flags) <= 2, repr(flib_flags)

    _reg5 = re.compile(r'[-][-](verbose)')
    setup_flags = [_m for _m in sys.argv[1:] if _reg5.match(_m)]
    sys.argv = [_m for _m in sys.argv if _m not in setup_flags]

    if '--quiet' in f2py_flags:
        setup_flags.append('--quiet')

    modulename = 'untitled'
    sources = sys.argv[1:]

    for optname in ['--include_paths', '--include-paths', '--f2cmap']:
        if optname in sys.argv:
            i = sys.argv.index(optname)
            f2py_flags.extend(sys.argv[i:i + 2])
            del sys.argv[i + 1], sys.argv[i]
            sources = sys.argv[1:]

    if '-m' in sys.argv:
        i = sys.argv.index('-m')
        modulename = sys.argv[i + 1]
        del sys.argv[i + 1], sys.argv[i]
        sources = sys.argv[1:]
    else:
        from numpy.distutils.command.build_src import get_f2py_modulename
        pyf_files, sources = filter_files('', '[.]pyf([.]src|)', sources)
        sources = pyf_files + sources
        for f in pyf_files:
            modulename = get_f2py_modulename(f)
            if modulename:
                break

    extra_objects, sources = filter_files('', '[.](o|a|so)', sources)
    include_dirs, sources = filter_files('-I', '', sources, remove_prefix=1)
    library_dirs, sources = filter_files('-L', '', sources, remove_prefix=1)
    libraries, sources = filter_files('-l', '', sources, remove_prefix=1)
    undef_macros, sources = filter_files('-U', '', sources, remove_prefix=1)
    define_macros, sources = filter_files('-D', '', sources, remove_prefix=1)
    for i in range(len(define_macros)):
        name_value = define_macros[i].split('=', 1)
        if len(name_value) == 1:
            name_value.append(None)
        if len(name_value) == 2:
            define_macros[i] = tuple(name_value)
        else:
            print('Invalid use of -D:', name_value)

    from numpy.distutils.system_info import get_info

    num_info = {}
    if num_info:
        include_dirs.extend(num_info.get('include_dirs', []))

    from numpy.distutils.core import setup, Extension
    ext_args = {'name': modulename, 'sources': sources,
                'include_dirs': include_dirs,
                'library_dirs': library_dirs,
                'libraries': libraries,
                'define_macros': define_macros,
                'undef_macros': undef_macros,
                'extra_objects': extra_objects,
                'f2py_options': f2py_flags,
                }

    if sysinfo_flags:
        from numpy.distutils.misc_util import dict_append
        for n in sysinfo_flags:
            i = get_info(n)
            if not i:
                outmess('No %s resources found in system'
                        ' (try `f2py --help-link`)\n' % (repr(n)))
            dict_append(ext_args, **i)

    ext = Extension(**ext_args)
    sys.argv = [sys.argv[0]] + setup_flags
    sys.argv.extend(['build',
                     '--build-temp', build_dir,
                     '--build-base', build_dir,
                     '--build-platlib', '.'])
    if fc_flags:
        sys.argv.extend(['config_fc'] + fc_flags)
    if flib_flags:
        sys.argv.extend(['build_ext'] + flib_flags)

    setup(ext_modules=[ext])

    if remove_build_dir and os.path.exists(build_dir):
        import shutil
        outmess('Removing build directory %s\n' % (build_dir))
        shutil.rmtree(build_dir)
Exemplo n.º 3
0
def run_compile():
    """
    Do it all in one call!
    """
    import tempfile

    i = sys.argv.index("-c")
    del sys.argv[i]

    remove_build_dir = 0
    try:
        i = sys.argv.index("--build-dir")
    except ValueError:
        i = None
    if i is not None:
        build_dir = sys.argv[i + 1]
        del sys.argv[i + 1]
        del sys.argv[i]
    else:
        remove_build_dir = 1
        build_dir = os.path.join(tempfile.mktemp())

    sysinfo_flags = filter(re.compile(r"[-][-]link[-]").match, sys.argv[1:])
    sys.argv = filter(lambda a, flags=sysinfo_flags: a not in flags, sys.argv)
    if sysinfo_flags:
        sysinfo_flags = [f[7:] for f in sysinfo_flags]

    f2py_flags = filter(
        re.compile(r"[-][-]((no[-]|)(wrap[-]functions|lower)|debug[-]capi|quiet)|[-]include").match, sys.argv[1:]
    )
    sys.argv = filter(lambda a, flags=f2py_flags: a not in flags, sys.argv)
    f2py_flags2 = []
    fl = 0
    for a in sys.argv[1:]:
        if a in ["only:", "skip:"]:
            fl = 1
        elif a == ":":
            fl = 0
        if fl or a == ":":
            f2py_flags2.append(a)
    if f2py_flags2 and f2py_flags2[-1] != ":":
        f2py_flags2.append(":")
    f2py_flags.extend(f2py_flags2)

    sys.argv = filter(lambda a, flags=f2py_flags2: a not in flags, sys.argv)

    flib_flags = filter(re.compile(r"[-][-]((f(90)?compiler([-]exec|)|compiler)=|help[-]compiler)").match, sys.argv[1:])
    sys.argv = filter(lambda a, flags=flib_flags: a not in flags, sys.argv)
    fc_flags = filter(
        re.compile(r"[-][-]((f(77|90)(flags|exec)|opt|arch)=|(debug|noopt|noarch|help[-]fcompiler))").match,
        sys.argv[1:],
    )
    sys.argv = filter(lambda a, flags=fc_flags: a not in flags, sys.argv)

    if 1:
        del_list = []
        for s in flib_flags:
            v = "--fcompiler="
            if s[: len(v)] == v:
                from numpy.distutils import fcompiler

                fcompiler.load_all_fcompiler_classes()
                allowed_keys = fcompiler.fcompiler_class.keys()
                nv = ov = s[len(v) :].lower()
                if ov not in allowed_keys:
                    vmap = {}  # XXX
                    try:
                        nv = vmap[ov]
                    except KeyError:
                        if ov not in vmap.values():
                            print 'Unknown vendor: "%s"' % (s[len(v) :])
                    nv = ov
                i = flib_flags.index(s)
                flib_flags[i] = "--fcompiler=" + nv
                continue
        for s in del_list:
            i = flib_flags.index(s)
            del flib_flags[i]
        assert len(flib_flags) <= 2, ` flib_flags `
    setup_flags = filter(re.compile(r"[-][-](verbose)").match, sys.argv[1:])
    sys.argv = filter(lambda a, flags=setup_flags: a not in flags, sys.argv)
    if "--quiet" in f2py_flags:
        setup_flags.append("--quiet")

    modulename = "untitled"
    sources = sys.argv[1:]
    if "-m" in sys.argv:
        i = sys.argv.index("-m")
        modulename = sys.argv[i + 1]
        del sys.argv[i + 1], sys.argv[i]
        sources = sys.argv[1:]
    else:
        from numpy.distutils.command.build_src import get_f2py_modulename

        pyf_files, sources = filter_files("", "[.]pyf([.]src|)", sources)
        sources = pyf_files + sources
        for f in pyf_files:
            modulename = get_f2py_modulename(f)
            if modulename:
                break

    extra_objects, sources = filter_files("", "[.](o|a|so)", sources)
    include_dirs, sources = filter_files("-I", "", sources, remove_prefix=1)
    library_dirs, sources = filter_files("-L", "", sources, remove_prefix=1)
    libraries, sources = filter_files("-l", "", sources, remove_prefix=1)
    undef_macros, sources = filter_files("-U", "", sources, remove_prefix=1)
    define_macros, sources = filter_files("-D", "", sources, remove_prefix=1)
    using_numarray = 0
    using_numeric = 0
    for i in range(len(define_macros)):
        name_value = define_macros[i].split("=", 1)
        if len(name_value) == 1:
            name_value.append(None)
        if len(name_value) == 2:
            define_macros[i] = tuple(name_value)
        else:
            print "Invalid use of -D:", name_value

    from numpy.distutils.system_info import get_info

    num_include_dir = None
    num_info = {}
    # import numpy
    # n = 'numpy'
    # p = get_prefix(numpy)
    # from numpy.distutils.misc_util import get_numpy_include_dirs
    # num_info = {'include_dirs': get_numpy_include_dirs()}

    if num_info:
        include_dirs.extend(num_info.get("include_dirs", []))

    from numpy.distutils.core import setup, Extension

    ext_args = {
        "name": modulename,
        "sources": sources,
        "include_dirs": include_dirs,
        "library_dirs": library_dirs,
        "libraries": libraries,
        "define_macros": define_macros,
        "undef_macros": undef_macros,
        "extra_objects": extra_objects,
        "f2py_options": f2py_flags,
    }

    if sysinfo_flags:
        from numpy.distutils.misc_util import dict_append

        for n in sysinfo_flags:
            i = get_info(n)
            if not i:
                outmess("No %s resources found in system" " (try `f2py --help-link`)\n" % (` n `))
            dict_append(ext_args, **i)

    ext = Extension(**ext_args)
    sys.argv = [sys.argv[0]] + setup_flags
    sys.argv.extend(["build", "--build-temp", build_dir, "--build-base", build_dir, "--build-platlib", "."])
    if fc_flags:
        sys.argv.extend(["config_fc"] + fc_flags)
    if flib_flags:
        sys.argv.extend(["build_ext"] + flib_flags)

    setup(ext_modules=[ext])

    if remove_build_dir and os.path.exists(build_dir):
        import shutil

        outmess("Removing build directory %s\n" % (build_dir))
        shutil.rmtree(build_dir)
Exemplo n.º 4
0
def run_compile():
    """
    Do it all in one call!
    """
    import tempfile

    i = sys.argv.index('-c')
    del sys.argv[i]

    remove_build_dir = 0
    try: i = sys.argv.index('--build-dir')
    except ValueError: i=None
    if i is not None:
        build_dir = sys.argv[i+1]
        del sys.argv[i+1]
        del sys.argv[i]
    else:
        remove_build_dir = 1
        build_dir = tempfile.mkdtemp()

    _reg1 = re.compile(r'[-][-]link[-]')
    sysinfo_flags = [_m for _m in sys.argv[1:] if _reg1.match(_m)]
    sys.argv = [_m for _m in sys.argv if _m not in sysinfo_flags]
    if sysinfo_flags:
        sysinfo_flags = [f[7:] for f in sysinfo_flags]

    _reg2 = re.compile(r'[-][-]((no[-]|)(wrap[-]functions|lower)|debug[-]capi|quiet)|[-]include')
    f2py_flags = [_m for _m in sys.argv[1:] if _reg2.match(_m)]
    sys.argv = [_m for _m in sys.argv if _m not in f2py_flags]
    f2py_flags2 = []
    fl = 0
    for a in sys.argv[1:]:
        if a in ['only:', 'skip:']:
            fl = 1
        elif a==':':
            fl = 0
        if fl or a==':':
            f2py_flags2.append(a)
    if f2py_flags2 and f2py_flags2[-1]!=':':
        f2py_flags2.append(':')
    f2py_flags.extend(f2py_flags2)

    sys.argv = [_m for _m in sys.argv if _m not in f2py_flags2]
    _reg3 = re.compile(r'[-][-]((f(90)?compiler([-]exec|)|compiler)=|help[-]compiler)')
    flib_flags = [_m for _m in sys.argv[1:] if _reg3.match(_m)]
    sys.argv = [_m for _m in sys.argv if _m not in flib_flags]
    _reg4 = re.compile(r'[-][-]((f(77|90)(flags|exec)|opt|arch)=|(debug|noopt|noarch|help[-]fcompiler))')
    fc_flags = [_m for _m in sys.argv[1:] if _reg4.match(_m)]
    sys.argv = [_m for _m in sys.argv if _m not in fc_flags]

    if 1:
        del_list = []
        for s in flib_flags:
            v = '--fcompiler='
            if s[:len(v)]==v:
                from numpy.distutils import fcompiler
                fcompiler.load_all_fcompiler_classes()
                allowed_keys = list(fcompiler.fcompiler_class.keys())
                nv = ov = s[len(v):].lower()
                if ov not in allowed_keys:
                    vmap = {} # XXX
                    try:
                        nv = vmap[ov]
                    except KeyError:
                        if ov not in vmap.values():
                            print('Unknown vendor: "%s"' % (s[len(v):]))
                    nv = ov
                i = flib_flags.index(s)
                flib_flags[i] = '--fcompiler=' + nv
                continue
        for s in del_list:
            i = flib_flags.index(s)
            del flib_flags[i]
        assert len(flib_flags)<=2, repr(flib_flags)

    _reg5 = re.compile(r'[-][-](verbose)')
    setup_flags = [_m for _m in sys.argv[1:] if _reg5.match(_m)]
    sys.argv = [_m for _m in sys.argv if _m not in setup_flags]

    if '--quiet' in f2py_flags:
        setup_flags.append('--quiet')

    modulename = 'untitled'
    sources = sys.argv[1:]

    for optname in ['--include_paths', '--include-paths']:
        if optname in sys.argv:
            i = sys.argv.index (optname)
            f2py_flags.extend (sys.argv[i:i+2])
            del sys.argv[i+1], sys.argv[i]
            sources = sys.argv[1:]

    if '-m' in sys.argv:
        i = sys.argv.index('-m')
        modulename = sys.argv[i+1]
        del sys.argv[i+1], sys.argv[i]
        sources = sys.argv[1:]
    else:
        from numpy.distutils.command.build_src import get_f2py_modulename
        pyf_files, sources = filter_files('', '[.]pyf([.]src|)', sources)
        sources = pyf_files + sources
        for f in pyf_files:
            modulename = get_f2py_modulename(f)
            if modulename:
                break

    extra_objects, sources = filter_files('', '[.](o|a|so)', sources)
    include_dirs, sources = filter_files('-I', '', sources, remove_prefix=1)
    library_dirs, sources = filter_files('-L', '', sources, remove_prefix=1)
    libraries, sources = filter_files('-l', '', sources, remove_prefix=1)
    undef_macros, sources = filter_files('-U', '', sources, remove_prefix=1)
    define_macros, sources = filter_files('-D', '', sources, remove_prefix=1)
    using_numarray = 0
    using_numeric = 0
    for i in range(len(define_macros)):
        name_value = define_macros[i].split('=', 1)
        if len(name_value)==1:
            name_value.append(None)
        if len(name_value)==2:
            define_macros[i] = tuple(name_value)
        else:
            print('Invalid use of -D:', name_value)

    from numpy.distutils.system_info import get_info

    num_include_dir = None
    num_info = {}
    #import numpy
    #n = 'numpy'
    #p = get_prefix(numpy)
    #from numpy.distutils.misc_util import get_numpy_include_dirs
    #num_info = {'include_dirs': get_numpy_include_dirs()}

    if num_info:
        include_dirs.extend(num_info.get('include_dirs', []))

    from numpy.distutils.core import setup, Extension
    ext_args = {'name': modulename, 'sources': sources,
                'include_dirs': include_dirs,
                'library_dirs': library_dirs,
                'libraries': libraries,
                'define_macros': define_macros,
                'undef_macros': undef_macros,
                'extra_objects': extra_objects,
                'f2py_options': f2py_flags,
                }

    if sysinfo_flags:
        from numpy.distutils.misc_util import dict_append
        for n in sysinfo_flags:
            i = get_info(n)
            if not i:
                outmess('No %s resources found in system'\
                        ' (try `f2py --help-link`)\n' % (repr(n)))
            dict_append(ext_args,**i)

    ext = Extension(**ext_args)
    sys.argv = [sys.argv[0]] + setup_flags
    sys.argv.extend(['build',
                     '--build-temp', build_dir,
                     '--build-base', build_dir,
                     '--build-platlib', '.'])
    if fc_flags:
        sys.argv.extend(['config_fc']+fc_flags)
    if flib_flags:
        sys.argv.extend(['build_ext']+flib_flags)

    setup(ext_modules = [ext])

    if remove_build_dir and os.path.exists(build_dir):
        import shutil
        outmess('Removing build directory %s\n'%(build_dir))
        shutil.rmtree(build_dir)
Exemplo n.º 5
0
def run_compile():
    """
    Do it all in one call!
    """
    import tempfile

    i = sys.argv.index("-c")
    del sys.argv[i]

    remove_build_dir = 0
    try:
        i = sys.argv.index("--build-dir")
    except ValueError:
        i = None
    if i is not None:
        build_dir = sys.argv[i + 1]
        del sys.argv[i + 1]
        del sys.argv[i]
    else:
        remove_build_dir = 1
        build_dir = tempfile.mkdtemp()

    _reg1 = re.compile(r"[-][-]link[-]")
    sysinfo_flags = [_m for _m in sys.argv[1:] if _reg1.match(_m)]
    sys.argv = [_m for _m in sys.argv if _m not in sysinfo_flags]
    if sysinfo_flags:
        sysinfo_flags = [f[7:] for f in sysinfo_flags]

    _reg2 = re.compile(
        r"[-][-]((no[-]|)(wrap[-]functions|lower)|debug[-]capi|quiet)|[-]include"
    )
    f2py_flags = [_m for _m in sys.argv[1:] if _reg2.match(_m)]
    sys.argv = [_m for _m in sys.argv if _m not in f2py_flags]
    f2py_flags2 = []
    fl = 0
    for a in sys.argv[1:]:
        if a in ["only:", "skip:"]:
            fl = 1
        elif a == ":":
            fl = 0
        if fl or a == ":":
            f2py_flags2.append(a)
    if f2py_flags2 and f2py_flags2[-1] != ":":
        f2py_flags2.append(":")
    f2py_flags.extend(f2py_flags2)

    sys.argv = [_m for _m in sys.argv if _m not in f2py_flags2]
    _reg3 = re.compile(
        r"[-][-]((f(90)?compiler([-]exec|)|compiler)=|help[-]compiler)")
    flib_flags = [_m for _m in sys.argv[1:] if _reg3.match(_m)]
    sys.argv = [_m for _m in sys.argv if _m not in flib_flags]
    _reg4 = re.compile(
        r"[-][-]((f(77|90)(flags|exec)|opt|arch)=|(debug|noopt|noarch|help[-]fcompiler))"
    )
    fc_flags = [_m for _m in sys.argv[1:] if _reg4.match(_m)]
    sys.argv = [_m for _m in sys.argv if _m not in fc_flags]

    if 1:
        del_list = []
        for s in flib_flags:
            v = "--fcompiler="
            if s[:len(v)] == v:
                from numpy.distutils import fcompiler

                fcompiler.load_all_fcompiler_classes()
                allowed_keys = list(fcompiler.fcompiler_class.keys())
                nv = ov = s[len(v):].lower()
                if ov not in allowed_keys:
                    vmap = {}  # XXX
                    try:
                        nv = vmap[ov]
                    except KeyError:
                        if ov not in vmap.values():
                            print('Unknown vendor: "%s"' % (s[len(v):]))
                    nv = ov
                i = flib_flags.index(s)
                flib_flags[i] = "--fcompiler=" + nv
                continue
        for s in del_list:
            i = flib_flags.index(s)
            del flib_flags[i]
        assert len(flib_flags) <= 2, repr(flib_flags)

    _reg5 = re.compile(r"[-][-](verbose)")
    setup_flags = [_m for _m in sys.argv[1:] if _reg5.match(_m)]
    sys.argv = [_m for _m in sys.argv if _m not in setup_flags]

    if "--quiet" in f2py_flags:
        setup_flags.append("--quiet")

    modulename = "untitled"
    sources = sys.argv[1:]

    for optname in ["--include_paths", "--include-paths"]:
        if optname in sys.argv:
            i = sys.argv.index(optname)
            f2py_flags.extend(sys.argv[i:i + 2])
            del sys.argv[i + 1], sys.argv[i]
            sources = sys.argv[1:]

    if "-m" in sys.argv:
        i = sys.argv.index("-m")
        modulename = sys.argv[i + 1]
        del sys.argv[i + 1], sys.argv[i]
        sources = sys.argv[1:]
    else:
        from numpy.distutils.command.build_src import get_f2py_modulename

        pyf_files, sources = filter_files("", "[.]pyf([.]src|)", sources)
        sources = pyf_files + sources
        for f in pyf_files:
            modulename = get_f2py_modulename(f)
            if modulename:
                break

    extra_objects, sources = filter_files("", "[.](o|a|so)", sources)
    include_dirs, sources = filter_files("-I", "", sources, remove_prefix=1)
    library_dirs, sources = filter_files("-L", "", sources, remove_prefix=1)
    libraries, sources = filter_files("-l", "", sources, remove_prefix=1)
    undef_macros, sources = filter_files("-U", "", sources, remove_prefix=1)
    define_macros, sources = filter_files("-D", "", sources, remove_prefix=1)
    for i in range(len(define_macros)):
        name_value = define_macros[i].split("=", 1)
        if len(name_value) == 1:
            name_value.append(None)
        if len(name_value) == 2:
            define_macros[i] = tuple(name_value)
        else:
            print("Invalid use of -D:", name_value)

    from numpy.distutils.system_info import get_info

    num_info = {}
    if num_info:
        include_dirs.extend(num_info.get("include_dirs", []))

    from numpy.distutils.core import setup, Extension

    ext_args = {
        "name": modulename,
        "sources": sources,
        "include_dirs": include_dirs,
        "library_dirs": library_dirs,
        "libraries": libraries,
        "define_macros": define_macros,
        "undef_macros": undef_macros,
        "extra_objects": extra_objects,
        "f2py_options": f2py_flags,
    }

    if sysinfo_flags:
        from numpy.distutils.misc_util import dict_append

        for n in sysinfo_flags:
            i = get_info(n)
            if not i:
                outmess(
                    "No %s resources found in system (try `f2py --help-link`)\n"
                    % (repr(n)))
            dict_append(ext_args, **i)

    ext = Extension(**ext_args)
    sys.argv = [sys.argv[0]] + setup_flags
    sys.argv.extend([
        "build",
        "--build-temp",
        build_dir,
        "--build-base",
        build_dir,
        "--build-platlib",
        ".",
    ])
    if fc_flags:
        sys.argv.extend(["config_fc"] + fc_flags)
    if flib_flags:
        sys.argv.extend(["build_ext"] + flib_flags)

    setup(ext_modules=[ext])

    if remove_build_dir and os.path.exists(build_dir):
        import shutil

        outmess("Removing build directory %s\n" % (build_dir))
        shutil.rmtree(build_dir)
Exemplo n.º 6
0
  description = "Intel Fortran Cross-Compiler for 64-bit MIC"

  executables = {
    'version_cmd'  : None,          # set by update_executables
    'compiler_f77' : [None, "-72"],
    'compiler_f90' : [None],
    'compiler_fix' : [None, "-FI"],
    'linker_so'    : ["<F90>", "-shared"],
    'archiver'     : ["ar", "-cr"],
    'ranlib'       : ["ranlib"]
    }

  def get_flags(self):
    # for Intel Fortran, -fp-model source is the same as precise without a compiler warning
    return ["-fPIC -shared -mmic -mkl -fp-model strict -g " + xcdirflags]

  def get_flags_linker_so(self):
    return self.get_flags()

  def get_flags_opt(self):
    return ['']

  def get_version(self):
    return "TODO"

fcompiler.load_all_fcompiler_classes()
# print fcompiler.fcompiler_class # {name: (name, klass, desc), ...}
fcompiler.fcompiler_class['intelmic'] = ('intelmic', IntelMICFCompiler, IntelMICFCompiler.description)

setup.setup_package()
Exemplo n.º 7
0
                return opt

        class Gnu95FCompilerHack(_gnu.Gnu95FCompiler):
            def get_library_dirs(self):
                try:
                    opt = super(Gnu95FCompilerHack, self).get_library_dirs()
                except TypeError:
                    # old distutils use old-style classes
                    opt = _gnu.Gnu95FCompiler.get_library_dirs(self)
                if sys.platform[:5] == 'linux' or sys.platform == 'darwin':
                    libgfortran_dir = _get_libgfortran_dir(self.compiler_f77)
                    if libgfortran_dir:
                        opt.append(libgfortran_dir)
                    return opt

        _fcompiler.load_all_fcompiler_classes()
        _fcompiler.fcompiler_class['gnu'] = ('gnu', GnuFCompilerHack,
                                             'GNU Fortran 77 compile Hack')
        _fcompiler.fcompiler_class['gnu95'] = ('gnu', Gnu95FCompilerHack,
                                               'GNU Fortran 95 compile Hack')

    # ok, now that that hack is over with, add our fortran extensions
    for d in fort_defs:
        if d is None:
            continue
        src_lst = d[1]
        ext_mods += [
            npExtension(d[0],
                        src_lst,
                        extra_compile_args=fort_fcflags,
                        extra_link_args=fort_ldflags,
Exemplo n.º 8
0
Arquivo: main.py Projeto: certik/fwrap
def allowed_fcompilers():
    from numpy.distutils import fcompiler
    fcompiler.load_all_fcompiler_classes()
    return fcompiler.fcompiler_class.keys()