Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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']