# Loading a custom framework when Shotgun Desktop loads a project?

**URL:** <https://community.shotgridsoftware.com/t/loading-a-custom-framework-when-shotgun-desktop-loads-a-project/8911>\
**Category:** Pipeline Integrations\
**Tags:** hooks, frameworks\
**Created:** [June 3, 2020, 6:13pm UTC](https://community.shotgridsoftware.com/t/loading-a-custom-framework-when-shotgun-desktop-loads-a-project/8911 "2020-06-03T18:13:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ricardo\_Musch](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/ricardo_musch/32/405_2.png) [@Ricardo\_Musch](https://community.shotgridsoftware.com/u/Ricardo_Musch)\
**Post date:** [June 3, 2020, 6:13pm UTC](https://community.shotgridsoftware.com/t/loading-a-custom-framework-when-shotgun-desktop-loads-a-project/8911/1 "2020-06-03T18:13:28Z")

</div>

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**

```auto
# 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**

```auto
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)**

```python
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!

---

<div class="post-metadata">

**Author:** ![Ricardo\_Musch](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/ricardo_musch/32/405_2.png) [@Ricardo\_Musch](https://community.shotgridsoftware.com/u/Ricardo_Musch)\
**Post date:** [June 9, 2020, 1:50pm UTC](https://community.shotgridsoftware.com/t/loading-a-custom-framework-when-shotgun-desktop-loads-a-project/8911/3 "2020-06-09T13:50:34Z")

</div>

Gentle bump 😬

---

<div class="post-metadata">

**Author:** ![philip.scadding](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/philip.scadding/32/30_2.png) [@philip.scadding](https://community.shotgridsoftware.com/u/philip.scadding)\
**Post date:** [June 9, 2020, 2:51pm UTC](https://community.shotgridsoftware.com/t/loading-a-custom-framework-when-shotgun-desktop-loads-a-project/8911/4 "2020-06-09T14:51:47Z")

</div>

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

> <https://github.com/shotgunsoftware/tk-config-default2/blob/master/env/project.yml#L59>

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

> [@How can I load a Toolkit framework in my hook?](https://community.shotgridsoftware.com/t/how-can-i-load-a-toolkit-framework-in-my-hook/115):
>
> [Toolkit frameworks](https://developer.shotgunsoftware.com/tk-core/platform.html#frameworks) can be useful for writing code that can be then reused in a number of different Apps or Engines. Normally if you are writing a custom App or Engine, you would import the framework using sgtk.platform.import\_framework(), and this requires that the App sets the framework as a dependency in the [app’s info.yml](https://github.com/shotgunsoftware/tk-multi-workfiles2/blob/3566876b4ec5c9afc7a8ae453f088fbd427a9794/info.yml#L253-L256). Frameworks in App hooks However, if you want to use a framework, in an App hook you can do so using the Hook class’s [load\_framework()](https://developer.shotgunsoftware.com/tk-core/core.html?highlight=load_framework#sgtk.Hook.load_framework). This method allows you to impo…

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