Exemplo n.º 1
0
def extension(name):
    """Return setuptools Extension."""
    opt = EXTENSIONS[name]
    ext = Extension(
        f'imagecodecs._{name}',
        sources=[f'imagecodecs/_{name}' + EXT] + opt['sources'],
        **{
            key: (OPTIONS[key] + opt[key])
            for key in (
                'include_dirs',
                'library_dirs',
                'libraries',
                'define_macros',
                'extra_compile_args',
                'extra_link_args',
            )
        },
    )
    ext.cython_compile_time_env = {
        **OPTIONS['cython_compile_time_env'],
        **opt['cython_compile_time_env'],
    }
    # ext.force = OPTIONS['cythonize'] or opt['cythonize']
    return ext
Exemplo n.º 2
0
if "--inplace" in sys.argv:
    extra_linker_flags.append("-Wl,-rpath,.")  # Added to make test code work

if use_cython:
    pydarknet_extension = Extension(
        "pydarknet", ["pydarknet.pyx", "pydarknet.pxd", "bridge.cpp"],
        include_dirs=include_paths,
        language="c++",
        libraries=libraries,
        library_dirs=library_paths,
        extra_link_args=extra_linker_flags,
        extra_compile_args=extra_compiler_flags,
        define_macros=macros)

    # Pass macros to Cython
    pydarknet_extension.cython_compile_time_env = cython_compile_directives
else:
    pydarknet_extension = Extension("pydarknet",
                                    ["pydarknet.cpp", "bridge.cpp"],
                                    include_dirs=include_paths,
                                    language="c++",
                                    libraries=libraries,
                                    library_dirs=library_paths,
                                    extra_link_args=extra_linker_flags,
                                    extra_compile_args=extra_compiler_flags,
                                    define_macros=macros)

    # NOTE: It is assumed that pydarknet.cpp is already generated using pydarknet.py. It is also assumed that USE_CV
    # flag is unchanged between cythonize and current compilation.

ext_modules = [pydarknet_extension]