Tk-desktop "launch_python" hook implementation


I tried to implement the tk-desktop “launch_python” hook in my config,
where I put the hook information in the tk-desktop.yml like this:

# site
  hook_launch_python: "{config}/tk-desktop/"

# project
  hook_launch_python: "{config}/tk-desktop/"

but it does not seem to get executed at all.

When I have a look into the dev console,
it shows this line at some point:

[ DEBUG] : Resolved hook expression (associated with setting 'hook_launch_python'): '{self}/' -> ['C:\\Program Files\\Shotgun\\Resources\\Python\\bundle_cache\\app_store\\tk-desktop\\v2.4.12\\hooks\\']

Did I just implement it in a wrong way or what is happening here?
The custom in my config/hooks/tk-desktop is not being called unfortunately.
It would be nice to get some insight here,

thanks for the help,



Have you configured your hook on the site config or project config level?

The site wide one is normally updated automatically (pointing to tk-config-basic) and runs before the per-pipeline-config level.

There are some useful docs here about it

I think that in order for you to use the hook_launch_python you would need to take control of the site configuration and add the hook in there.

I’m looking into something like this at the moment too. Trying to avoid having to override the site config but it’s looking inevitable.


Hi, thanks for the infos!

It also looks like I had some serious cache problems with my config yesterday,
but now i got the launch_python working, at least for the py file configured in

It looks like that hook gets executed any time a project is chosen in sg desktop.
I will try to check out if thats enough for my purposes,
but just out of interest:

how could I override the site config as you described?
I think thats more what I need in my case right now

Thanks a lot!


Oh that’s interesting, maybe I was having similar caching issues. It would be really useful to be able to run that hook from the project level! I wasn’t changing the project, just the pipeline config within the project (maybe that makes a difference).

I think you can override the config using TK_BOOTSTRAP_CONFIG_OVERRIDE but I’ve never done it myself.

I’m looking at these docs

and I think the framework that handles it is tk-framework-desktopstartup so I’m looking here in the code

Again I haven’t tried it out, I’m planning to investigate it further as soon as I get a chance.


Yeah I was able to get the hook working by cleaning up my %appdata%/Shotgun and then
restart SG Desktop completely.
It kind of runs with some project/config information, at least it works for me now because it
directly resolves the python interpreter from the configs core .cfg file before running, so I can mess with it a bit :slight_smile:

Anyways, I will have a look into the tk-framework-desktopstartup because that seems pretty interesting for my purposes.



To override the site config, you just need to create a PipelineConfiguration entity on your Shotgun site with no Project assigned in the project field. You could download a copy of the tk-config-basic, make your changes and then upload the config to your PipelineConfiguration entity or use a descriptor to point to it.
A bit like this


Thanks @philip.scadding that is so much easier than what I was planning!


jep, thanks, that helps a lot!

1 Like