Loading a custom framework when Shotgun Desktop loads a project?

I’ve got a custom framework which is a python library of convenience functions for our studio.
Ideally I would love to load this (add the library to the sys.path) when shotgun desktop loads up a project so the library files are available for import in anything launched from that SG desktop session.

However I currently don’t seem to get the framework loaded.

This is how I’ve got it setup:

tk-desktop.yml

# project
settings.tk-desktop.project:
  frameworks:
  - {"name": "lp-tk-framework-custom", "version": "v0.0.0"}
  apps:
    tk-multi-pythonconsole:
      location: "@apps.tk-multi-pythonconsole.location"
    tk-multi-devutils:
      location: "@apps.tk-multi-devutils.location"
    tk-multi-launchapp: "@settings.tk-multi-launchapp"

frameworks.yml

lp-tk-framework-custom:
  location:
    version: v0.0.0
    type: dev
    path: F:\some_path\lp-tk-framework-custom

framework.yml (inside the framework folder)

class CustomFramework(sgtk.platform.Framework):
    def init_framework(self):
        """
        Init this framework.
        """
        path = os.path.join(os.path.dirname(__file__), "python")
        sys.path.insert(0, path)
  • Ignore the weird formatting above, the code doesn’t always copy nicely into the forum editor!
4 Likes

Gentle bump :grimacing:

1 Like

Hey @Ricardo_Musch sorry this dropped off our radar.

As far as I know, the engine does not have a recognized frameworks section.
The engine or apps may require the frameworks in their info.yml files.

But if you have the framework defined in the environment files under the frameworks section


then you can import it in an app or engine hook.

Since the framework can’t be called from a core hook, I’m not sure if a framework approach will work for you here.

3 Likes