I would still only use sys.path in userSetup.py as for all I know its being exec'd into the already initialized python interpreter. Maya.env might be the place for PYTHONPATH modifications. On Dec 7, 2013 11:21 AM, "Todd Widup" <[email protected]> wrote:
> I understand what you are saying, basically, if we are doing this after > opening Maya, do it as a sys.path, otherwise, we can do how we are doing it > > > On Fri, Dec 6, 2013 at 2:20 PM, Todd Widup <[email protected]> wrote: > >> these are all being editing within a Maya session... done within our >> userSetup.py until we shift it over to a powershell based maya launcher >> >> >> On Fri, Dec 6, 2013 at 1:53 PM, Justin Israel <[email protected]>wrote: >> >>> Ya but MAYA_SCRIPT_PATH is an application specific environment variable >>> that Maya is free to read it at any time. >>> PYTHONPATH is specific to python. If Maya is choosing to read it from >>> the env after initialization, I would consider it undefined behavior. >>> >>> http://docs.python.org/2/tutorial/modules.html#the-module-search-path >>> "sys.path is initialized from these locations: >>> the directory containing the input script (or the current directory). >>> PYTHONPATH (a list of directory names, with the same syntax as the shell >>> variable PATH). >>> the installation-dependent default. >>> After initialization, Python programs can modify sys.path." >>> >>> So you can see that after a python interpreter has initialized , you >>> should be using sys.path and not banking on modifying the env for python >>> imports. Unless you are doing it so that subprocesses will inherit the >>> modification, although that should really be done specifically by passing >>> an env dict anyways. >>> Mel is a different story and follows the semantics defined by Maya. >>> On Dec 7, 2013 9:25 AM, "Todd Widup" <[email protected]> wrote: >>> >>>> that was just an example. >>>> >>>> we've done for MAYA_SCRIPT_PATH and for mel is was picking up just fine >>>> from the environ edit, but for an AE template file, it failed unless we >>>> appended the sys path. >>>> >>>> >>>> >>>> >>>> On Fri, Dec 6, 2013 at 12:16 PM, Justin Israel >>>> <[email protected]>wrote: >>>> >>>>> Because an active python interpreter process isn't making use of the >>>>> PYTHONPATH environment variable after the fact. It is used on startup to >>>>> ultimately derive the sys.path >>>>> There are a number of things that actually contribute to the final >>>>> sys.path. >>>>> >>>>> Modifying the PYTHONPATH on os.environ would only have an effect on >>>>> the environment of a subprocess. >>>>> >>>>> >>>>> On Dec 7, 2013, at 9:03 AM, Todd Widup wrote: >>>>> >>>>> ive noticed this a few times and I am trying to track down a WHY >>>>> >>>>> myPath = "someDirectoryPath" >>>>> os.environ["PYTHONPATH"] = "%s;%s" % (myPath, os.environ["PYTHONPATH"]) >>>>> # works occassionally >>>>> >>>>> sys.path.append(myPath) >>>>> # works every time >>>>> >>>>> any ideas or suggestions as to why updating the environ wouldn't work >>>>> all the time? >>>>> >>>>> >>>>> >>>>> -- >>>>> Todd Widup >>>>> Creature TD / Technical Artist >>>>> [email protected] >>>>> [email protected] >>>>> www.toddwidup.com >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Python Programming for Autodesk Maya" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to [email protected]. >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/python_inside_maya/CABBPk35R3O1iT%2BFK55-PKCOd5WKbizRWZM%2BBYrrxeigJzSK3WQ%40mail.gmail.com >>>>> . >>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>> >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Python Programming for Autodesk Maya" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to [email protected]. >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/python_inside_maya/21FF88DF-3720-4B8F-ADE6-C5D667A0E5BB%40gmail.com >>>>> . >>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>> >>>> >>>> >>>> >>>> -- >>>> Todd Widup >>>> Creature TD / Technical Artist >>>> [email protected] >>>> [email protected] >>>> www.toddwidup.com >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Python Programming for Autodesk Maya" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/python_inside_maya/CABBPk36xiov1iijBo%3DkM04DfUxyO5n8wALY2RrD1Mc38j%3Da%2BhQ%40mail.gmail.com >>>> . >>>> >>>> For more options, visit https://groups.google.com/groups/opt_out. >>>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Python Programming for Autodesk Maya" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1jKu-cLJPUX1nZG4sLjpDLgPcX9nB1CzEovKzOPbrckw%40mail.gmail.com >>> . >>> >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >> >> >> >> -- >> Todd Widup >> Creature TD / Technical Artist >> [email protected] >> [email protected] >> www.toddwidup.com >> > > > > -- > Todd Widup > Creature TD / Technical Artist > [email protected] > [email protected] > www.toddwidup.com > > -- > You received this message because you are subscribed to the Google Groups > "Python Programming for Autodesk Maya" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/CABBPk36Lot68WEMCW8WBUDwC4hRhrOYzd%3Dg%2Bb23g5RDbFgodng%40mail.gmail.com > . > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2NfBkUCDMMnyvHLUQda5DP%3D%2BrNTxuRN5AYEZN9N5_gWQ%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
