From a09effd3a01cdfdab116b970dd23ab9f4bf5cefd Mon Sep 17 00:00:00 2001 From: Mark Reid Date: Mon, 29 Aug 2022 13:05:43 -0700 Subject: [PATCH] Load entrypoint plugins before builtin and contrib. Allows for overriding builtin plugins via entrypoint method. Signed-off-by: Mark Reid --- .../opentimelineio/plugins/manifest.py | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/py-opentimelineio/opentimelineio/plugins/manifest.py b/src/py-opentimelineio/opentimelineio/plugins/manifest.py index 6ef6e9bd1b..dc0803da58 100644 --- a/src/py-opentimelineio/opentimelineio/plugins/manifest.py +++ b/src/py-opentimelineio/opentimelineio/plugins/manifest.py @@ -202,10 +202,10 @@ def load_manifest(): The order of loading (and precedence) is: - 1. manifests specfied via the ``OTIO_PLUGIN_MANIFEST_PATH`` variable - 2. builtin plugin manifest - 3. contrib plugin manifest - 4. ``setuptools.pkg_resources`` based plugin manifests + 1. Manifests specified via the ``OTIO_PLUGIN_MANIFEST_PATH`` variable + 2. Entrypoint based plugin manifests + 3. Builtin plugin manifest + 4. Contrib plugin manifest """ result = Manifest() @@ -242,22 +242,6 @@ def load_manifest(): plugin_manifest = manifest_from_file(builtin_manifest_path) result.extend(plugin_manifest) - # the contrib plugin manifest (located in the opentimelineio_contrib package) - try: - import opentimelineio_contrib as otio_c - - contrib_manifest_path = os.path.join( - os.path.dirname(inspect.getsourcefile(otio_c)), - "adapters", - "contrib_adapters.plugin_manifest.json" - ) - if os.path.abspath(contrib_manifest_path) not in result.source_files: - contrib_manifest = manifest_from_file(contrib_manifest_path) - result.extend(contrib_manifest) - - except ImportError: - pass - # setuptools.pkg_resources based plugins if pkg_resources: for plugin in pkg_resources.iter_entry_points( @@ -324,6 +308,22 @@ def load_manifest(): # available? pass + # the contrib plugin manifest (located in the opentimelineio_contrib package) + try: + import opentimelineio_contrib as otio_c + + contrib_manifest_path = os.path.join( + os.path.dirname(inspect.getsourcefile(otio_c)), + "adapters", + "contrib_adapters.plugin_manifest.json" + ) + if os.path.abspath(contrib_manifest_path) not in result.source_files: + contrib_manifest = manifest_from_file(contrib_manifest_path) + result.extend(contrib_manifest) + + except ImportError: + pass + # force the schemadefs to load and add to schemadef module namespace for s in result.schemadefs: s.module()