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')))