Fix up minor things with import hook
This commit is contained in:
@@ -1139,6 +1139,12 @@ class _Loader:
|
|||||||
def __init__(self, fullname, path, additional_paths):
|
def __init__(self, fullname, path, additional_paths):
|
||||||
self.fullname = fullname
|
self.fullname = fullname
|
||||||
self.path = path
|
self.path = path
|
||||||
|
|
||||||
|
# Add current directory of the capnp schema to search path
|
||||||
|
dir_name = _os.path.dirname(path)
|
||||||
|
if path is not '':
|
||||||
|
additional_paths = [dir_name] + additional_paths
|
||||||
|
|
||||||
self.additional_paths = additional_paths
|
self.additional_paths = additional_paths
|
||||||
|
|
||||||
def load_module(self, fullname):
|
def load_module(self, fullname):
|
||||||
@@ -1146,7 +1152,7 @@ class _Loader:
|
|||||||
"invalid module, expected %s, got %s" % (
|
"invalid module, expected %s, got %s" % (
|
||||||
self.fullname, fullname))
|
self.fullname, fullname))
|
||||||
|
|
||||||
imports = self.additional_paths + _sys.path
|
imports = self.additional_paths + _sys.path # TODO: change '' to '.' in sys.path
|
||||||
module = load(self.path, fullname, imports=imports)
|
module = load(self.path, fullname, imports=imports)
|
||||||
_sys.modules[fullname] = module
|
_sys.modules[fullname] = module
|
||||||
|
|
||||||
@@ -1169,7 +1175,7 @@ class _Importer:
|
|||||||
if not module_name.endswith('_capnp'):
|
if not module_name.endswith('_capnp'):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
module_name = module_name.rstrip('_capnp')
|
module_name = module_name[:-len('_capnp')]
|
||||||
capnp_module_name = module_name + self.extension
|
capnp_module_name = module_name + self.extension
|
||||||
|
|
||||||
if package_path:
|
if package_path:
|
||||||
|
|||||||
Reference in New Issue
Block a user