I’m beginning the process of building a pipeline from scratch. It’s a personal project, but ideally there would be a main tools site-package for things that every project will use, like modeling tools. In addition to that there would be another site-package that would be project specific. Each project will have one and they have the same structure as the global tools repository:
Global Tools
-ahtools
–maya
—animation
----animationtools.py
----modeling
------modelingtools.py
-----rigging
------riggingtools.py
–motionbuilder
—animation
----retargeting.py
ProjectA Tools
-ahtools
–maya
—animation
—modeling
—rigging
----riggingtools.py
----autorig.py
–motionbuilder
—animation
----retargeting.py
I left out all of the init.py files to keep things simple here.
Someone once told me that they were able to achieve this by adding both tools databases to sys.path on startup. They said that they just had to insert ProjectA Tools into sys.path before the Global Tools. The super awesome benefit to doing things this way is that python would look in ProjectA Tools for a module first, essentially overriding the one in the Global Tools database if it exists. If the module doesn’t exist in ProjectA Tools, like modelingtools.py for example, then the system would use the one in Global Tools, because its path is last in sys.path.
It sounds like a really smart way to structure a pipeline’s tools. This behavior reminds me of other non-destructive things like overriding methods in classes, or localizations.
The only problem is that I can’t get it to work with site-packages. I get an import error if the module being imported doesn’t exist in ProjectA Tools (animationtools.py for example). Has anyone used this design before? Were you able to solve this import error? Thanks!