mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-29 05:01:23 +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/6678>
This commit is contained in:
parent
fda0442258
commit
ac835db179
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