2015-04-24 08:35:14 +00:00
|
|
|
import os
|
2018-10-30 23:41:31 +00:00
|
|
|
import sys
|
2024-01-04 13:43:20 +00:00
|
|
|
import importlib
|
2015-04-15 17:57:43 +00:00
|
|
|
|
2024-01-04 12:44:57 +00:00
|
|
|
|
2018-10-30 23:41:31 +00:00
|
|
|
class GstOverrideImport:
|
2024-01-04 13:43:20 +00:00
|
|
|
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
|
2016-11-03 14:49:15 +00:00
|
|
|
|
2018-10-31 16:02:24 +00:00
|
|
|
|
2024-01-04 12:44:57 +00:00
|
|
|
sys.meta_path.insert(0, GstOverrideImport())
|