Drop old module loading from abspath cruft

try_trip^2
Tyler Goodlet 2020-01-31 12:04:46 -05:00
parent ee4b014092
commit 8264b7d136
1 changed files with 3 additions and 9 deletions

View File

@ -10,6 +10,7 @@ import inspect
import uuid import uuid
import typing import typing
from typing import Dict, List, Tuple, Any, Optional from typing import Dict, List, Tuple, Any, Optional
from types import ModuleType
import sys import sys
import os import os
@ -203,7 +204,7 @@ class Actor:
mods[name] = _get_mod_abspath(mod) mods[name] = _get_mod_abspath(mod)
self.rpc_module_paths = mods self.rpc_module_paths = mods
self._mods: dict = {} self._mods: Dict[str, ModuleType] = {}
# TODO: consider making this a dynamically defined # TODO: consider making this a dynamically defined
# @dataclass once we get py3.7 # @dataclass once we get py3.7
@ -268,15 +269,8 @@ class Actor:
# XXX append the allowed module to the python path which # XXX append the allowed module to the python path which
# should allow for relative (at least downward) imports. # should allow for relative (at least downward) imports.
sys.path.append(os.path.dirname(filepath)) sys.path.append(os.path.dirname(filepath))
# XXX leaving this in for now incase we decide to swap
# it with the above path mutating solution:
# spec = importlib.util.spec_from_file_location(
# modname, absfilepath)
# mod = importlib.util.module_from_spec(spec)
# spec.loader.exec_module(mod) # type: ignore
log.debug(f"Attempting to import {modpath}@{filepath}") log.debug(f"Attempting to import {modpath}@{filepath}")
mod = importlib.import_module(modpath) self._mods[modpath] = importlib.import_module(modpath)
self._mods[modpath] = mod
except ModuleNotFoundError: except ModuleNotFoundError:
# it is expected the corresponding `ModuleNotExposed` error # it is expected the corresponding `ModuleNotExposed` error
# will be raised later # will be raised later