Recently someone asked me if we could use lxml inside Maya and it turns out that lxml can be used in Maya excepted the Linux version. If you wonder what is lxml, here is a quick description: The lxml XML toolkit is a Pythonic binding for the C libraries libxml2 and libxslt. It is unique in that it combines the speed and XML feature completeness of these libraries with the simplicity of a native Python API, mostly compatible but superior to the well-known ElementTree API.
Libxml2 is the XML C parser and toolkit developed for the Gnome project (but usable outside of the Gnome platform).
Because the Linux version of Maya uses a very old version of libxml2 (i.e. version 2.6.4) and that the least version lxml can be built with is version 2.6.14, it is impossible to make it working. And when I say least lxml version, it is an old one :(
lxml web site mentions that the workaround is to build lxml in static mode. But it turns out that Maya will continue to crash (I also tried the egg way with no luck).
Anyway, after debuging into Maya, the issue was showing when Python was referencing a dictionary libxml2 upon loading lxml.etree => dict.c - xmlDictReference(). And naturally no way to fix the issue from the lxml side.
A workaround, but cannot guarante you would not break any other Maya features is to replace the libawxml2.so from Maya with a newer version. I tried with lxml-2.3.5 and libxml2-2.7.8 and it worked great.
Here is my scripts in case you want to try
#!/bin/bash export MAYA_LOCATION=/usr/autodesk/maya2013.5-x64 export MYHOME=/home/cyrille export DEST=$HOME/output # assuming libxml2 source was downloaded and untar in ~/libxml2 # and that libxslt is already on the machine or was built as well cd ~/libxml2 ./configure --prefix=$DEST --without-python --with-zlib make clean && make make install # assuming lxml was downloaded and untar in ~/lxml cd ~/lxml $MAYA_LOCATION/bin/mayapy ./setup.py build # log as su $MAYA_LOCATION/bin/mayapy ./setup.py install mv $MAYA_LOCATION/lib/libawxml2.so $MAYA_LOCATION/lib/libawxml2.so.old cp $DEST/lib/libxml2.so $MAYA_LOCATION/lib/libawxml2.so
That should be it,
but do not forget you need GCC 4.1.2 as it always been for Maya 2013 - 2013.5
Comments