mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 11:11:08 +00:00
debug-viewer: Fix plugin loading machinery
The previous code was failing at least with Python 3.11 and Python 3.12. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6659>
This commit is contained in:
parent
a2254a4968
commit
83b1feb4f8
1 changed files with 3 additions and 7 deletions
|
@ -41,22 +41,18 @@ def _load_plugins(path):
|
|||
import glob
|
||||
|
||||
files = glob.glob(os.path.join(path, "*.py"))
|
||||
|
||||
for filename in files:
|
||||
|
||||
name = os.path.basename(os.path.splitext(filename)[0])
|
||||
if name == "__init__":
|
||||
continue
|
||||
|
||||
finder = importlib.machinery.PathFinder()
|
||||
spec = finder.find_spec(
|
||||
name,
|
||||
os.environ.get('_GI_OVERRIDES_PATH', '').split(os.pathsep)
|
||||
)
|
||||
loader = importlib.machinery.SourceFileLoader(name, filename)
|
||||
spec = importlib.util.spec_from_file_location(name, filename, loader=loader)
|
||||
if spec is None:
|
||||
raise ModuleNotFoundError(name)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
|
||||
loader.exec_module(module)
|
||||
yield module
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue