How to use the cppimport.import_hook.ImportCppExt function in cppimport

To help you get started, we’ve selected a few cppimport examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tbenthompson / cppimport / cppimport / import_hook.py View on Github external
use_existing_extension = not should_force_rebuild and \
        checksum_good and \
        os.path.exists(ext_path)

    if use_existing_extension:
        if not quiet:
            print("Matching checksum for " + filepath + " --> not compiling")
        return

    if not quiet:
        print("Compiling " + filepath)

    temp_filepath = setup_plugin(module_name, filepath, build_path)

    ext = ImportCppExt(
        dir_name,
        full_module_name,
        sources = [temp_filepath],
        language = 'c++',
        include_dirs = [
            pybind11.get_include(),
            pybind11.get_include(True)
        ],
        extra_compile_args = [
            '-std=c++11', '-Wall', '-Werror'
        ]
    )

    args = ['build_ext', '--inplace']
    args.append('--build-temp=' + build_path)
    args.append('--build-lib=' + build_path)