Maya 2019 userSetup.py

Hi, I just lost a day to this so I’m making a post to raise awareness :wink:

It looks like Maya 2019 calls userSetup.py earlier than it used to. I upgraded a few days ago and my toolset worked as usual, until at some point after closing and re-opening Maya my userSetup stopped running the studio menu and rollback importer.

The solution was to nest the imports from my studio tool-set and calls under a function to be called in cmds.evalDeferred([function], lowestPriority=True) and to store my menu and rollback variables under main

Has anyone else struggled with this?

def start():
    from sys_utils import mk_menu
    from sys_utils.rollbackImporter import RollbackImporter
    import __main__

    __main__.rollback = RollbackImporter()
    __main__.mkMenu = mk_menu.MKMenu()


cmds.evalDeferred(start, lp=True)

:smiling_face_with_three_hearts: Phoebe

Maya has always run userSetup.py well before the UI was available.
userSetup.mel is what gets run after the UI is up and running.

Yes I’ve always used evalDeferred to call my menu, but now userSetup is being called before PYTHONPATH is set by Maya.Env

That shouldn’t be the case.
PYTHONPATH is evaluated at interpreter startup, you can’t run a python file without that happening. In fact the logic to check for userSetup.py relies on parsing PYTHONPATH

I don’t have 2019 in front of me to check, but C:\Program Files\Autodesk\Maya2019\Python\lib\site-packages\maya\app\startup\basic.py is where the logic for when userSetup.py is evaluated should exist.

Question, which version of maya did you just update from?

All I know is if I don’t run my imports in deferred evaluation with lowest priority they won’t import, and if I don’t store my rollback under main manually I can’t access it after initialisation.

I’ve just updated from Maya 2018 to 2019.1

I think it’s a bug more than anything; userSetup was running fine as usual for a few days in 2019, then suddenly this happened. Maybe userSetup is supposed to be called after Maya.Env, but I can tell you that’s not what’s happening on my machine, or for anyone in my studio I’ve tested it with :frowning:

That is downright puzzling.
Looks like I need to get my hands on 2019

Are you by chance relying on module files at all to expand the environment lookup?

I haven’t decided if it’s worth upgrading the whole studio yet; the updates to the evaluation models are super awesome, but looks like a couple of under the hood edits that I’m not heaps happy with.

I’m not using module files :), well I am, but not to expand the environment lookup

Something that came up in the TAO slack, are you guys by chance using animBot?
Seems it has a habit of breaking PYTHONPATH.

Two of our animators use it but it’s not on the machines that were having the issue so far :slight_smile:
I have identified that in some cases with Maya 2019, UserSetup.py is running before Maya.Env so my studio tools aren’t able to be imported without deferred evaluation :slight_smile: :slight_smile:

Not one for doubling up, wanted to point to an early thread that might offer solutions: Python Maya startup script via @bob.w:

My gut is that PYTHONPATH is being set on Maya start up, but some higher priority tool, plugin, is overriding it prior to calling the userSetup.py. Can you attach a debugger to Maya and see what its calling on startup?