mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-22 08:17:01 +00:00
7c68ef354b
The `imp` module got removed in python 3.12 and the `importlib` module should be used instead. This is also a good excuse to switch to the new finder module from PEP 451 : https://www.python.org/dev/peps/pep-0451/ This only requires implement the `find_spec()` method in our custom loaders Co-authored-by: Stefan <107316-stefan6419846@users.noreply.gitlab.freedesktop.org> Co-authored-by: Jordan Petrids <jordan@centricular.com> Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5633>
23 lines
709 B
Python
23 lines
709 B
Python
import os
|
|
import sys
|
|
import importlib
|
|
|
|
|
|
class GstOverrideImport:
|
|
def find_spec(self, fullname, path, target=None):
|
|
if not (fullname.startswith("gi.overrides.Gst") or fullname.startswith("gi.overrides._gi_gst")):
|
|
return None
|
|
finder = importlib.machinery.PathFinder()
|
|
# From find_spec the docs:
|
|
# If name is for a submodule (contains a dot), the parent module is automatically imported.
|
|
spec = finder.find_spec(
|
|
fullname,
|
|
[
|
|
os.environ.get('GST_OVERRIDE_SRC_PATH'),
|
|
os.environ.get('GST_OVERRIDE_BUILD_PATH'),
|
|
]
|
|
)
|
|
return spec
|
|
|
|
|
|
sys.meta_path.insert(0, GstOverrideImport())
|