*sitecustomize*
There can be only one sitecustomize.py in your environment. Python will
search the PYTHONPATH and run the first sitecustomize.py found. It does
this each time the interpreter is booted up.
I like to reserve sitecustomize for very basic path python library setup.
Mostly, I inject the core studio libraries into the sys.path so I have
access from every app/tool. I even have some binary libraries that I want
available in every interpreter. This requires some IT/Systems coordination,
but it's simple enough once you set all machines to have:
PYTHONPATH=/studio_server/lib/python
My sitecustomize.py inspects the interpreter to determine the correct paths
to add to sys.path:
<...>/<pyversion>/<os>/<architecture>
The libraries are some place like this:
/studio_server/lib/python/2.7/Darwin/64bit/opencv
*virtualenv*
Virtualenv does some trickery with the sys.exec_prefix when launching
python from within a virtualenv environment. I believe this is done by
using a wrapper binary for the real python binary. This *may* work for
mayapy if you specify the python binary when creating the env:
virtualenv -p <path/to/mayapy> <path/to/new/virtualenv/>
or even:
virtualenv -p <path/to/maya> <path/to/new/virtualenv/>
*Alternatives:*
*sys.path*
You can try to directly manipulate the sys.path before you import any
necessary libraries. You can even try to use your virtualenv libraries:
import sys
sys.path.append("/path/to/myvirtualenv/lib/python2.7/site-packages")
*PYTHONPATH*
The PYTHONPATH environment variable can be used on its own if you don't
want to play with sitecustomize. It's just a search path and not really
that magic. Virtualenv is mostly there to help with the install process,
and avoid letting you poison your main library folder.
*userSetup.py*
userSetup.py is much like sitecustomize except that you can have multiple
userSetup.py files and *all* will be executed when maya starts. It
leverages your PYTHONPATH variable. For example, just set do this:
export PYTHONPATH=/studio_server/lib/python:/studio_server/projects/acme123maya
... Actually, Autodesk has a good writeup on this stuff already:
http://help.autodesk.com/view/MAYAUL/2015/ENU/?guid=Python_Python_in_Maya
There are too many ways to customize maya and the available python
packages. You just need to pick your poison.
-j
--
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/CANESWi2kCzr2FzVV-JZmpUtw%3DY0U9AgpeYdYJtHDuv_jLYDedg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.