How to use the cppimport.find.find_module_cpppath 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 / tests / test_cppimport.py View on Github external
def test_find_module_cpppath():
    mymodule_loc = cppimport.find.find_module_cpppath("mymodule")
    mymodule_dir = os.path.dirname(mymodule_loc)
    assert(os.path.basename(mymodule_loc) == "mymodule.cpp")

    apackage = cppimport.find.find_module_cpppath("apackage.mymodule")
    apackage_correct = os.path.join(mymodule_dir, 'apackage', 'mymodule.cpp')
    assert(apackage == apackage_correct)

    inner = cppimport.find.find_module_cpppath("apackage.inner.mymodule")
    inner_correct = os.path.join(mymodule_dir, 'apackage', 'inner', 'mymodule.cpp')
    assert(inner == inner_correct)
github tbenthompson / cppimport / cppimport / importer.py View on Github external
def build(fullname):
    # Search through sys.path to find a file that matches the module
    filepath = cppimport.find.find_module_cpppath(fullname)
    module_data = setup_module_data(fullname, filepath)
    if not check_checksum(module_data):
        template_and_build(filepath, module_data)

    # Return the path to the built module
    return module_data['ext_path']