Let's say we have a project:
With a pipeline configuration:
A while ago we tried setting the PYTHONPATH to include the project's linked core python directory:
But then this happens when we try to initialize:
>>> import sgtk
>>> tk = sgtk.sgtk_from_path("/path/to/project")
tank.errors.TankError: Location metadata file '/path/to/project/sgtk/install/core/python/sgtk/config/core/install_location.yml' missing! Please contact support.
I thought this was some expected behaviour, but somehow the path is being compounded, and this seemed wrong.
I dug around and found that install/core/python/sgtk/__init__.py is a proxy and sets the environment variable TANK_CURRENT_PC before importing the "real" sgtk library. Removing this made it work, but I'm sure it's there for a reason.
Looking further I realised it sets TANK_CURRENT_PC to the "current_folder", which is:
This is not a pipeline configuration and that seems to be why it breaks (it is within one though). If instead we go up a few more levels we do get a pipeline configuration:
So I changed the code to strip those extra directories and it works!
I've attached a tk-core patch. To apply:
git am 0001-Fix-to-allow-inclusion-of-project-pipeline-configs-i.patch
Do you think this makes sense as a fix? Could it be incorporated into a core release? We'll keep the patch on hand locally anyway and continue using this to see if it introduces subtle problems, but so far it's going well.