Skip to content

Commit

Permalink
Fix test: tests/test_builtin_adapters.py
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanBldy committed Oct 10, 2023
1 parent dde9683 commit 64cf737
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/py-opentimelineio/opentimelineio/plugins/python_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import inspect
import collections
import copy
import importlib
import importlib.util

from .. import (
core,
Expand Down Expand Up @@ -107,7 +107,23 @@ def module_abs_path(self):
def _imported_module(self, namespace):
"""Load the module this plugin points at."""

return importlib.import_module(f"opentimelineio.{namespace}.{self.name}")
pyname = os.path.splitext(os.path.basename(self.module_abs_path()))[0]
pydir = os.path.dirname(self.module_abs_path())
module_name = f"opentimelineio.{namespace}.{self.name}"
try:
# Attempt to import the module using importlib first
mod = importlib.import_module(module_name)
except ImportError:
# If the module couldn't be imported, import it manually
spec = importlib.util.spec_from_file_location(
f"opentimelineio.{namespace}.{self.name}",
os.path.join(pydir, f"{pyname}.py"),
)

mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)

return mod

def module(self):
"""Return the module object for this adapter. """
Expand Down

0 comments on commit 64cf737

Please sign in to comment.