File size: 496 Bytes
814bf6c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | import ctypes
import importlib.util
import sys
from pathlib import Path
def _import_from_path(file_path: Path):
path_hash = '{:x}'.format(ctypes.c_size_t(hash(file_path.absolute())).value)
spec = importlib.util.spec_from_file_location(path_hash, file_path)
module = importlib.util.module_from_spec(spec)
sys.modules[path_hash] = module
spec.loader.exec_module(module)
return module
globals().update(vars(_import_from_path(Path(__file__).parent.parent / '__init__.py')))
|