userSetup.mel, userSetup.py Tutorial Part 2: Theory and Practical Use
For the Advanced user:
Delving into what how userSetup files work can be tedious. That’s why i’m posting how to configure Maya properly for those people who are perpetually scratching their heads, trying to figure out what way is better or why things aren’t working out like they planned. Check out my previous post on userSetup and see if you are pondering things after reading all of that. Of course, i’ve learned some things about the process too since then because my startup process is a lot more complicated than sourcing a couple of tools. I’m setting up whole programming environments! Learning Maya startup configuration has been a process of trial and error, searching and finding or sometimes not finding. Here’s the beef. Maya loads script paths in a specific order. Once you learn that order, the daunting task of setting configurations for a whole studio is as simple as pie. I work at a smaller studio, so the process of discovery falls on my shoulders and so I had to rise to the challenge.
Case Study: Finding the Solution to a Problem with userSetup.py
So where do you find the source code to decipher what’s really going on when Maya starts up? After finding this relic of a thread online, It crystallized one piece of the puzzle. I was having the hardest time figuring out why PYTHONPATH wasn’t working for all my scripts. After all, I was pointing it to find my userSetup.py and also my Maya2011 python\libs\site-packages directory so I can have access to all my downloaded modules yet my PyQt modules were failing to import while my userSetup modules were sourcing just fine.
Here's the order of how Maya finds scripts for python taken from the post linked above, which is directly from module: maya.app.startup.basic Per-version prefs scripts dir (eg .../maya8.5/prefs/scripts) Per-version scripts dir (eg .../maya8.5/scripts) User application dir (eg .../maya/scripts) Look for userSetup.py in the search path and execute it in the "__main__" namespace Set up sys.path to include Maya-specific user script directories. Set up auto-load stubs for Maya commands implemented in libraries which are not yet loaded Run the user's userSetup.py if it exists Register code to be run on exit