A blog about technical art, particularly Maya, Python, and Unity. With lots of obscurantist references

We've Moved

The blog has been retired - it's up for legacy reasons, but these days I'm blogging atblog.theodox.com. All of the content from this site has been replicated there, and that's where all of the new content will be posted. The new feed is here . I'm experimenting with crossposting from the live site, but if you want to keep up to date use blog.theodox.com or just theodox.com

Thursday, February 18, 2016

The little things

It’s the little things that really matter in life.

If you’ve ever spent any time wrestling with Maya distribution, you’ve probably noticed that userSetup.py executes in an odd fashion: it’s not a module that gets imported, it’s basically a series of statements that get executed when Maya fires up. Unfortunately that also means that most of the usual strategies you’d use in python to find out where, exactly, you are running from is problematic. The usual python tricks like __file__ don’t work; and most of the time asking for os.getcwd() will point at your Maya program directory. Usually you end up running around looking at all the directories where Maya might be stashing a userSetup and trying to figure out which one is the one you are in`. It’s ugly.
However today, I actually found one which works. At least, I haven’t figured out how to break it yet.

Since I’ve tried to figure this one out on at least a hundred previous occasions, I am feeling unduly smug about this one.
PS, if you’re wondering why I care: this makes it really easy to do a simple install/uninstall of a userSetup.py / userSetup.zip combo with no environment variables or special rules.
PPS: Take that, Maya!

About Me

I fell in love with computer animation in the Dark Ages, in more ways than one: I dropped out of a Ph.D. program in ancient history to start rendering 3D scenes on the Brown University mainframe back in the wee early 1990's. I went pro in 1993, doing animations for a variety of commercial and television projects.

My first game job was building mechs and environments for FASA's MechCommander in 1995.