What's the best way to include pip dependencies in a SGTK app/framework?

Hey there, I’m trying to build an app that is dependent on the USD pip package. What would be the best way to do this in the Shotgun Toolkit?

I was currently thinking about running a setuptools setup.py at the initialization of the framework/app, but I’m wondering what the best practice for this would be…

Many thanks in advance!

2 Likes

Hi,

When I have small dependencies, I try to embed them. It works if, theses dependencies doesn’t change too often and are not required between multiple apps (or I move them to a framework).
If I don’t want to embed them for any reason (binaries, frequent updates, module shared with non SGTK code), I pip install on the fly in a user folder ($HOME or %APPDATA% on windows).

1 Like

Shotgun doesn’t have any built-in mechanism for this. Some options you have are:

  • Install pip packages to a central repository
    You can install them to a central repository and simply add this repository in the app_launch hook. There’s a hook that runs before that with you need packages in tk-desktop. I’m away from the my workstation right now, but it’s something to do with the pipeline_configuration.

  • Install on the spot
    Similar to what you are doing. You can also do things like this.

  • Use a package manager.
    This is the more robust solution, but it requires some work. Rez is a very good one. You can integrate rez in Shotgun in a variety of ways. From calling shotgun from rez to using rez to launch your apps from tk-desktop.
    Using rez you can either make your own packages or use pipz to do it for you.

1 Like

I suppose Rez is suitable.
However, we have a separate system for machine set up (using Salt), which installs any needed libraries. This is pretty easy, because you can apply a whole set of installations and setup at once.
Specifically for tk apps it would be nice to manage dependencies via tk though, I agree. Perhaps something similar to how frameworks are specified.

1 Like

Thanks for answering! This is definitely an option I am considering, though I have read many posts online where they mention embedding packages is not the best practice per se, but if it works it works!

I like the package manager options! Seems like the most scalable one as well, but I will try the other options as well! Thanks for answering.

It would be nice to have a similar function as importing the frameworks from within the toolkit, but Salt also seems like a viable option! Thanks for answering mate.