File: overrides_hack.py

package info (click to toggle)
gst-python1.0 1.26.2-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 968 kB
  • sloc: python: 7,964; ansic: 1,854; makefile: 33
file content (23 lines) | stat: -rw-r--r-- 709 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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())