diff --git a/src/addons/send2ue/__init__.py b/src/addons/send2ue/__init__.py index 51409004..4a0e2402 100644 --- a/src/addons/send2ue/__init__.py +++ b/src/addons/send2ue/__init__.py @@ -13,7 +13,7 @@ bl_info = { "name": "Send to Unreal", "author": "Epic Games Inc (now a community fork)", - "version": (2, 4, 8), + "version": (2, 4, 9), "blender": (3, 6, 0), "location": "Header > Pipeline > Send to Unreal", "description": "Sends an asset to the first open Unreal Editor instance on your machine.", diff --git a/src/addons/send2ue/blender_manifest.toml b/src/addons/send2ue/blender_manifest.toml index edc7ff6e..06f32258 100644 --- a/src/addons/send2ue/blender_manifest.toml +++ b/src/addons/send2ue/blender_manifest.toml @@ -2,7 +2,7 @@ schema_version = "1.0.0" id = "send2ue" name = "Send to Unreal" tagline = "Send assets directly to an open Unreal Editor on your machine" -version = "2.4.8" +version = "2.4.9" type = "add-on" tags = [ "Pipeline" ] blender_version_min = "4.2.0" diff --git a/src/addons/send2ue/core/extension.py b/src/addons/send2ue/core/extension.py index f8f20cb4..06899cea 100644 --- a/src/addons/send2ue/core/extension.py +++ b/src/addons/send2ue/core/extension.py @@ -4,7 +4,6 @@ import bpy import sys import ast -import importlib.util import tempfile from . import settings from abc import abstractmethod @@ -12,6 +11,8 @@ from . import utilities from .. import __package__ as base_package from pathlib import Path +from importlib.machinery import SourceFileLoader +from importlib.util import module_from_spec, spec_from_loader def run_extension_filters(armature_objects, mesh_objects, hair_objects): @@ -266,9 +267,9 @@ def __init__(self, file_path): super(ExtensionCollector, self).__init__() # Todo: Remove this when extensions don't need base classes - addons_folder = str(Path(__file__).parent.parent.parent) - if addons_folder not in sys.path: - sys.path.insert(0, addons_folder) + addons_folder = Path(__file__).parent.parent.parent + if addons_folder not in [Path(i) for i in sys.path]: + sys.path.insert(0, str(addons_folder)) self._extension_module = self.get_module(file_path) self._extension_classes = [] @@ -282,15 +283,10 @@ def get_module(file_path): """ Gets the module from the file path. """ - path = os.path.dirname(file_path) - name, file_extension = os.path.splitext(os.path.basename(file_path)) - if path not in sys.path: - sys.path.insert(0, path) - module = importlib.import_module(name) - importlib.reload(module) - - # remove to prevent root module naming conflicts - sys.path.remove(path) + name = f'send2ue_extension_{Path(file_path).name}' + spec = spec_from_loader(name, SourceFileLoader(name, str(file_path))) + module = module_from_spec(spec) # type: ignore + spec.loader.exec_module(module) # type: ignore return module def get_extension_classes(self): @@ -307,7 +303,7 @@ def visit_ClassDef(self, node): """ extension_class = getattr(self._extension_module, node.name) - if issubclass(extension_class, ExtensionBase): + if ExtensionBase.__name__ in [i.__name__ for i in extension_class.__bases__]: self._extension_classes.append(extension_class) diff --git a/src/addons/send2ue/dependencies/rpc/validations.py b/src/addons/send2ue/dependencies/rpc/validations.py index e4a95877..8dd7dc9e 100644 --- a/src/addons/send2ue/dependencies/rpc/validations.py +++ b/src/addons/send2ue/dependencies/rpc/validations.py @@ -16,8 +16,7 @@ def get_source_file_path(function): :param callable function: A callable. :return str: A file path. """ - client_module = inspect.getmodule(function) - return client_module.__file__ + return inspect.getsourcefile(function) def get_line_link(function):