Great works! We do use the global userSetup.[mel,py] w/o loading local ones right now in concern of artist's mis-usage of userSetup. But I start to think about post-loading local startup scripts to ease TD's testing right now.
- Drake On Aug 7, 1:29 pm, chadrik <[email protected]> wrote: > > we have local userSetup run a global userSetupAll. This way we can > > have local functions run together with functions that are global for > > every one. > > we do something similar, but the other way around. we have a global > userSetup.py and userSetup.mel which call user's local userSetup.py > and userSetup.mel. > > there are a couple of things to keep in mind: only one > userSetup.py/.mel is executed per user, so make sure that the global > network path is before the user's local path in PYTHONPATH and > MAYA_SCRIPT_PATH, and make sure that maya isn't prepending any > unexpected values to these. > > userSetup.py is run very early in the load process, and based on your > symptoms, it might be running before Maya.env is parsed. i'm not > really sure because we have a tool for dynamically setting our > PYTHONPATH and MAYA_SCRIPT_PATH envs at the system level, prior to > Maya launching and we don't use Maya.env at all. this makes certain > that values are set in time. > > if you want to get even deeper into this, the really cool thing is you > can check out exactly where userSetup.py is being executed: it's in > your maya site-packages/maya/app/startup/basic.py: > > # module: maya.app.startup.basic > # > # This module is always imported during Maya's startup. It is > imported from > # both the maya.app.startup.batch and maya.app.startup.gui scripts > # > > import maya, maya.app, maya.app.commands > from maya import cmds, utils > import sys, os.path, atexit > > def setupScriptPaths(): > """ > Add Maya-specific directories to sys.path > """ > > # Per-version prefs scripts dir (eg .../maya8.5/prefs/scripts) > # > prefsDir = cmds.internalVar( userPrefDir=True ) > sys.path.append( os.path.join( prefsDir, 'scripts' ) ) > > # Per-version scripts dir (eg .../maya8.5/scripts) > # > scriptDir = cmds.internalVar( userScriptDir=True ) > sys.path.append( os.path.dirname(scriptDir) ) > > # User application dir (eg .../maya/scripts) > # > appDir = cmds.internalVar( userAppDir=True ) > sys.path.append( os.path.join( appDir, 'scripts' ) ) > > def executeUserSetup(): > """ > Look for userSetup.py in the search path and execute it in the > "__main__" > namespace > """ > try: > for path in sys.path: > scriptPath = os.path.join( path, 'userSetup.py' ) > if os.path.isfile( scriptPath ): > import __main__ > execfile( scriptPath, __main__.__dict__ ) > except Exception, e: > sys.stderr.write( "Failed to execute userSetup.py\n" ) > sys.stderr.write( str( e ) ) > > # Set up sys.path to include Maya-specific user script directories. > setupScriptPaths() > > # Set up auto-load stubs for Maya commands implemented in libraries > which are not yet loaded > maya.app.commands.processCommandList() > > # Run the user's userSetup.py if it exists > executeUserSetup() > > # Register code to be run on exit > atexit.register( maya.app.finalize ) > > # Set up string table instance for application > maya.stringTable = utils.StringTable() > > that should really let you accurately troubleshoot this. > > -chad > > On Aug 7, 2009, at 10:24 AM, Sylvain Berger wrote: > > > that's a good idea... I finally when with the userSetup.mel calling > > the network python script... Works fine > > > On Fri, Aug 7, 2009 at 11:50 AM, yury nedelin <[email protected]> > > wrote: > > > yury > > > On Fri, Aug 7, 2009 at 7:44 AM, sberger <[email protected]> > > wrote: > > > Hi, I have this setup for Maya 2009 > > > My user Pref are localed on the network m:\profiles\sylvain.berger > > \maya > > \... > > in these user pref I have a maya.env file that add a network > > MAYA_SCRIPT_PATH=m:\library\maya\scripts\ > > > when I put the userSetup.py in the MAYA_SCRIPT_PATH location it > > doesn't get executed, > > it only runs when it is in the scripts folder of my maya pref folder > > > I also have a PYTHONPATH in my maya.env file, and puting the > > userSetup.py file there doesn't work as well. > > > It only runs when it is in my pref folder. > > > did anyone know how to get the userSetup.py to work outside the pref > > folder? I would like to have a userSetup.py global to all user... I > > think I could revert to using a userSetup.mel and call my userSetup.py > > from the mel file... but it is not clean and I hate things that are > > messy :) > > > Thanks > > > -- > > "A pit would not be complete without a Freeman coming out of it." > > The Vortigaunt > > --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/python_inside_maya -~----------~----~----~----~------~----~------~--~---
