from maya.OpenMaya import MGlobal
apiVerNum = MGlobal.apiVersion()
verString = MGlobal.mayaVersion()
- Paul
--
http://groups.google.com/group/python_inside_maya
To unsubscribe, reply using "remove me" as the subject.
It cuts down the sitecustomize into more manageable pieces and seems
to be working out well for us.
Ian
The other related thing we do that may be of interest to you is to
call the python interpreter explicitly, rather than relying on some os
level association, which might give you the wrong one. We have a stand
alone application that runs most of our tools. When a user runs Maya,
or any tool, this stand alone app builds an environment for it and
then runs it. We don't absolutely need to build the environment each
time, as it would be inherited from the calling process, but we wanted
the option of overloading some settings. We keep all of our tools,
including Maya, in our Perforce depot. Aside from getting around
having to install it, this means we know exactly where it is, so we
can call the correct mayapy directly.
At any rate, what you are describing sounds reasonable, but I would
advise limiting the content of sitecustomize to site customization
only. Not only will your cmds problem go away, but you will a system
that is easier to troubleshoot.
The major change in 2.5 related to sitecustomize.py is that it must be
on the original pythonpath in order for it to be executed. Prior to
2.5 you were able to save sitecustomize.py in the current working
directory and python would execute it. This is because the cwd is now
added to the path much later (and after the site module loads).
This recipe seems to support this understanding:
http://code.activestate.com/recipes/552729/
That all said projects/packages that were using it via the no longer
supported methods could easily break so YMMV.
2010/4/12 Jo Jürgens <joju...@gmail.com>:
What I've done here to support different scripts, plug-in etc is to
write a Maya launcher in PyQt. Essentially the user gets a UI with
several different flavors of Maya to choose from. Our flavors are just
different projects. When the user clicks, a new thread is spawned with
a blank environment. I then populate the environment based on the
selection. This give me absolute control on where maya will look at
things as I'm controlling the environments vars it will be looking
at.
So far it seems to be working pretty well.
Cheers,
-Shawn
On Apr 12, 8:39 am, Ian Jones <i...@ambientdivide.com> wrote:
> My understanding is that sitecustomize.py is still supported, just not
> in all the ways it used to be prior to version 2.5. I'm using it with
> version 2.6 right now in fact.
>
> The major change in 2.5 related to sitecustomize.py is that it must be
> on the original pythonpath in order for it to be executed. Prior to
> 2.5 you were able to save sitecustomize.py in the current working
> directory and python would execute it. This is because the cwd is now
> added to the path much later (and after the site module loads).
>
> This recipe seems to support this understanding:
>
> http://code.activestate.com/recipes/552729/
>
> That all said projects/packages that were using it via the no longer
> supported methods could easily break so YMMV.
>
> 2010/4/12 Jo Jürgens <jojurg...@gmail.com>:
>
> > Just be aware that sitecustomize.py is unsupported by Python since Python 25
> > and may cause problems with other modules. Ive had it break Django or Pylons
> > (dont remember which one), so I stopped using it.
>
> >> > On Sun, Apr 11, 2010 at 8:06 PM, David Shaw <flopp...@gmail.com> wrote:
> >> >> Thank you Paul, much appreciated.
>
> >> >> Do you think the approach I am taking is feasible or practical?
>
> >> >> How do you guys go about it?
>
> >> >> Dave
>
> >> >> On Mon, Apr 12, 2010 at 1:55 AM, Paul Molodowitch <elron...@gmail.com>
from pymel.all import *
# Error: AssertionError: assert hasattr(maya.utils, 'shellLogHandler'), "If you manually installed pymel, ensure " \: If you manually installed pymel, ensure that pymel comes before Maya's site-packages directory on PYTHONPATH / sys.path. See pymel docs for more info. #
Post Path: D:\pipeline_tools\python\site-packages\pyodbc-2.1.7
Post Path: D:\pipeline_tools\python\site-packages\pymel_1.0.0rc2
Post Path: I:\Program Files (x86)\Autodesk\Maya2010\bin
Post Path: I:\Program Files (x86)\Autodesk\Maya2010\bin\python26.zip
Post Path: I:\Program Files (x86)\Autodesk\Maya2010\Python\DLLs
Post Path: I:\Program Files (x86)\Autodesk\Maya2010\Python\lib
Post Path: I:\Program Files (x86)\Autodesk\Maya2010\Python\lib\plat-win
Post Path: I:\Program Files (x86)\Autodesk\Maya2010\Python\lib\lib-tk
Post Path: I:\Program Files (x86)\Autodesk\Maya2010\Python
Post Path: I:\Program Files (x86)\Autodesk\Maya2010\Python\lib\site-packages
import sys
import os
import re
from maya.OpenMaya import MGlobal
for p in sys.path: print ('Pre Path: ' + p)
apiVerNum = MGlobal.apiVersion()
verString = MGlobal.mayaVersion()
mayaVersion = str(verString)
path = os.environ.get ("PYTHON_SITEPACKAGES")
if(os.path.exists(path)):
sitePackages = os.listdir(path)
packagesToInsert = sitePackages[:] #duplicate the list so we can remove any packages we don't want to insert
for package in sitePackages:
if mayaVersion == '2011':
pymelMatch = re.match('pymel', package)
if pymelMatch:
packagesToInsert.remove(package)
for insertPackage in packagesToInsert:
sitePath = os.path.join(path, insertPackage)
realPath = os.path.realpath(sitePath)
print '*** Inserting package: %s from path: %s' % (insertPackage, realPath)
sys.path.insert(0,realPath)
else:
print "DEV: Site packages path does not exist in Maya.env - skipping"
for p in sys.path: print ('Post Path: ' + p)
import sys
import os
import re
#from maya.OpenMaya import MGlobal
for p in sys.path: print ('Pre Path: ' + p)
#apiVerNum = MGlobal.apiVersion()
#verString = MGlobal.mayaVersion()
mayaVersion = '2011'
path = os.environ.get ("PYTHON_SITEPACKAGES")
if(os.path.exists(path)):
sitePackages = os.listdir(path)
packagesToInsert = sitePackages[:] #duplicate the list so we can remove any packages we don't want to insert
for package in sitePackages:
if mayaVersion == '2011':
pymelMatch = re.match('pymel', package)
if pymelMatch:
packagesToInsert.remove(package)
for insertPackage in packagesToInsert:
sitePath = os.path.join(path, insertPackage)
realPath = os.path.realpath(sitePath)
print '*** Inserting package: %s from path: %s' % (insertPackage, realPath)
sys.path.insert(0,realPath)
else:
print "DEV: Site packages path does not exist in Maya.env - skipping"
for p in sys.path: print ('Post Path: ' + p)
pymel_1.0.0rc2
pyodbc-2.1.7