Exemplo n.º 1
0
def pre_build_hook(build_ext, ext):
    from scipy._build_utils.compiler_helper import (
        get_cxx_std_flag, try_add_flag, try_compile, has_flag)
    cc = build_ext._cxx_compiler
    args = ext.extra_compile_args

    std_flag = get_cxx_std_flag(cc)
    if std_flag is not None:
        args.append(std_flag)

    if cc.compiler_type == 'msvc':
        args.append('/EHsc')
    else:
        # Use pthreads if available
        has_pthreads = try_compile(cc, code='#include <pthread.h>\n'
                                   'int main(int argc, char **argv) {}')
        if has_pthreads:
            ext.define_macros.append(('POCKETFFT_PTHREADS', None))
            if has_flag(cc, '-pthread'):
                args.append('-pthread')
                ext.extra_link_args.append('-pthread')
            else:
                raise RuntimeError("Build failed: System has pthreads header "
                                   "but could not compile with -pthread option")

        # Don't export library symbols
        try_add_flag(args, cc, '-fvisibility=hidden')
        # Set min macOS version
        min_macos_flag = '-mmacosx-version-min=10.9'
        import sys
        if sys.platform == 'darwin' and has_flag(cc, min_macos_flag):
            args.append(min_macos_flag)
            ext.extra_link_args.append(min_macos_flag)
Exemplo n.º 2
0
def pre_build_hook(build_ext, ext):
    from scipy._build_utils.compiler_helper import (
        get_cxx_std_flag, try_add_flag, try_compile, has_flag)
    cc = build_ext._cxx_compiler
    args = ext.extra_compile_args

    std_flag = get_cxx_std_flag(build_ext._cxx_compiler)
    if std_flag is not None:
        args.append(std_flag)

    if cc.compiler_type == 'msvc':
        args.append('/EHsc')
    else:
        try_add_flag(args, cc, '-fvisibility=hidden')

        has_pthreads = try_compile(cc, code='#include <pthread.h>\n'
                                   'int main(int argc, char **argv) {}')
        if has_pthreads:
            ext.define_macros.append(('POCKETFFT_PTHREADS', None))

        min_macos_flag = '-mmacosx-version-min=10.9'
        import sys
        if sys.platform == 'darwin' and has_flag(cc, min_macos_flag):
            args.append(min_macos_flag)
            ext.extra_link_args.append(min_macos_flag)
Exemplo n.º 3
0
def unuran_pre_build_hook(build_clib, build_info):
    from scipy._build_utils.compiler_helper import (get_c_std_flag,
                                                    try_compile, has_flag)
    c = build_clib.compiler
    c_flag = get_c_std_flag(c)
    if c_flag is not None:
        if "extra_compiler_args" not in build_info:
            build_info["extra_compiler_args"] = []
        build_info["extra_compiler_args"].append(c_flag)
    deps = {
        "unistd.h": ["HAVE_DECL_GETOPT", "HAVE_UNISTD_H"],
        "dlfcn.h": ["HAVE_DLFCN_H"],
        "sys/time.h":
        ["HAVE_GETTIMEOFDAY", "HAVE_SYS_TIME_H", "TIME_WITH_SYS_TIME"],
        "memory.h": ["HAVE_MEMORY_H"],
        "strings.h": ["HAVE_STRCASECMP", "HAVE_STRINGS_H"],
        "sys/stat.h": ["HAVE_SYS_STAT_H"],
        "sys/types.h": ["HAVE_SYS_TYPES_H"]
    }
    for dep in deps:
        has_dep = try_compile(c,
                              code=f"#include <{dep}>\n"
                              "int main(int argc, char **argv){}")
        if has_dep:
            for macro in deps[dep]:
                build_info["macros"].append((macro, "1"))
    if has_flag(c, flag="-lm"):
        try:
            build_info["libraries"].append("m")
        except KeyError:
            build_info["libraries"] = ["m"]
Exemplo n.º 4
0
def pre_build_hook(build_ext, ext):
    from scipy._build_utils.compiler_helper import (set_cxx_flags_hook,
                                                    try_add_flag, try_compile,
                                                    has_flag)
    cc = build_ext._cxx_compiler
    args = ext.extra_compile_args

    set_cxx_flags_hook(build_ext, ext)

    if cc.compiler_type == 'msvc':
        args.append('/EHsc')
    else:
        # Use pthreads if available
        has_pthreads = try_compile(cc,
                                   code='#include <pthread.h>\n'
                                   'int main(int argc, char **argv) {}')
        if has_pthreads:
            ext.define_macros.append(('POCKETFFT_PTHREADS', None))
            if has_flag(cc, '-pthread'):
                args.append('-pthread')
                ext.extra_link_args.append('-pthread')
            else:
                raise RuntimeError(
                    "Build failed: System has pthreads header "
                    "but could not compile with -pthread option")

        # Don't export library symbols
        try_add_flag(args, cc, '-fvisibility=hidden')
Exemplo n.º 5
0
def pre_build_hook(build_ext, ext):
    from scipy._build_utils.compiler_helper import (get_cxx_std_flag, has_flag,
                                                    try_add_flag)
    cc = build_ext._cxx_compiler
    args = ext.extra_compile_args

    std_flag = get_cxx_std_flag(cc)
    if std_flag is not None:
        args.append(std_flag)

    if cc.compiler_type == 'msvc':
        args.append('/EHsc')
    else:
        try_add_flag(args, cc, '-fvisibility=hidden')

        min_macos_flag = '-mmacosx-version-min=10.9'
        import sys
        if sys.platform == 'darwin' and has_flag(cc, min_macos_flag):
            args.append(min_macos_flag)
            ext.extra_link_args.append(min_macos_flag)