maya2egg linux error

first, big thanks to pro-rsoft for adding linux support for the maya exporter to makepanda!

Now, on to debugging :slight_smile: The build and install was pretty painless, but I’m getting a segfault when I try to convert a model:

$ maya2egg2008 -a model -o test.egg skull.mb

Initializing Maya.
Fatal Python error: Py_Initialize: can't make first thread

Signal: 6 ()
Segmentation fault

Interesting. Can you post a traceback?

gdb maya2egg2008
run -a model -o test.egg skull.mb
bt

(the second command should be typed in the gdb shell, and the third the moment it crashes)

Hmm, I wonder if Maya’s Python is inadvertently calling into Panda’s pystub routines? That would be bad news.

Ever since Maya went to Python, we’ve had various troubles keeping their Python calls separate from our Python calls.

David

Here’s the backtrace from the core file …

gdb maya2egg2008-wrapped --core core.8141
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...

warning: core file may not match specified executable file.
Reading symbols from /usr/lib/panda3d/libpandaegg.so...done.
Loaded symbols for /usr/lib/panda3d/libpandaegg.so
Reading symbols from /usr/lib/panda3d/libpanda.so...done.
Loaded symbols for /usr/lib/panda3d/libpanda.so
Reading symbols from /usr/lib/panda3d/libpandaexpress.so...done.
Loaded symbols for /usr/lib/panda3d/libpandaexpress.so
Reading symbols from /usr/lib/panda3d/libp3dtool.so...done.
Loaded symbols for /usr/lib/panda3d/libp3dtool.so
Reading symbols from /usr/lib/panda3d/libp3dtoolconfig.so...done.
Loaded symbols for /usr/lib/panda3d/libp3dtoolconfig.so
Reading symbols from /usr/lib/panda3d/libp3pystub.so...done.
Loaded symbols for /usr/lib/panda3d/libp3pystub.so
Reading symbols from /usr/autodesk/maya2008/lib/libOpenMaya.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/libOpenMaya.so
Reading symbols from /usr/autodesk/maya2008/lib/libOpenMayaAnim.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/libOpenMayaAnim.so
Reading symbols from /usr/autodesk/maya2008/lib/libAnimSlice.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/libAnimSlice.so
Reading symbols from /usr/autodesk/maya2008/lib/libDeformSlice.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/libDeformSlice.so
Reading symbols from /usr/autodesk/maya2008/lib/libModifiers.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/libModifiers.so
Reading symbols from /usr/autodesk/maya2008/lib/libDynSlice.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/libDynSlice.so
Reading symbols from /usr/autodesk/maya2008/lib/libKinSlice.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/libKinSlice.so
Reading symbols from /usr/autodesk/maya2008/lib/libModelSlice.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/libModelSlice.so
Reading symbols from /usr/autodesk/maya2008/lib/libNurbsSlice.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/libNurbsSlice.so
Reading symbols from /usr/autodesk/maya2008/lib/libPolySlice.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/libPolySlice.so
Reading symbols from /usr/autodesk/maya2008/lib/libProjectSlice.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/libProjectSlice.so
Reading symbols from /usr/autodesk/maya2008/lib/libImage.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/libImage.so
Reading symbols from /usr/autodesk/maya2008/lib/libShared.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/libShared.so
Reading symbols from /usr/autodesk/maya2008/lib/libTranslators.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/libTranslators.so
Reading symbols from /usr/autodesk/maya2008/lib/libDataModel.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/libDataModel.so
Reading symbols from /usr/autodesk/maya2008/lib/libRenderModel.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/libRenderModel.so
Reading symbols from /usr/autodesk/maya2008/lib/libNurbsEngine.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/libNurbsEngine.so
Reading symbols from /usr/autodesk/maya2008/lib/libDependEngine.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/libDependEngine.so
Reading symbols from /usr/autodesk/maya2008/lib/libCommandEngine.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/libCommandEngine.so
Reading symbols from /usr/autodesk/maya2008/lib/libFoundation.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/libFoundation.so
Reading symbols from /usr/autodesk/maya2008/lib/libIMFbase.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/libIMFbase.so
Reading symbols from /lib/tls/i686/cmov/libpthread.so.0...done.
Loaded symbols for /lib/tls/i686/cmov/libpthread.so.0
Reading symbols from /lib/tls/i686/cmov/libdl.so.2...done.
Loaded symbols for /lib/tls/i686/cmov/libdl.so.2
Reading symbols from /usr/lib/libstdc++.so.6...done.
Loaded symbols for /usr/lib/libstdc++.so.6
Reading symbols from /lib/tls/i686/cmov/libm.so.6...done.
Loaded symbols for /lib/tls/i686/cmov/libm.so.6
Reading symbols from /lib/libgcc_s.so.1...done.
Loaded symbols for /lib/libgcc_s.so.1
Reading symbols from /lib/tls/i686/cmov/libc.so.6...done.
Loaded symbols for /lib/tls/i686/cmov/libc.so.6
Reading symbols from /usr/autodesk/maya2008/lib/libCg.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/libCg.so
Reading symbols from /usr/lib/libtiff.so.4...done.
Loaded symbols for /usr/lib/libtiff.so.4
Reading symbols from /usr/lib/libz.so.1...done.
Loaded symbols for /usr/lib/libz.so.1
Reading symbols from /usr/lib/libpng12.so.0...done.
Loaded symbols for /usr/lib/libpng12.so.0
Reading symbols from /usr/lib/libjpeg.so.62...done.
Loaded symbols for /usr/lib/libjpeg.so.62
Reading symbols from /usr/lib/i686/cmov/libssl.so.0.9.8...done.
Loaded symbols for /usr/lib/i686/cmov/libssl.so.0.9.8
Reading symbols from /usr/lib/libfreetype.so.6...done.
Loaded symbols for /usr/lib/libfreetype.so.6
Reading symbols from /usr/autodesk/maya2008/lib/libawxml2.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libawxml2.so
Reading symbols from /usr/autodesk/maya2008/lib/libAG.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libAG.so
Reading symbols from /usr/autodesk/maya2008/lib/libiff.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libiff.so
Reading symbols from /usr/autodesk/maya2008/lib/libAppVersion.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libAppVersion.so
Reading symbols from /usr/autodesk/maya2008/lib/libAnimEngine.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libAnimEngine.so
Reading symbols from /usr/autodesk/maya2008/lib/libGeometryEngine.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libGeometryEngine.so
Reading symbols from /usr/autodesk/maya2008/lib/libDependCommand.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libDependCommand.so
Reading symbols from /usr/autodesk/maya2008/lib/libExtensionLayer.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libExtensionLayer.so
Reading symbols from /usr/autodesk/maya2008/lib/libPolyEngine.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libPolyEngine.so
Reading symbols from /usr/autodesk/maya2008/lib/libSubdivEngine.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libSubdivEngine.so
Reading symbols from /usr/autodesk/maya2008/lib/libSubdivGeom.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libSubdivGeom.so
Reading symbols from /usr/autodesk/maya2008/lib/lib3dGraphics.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/lib3dGraphics.so
Reading symbols from /usr/autodesk/maya2008/lib/libNurbs.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libNurbs.so
Reading symbols from /usr/autodesk/maya2008/lib/libPoly.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libPoly.so
Reading symbols from /usr/autodesk/maya2008/lib/libSubdiv.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libSubdiv.so
Reading symbols from /usr/autodesk/maya2008/lib/libHWFoundation.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libHWFoundation.so
Reading symbols from /usr/autodesk/maya2008/lib/libHWGL.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libHWGL.so
Reading symbols from /usr/autodesk/maya2008/lib/libHWRender.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libHWRender.so
Reading symbols from /usr/autodesk/maya2008/lib/libRenderSlice.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libRenderSlice.so
Reading symbols from /usr/autodesk/maya2008/lib/libBase.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libBase.so
Reading symbols from /usr/autodesk/maya2008/lib/libpython2.5.so.1.0...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libpython2.5.so.1.0
Reading symbols from /usr/autodesk/maya2008/lib/libtbb.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libtbb.so
Reading symbols from /usr/autodesk/maya2008/lib/libHumanIKShared.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libHumanIKShared.so
Reading symbols from /usr/lib/libGL.so.1...done.
Loaded symbols for /usr/lib/libGL.so.1
Reading symbols from /usr/autodesk/maya2008/lib/libimf.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libimf.so
Reading symbols from /usr/autodesk/maya2008/lib/libsvml.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libsvml.so
Reading symbols from /usr/autodesk/maya2008/lib/libguide.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libguide.so
Reading symbols from /usr/autodesk/maya2008/lib/libcxaguard.so.5...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libcxaguard.so.5
Reading symbols from /usr/autodesk/maya2008/lib/libirc.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libirc.so
Reading symbols from /usr/autodesk/maya2008/lib/libawnSolver.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libawnSolver.so
Reading symbols from /usr/autodesk/maya2008/lib/libSharedUI.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libSharedUI.so
Reading symbols from /usr/autodesk/maya2008/lib/libImageUI.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libImageUI.so
Reading symbols from /usr/autodesk/maya2008/lib/libXm.so.3...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libXm.so.3
Reading symbols from /usr/lib/libXp.so.6...done.
Loaded symbols for /usr/lib/libXp.so.6
Reading symbols from /usr/lib/libXmu.so.6...done.
Loaded symbols for /usr/lib/libXmu.so.6
Reading symbols from /usr/lib/libXpm.so.4...done.
Loaded symbols for /usr/lib/libXpm.so.4
Reading symbols from /usr/lib/libXt.so.6...done.
Loaded symbols for /usr/lib/libXt.so.6
Reading symbols from /usr/lib/libXi.so.6...done.
Loaded symbols for /usr/lib/libXi.so.6
Reading symbols from /usr/lib/libXext.so.6...done.
Loaded symbols for /usr/lib/libXext.so.6
Reading symbols from /usr/lib/libX11.so.6...done.
Loaded symbols for /usr/lib/libX11.so.6
Reading symbols from /usr/autodesk/maya2008/lib/libawCacheShared.so...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libawCacheShared.so
Reading symbols from /usr/lib/libfam.so.0...done.
Loaded symbols for /usr/lib/libfam.so.0
Reading symbols from /usr/autodesk/maya2008/lib/libGLU.so.1...done.
Loaded symbols for /usr/autodesk/maya2008/lib/../lib/libGLU.so.1
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /usr/lib/i686/cmov/libcrypto.so.0.9.8...done.
Loaded symbols for /usr/lib/i686/cmov/libcrypto.so.0.9.8
Reading symbols from /usr/lib/libXinerama.so.1...done.
Loaded symbols for /usr/lib/libXinerama.so.1
Reading symbols from /lib/tls/i686/cmov/librt.so.1...done.
Loaded symbols for /lib/tls/i686/cmov/librt.so.1
Reading symbols from /lib/libuuid.so.1...done.
Loaded symbols for /lib/libuuid.so.1
Reading symbols from /lib/tls/i686/cmov/libutil.so.1...done.
Loaded symbols for /lib/tls/i686/cmov/libutil.so.1
Reading symbols from /usr/lib/libGLcore.so.1...done.
Loaded symbols for /usr/lib/libGLcore.so.1
Reading symbols from /usr/lib/tls/libnvidia-tls.so.1...done.
Loaded symbols for /usr/lib/tls/libnvidia-tls.so.1
Reading symbols from /usr/lib/libSM.so.6...done.
Loaded symbols for /usr/lib/libSM.so.6
Reading symbols from /usr/lib/libICE.so.6...done.
Loaded symbols for /usr/lib/libICE.so.6
Reading symbols from /usr/lib/libXau.so.6...done.
Loaded symbols for /usr/lib/libXau.so.6
Reading symbols from /usr/lib/libxcb-xlib.so.0...done.
Loaded symbols for /usr/lib/libxcb-xlib.so.0
Reading symbols from /usr/lib/libxcb.so.1...done.
Loaded symbols for /usr/lib/libxcb.so.1
Reading symbols from /usr/lib/libXdmcp.so.6...done.
Loaded symbols for /usr/lib/libXdmcp.so.6
Core was generated by `/usr/bin/maya2egg2008 -a model -o test.egg skull.mb'.
Program terminated with signal 11, Segmentation fault.
[New process 8141]
[New process 8144]
#0  0xb2e526f6 in Tmodel::delayActiveListModified () from /usr/autodesk/maya2008/lib/libDataModel.so
(gdb) bt
#0  0xb2e526f6 in Tmodel::delayActiveListModified () from /usr/autodesk/maya2008/lib/libDataModel.so
#1  0xb3583e3c in TfileCmd::doCommand () from /usr/autodesk/maya2008/lib/libShared.so
#2  0xb1c6f6f1 in Mel_Command_Dispatch () from /usr/autodesk/maya2008/lib/libCommandEngine.so
#3  0xb1c92160 in node_exec () from /usr/autodesk/maya2008/lib/libCommandEngine.so
#4  0xb1c92326 in sophia_call_executable () from /usr/autodesk/maya2008/lib/libCommandEngine.so
#5  0xb1cae85a in SophiaExecutable::evaluate () from /usr/autodesk/maya2008/lib/libCommandEngine.so
#6  0xb1c75393 in TcommandEngine::executeCommand () from /usr/autodesk/maya2008/lib/libCommandEngine.so
#7  0xaf0bf038 in ?? () from /usr/autodesk/maya2008/lib/../lib/libExtensionLayer.so
#8  0xaf0c0200 in ?? () from /usr/autodesk/maya2008/lib/../lib/libExtensionLayer.so
#9  <signal handler called>
#10 0xb7fd8410 in __kernel_vsyscall ()
#11 0xafd44085 in raise () from /lib/tls/i686/cmov/libc.so.6
#12 0xafd45a01 in abort () from /lib/tls/i686/cmov/libc.so.6
#13 0xae0261b8 in Py_FatalError (msg=0xae061014 "Py_Initialize: can't make first thread") at Python/pythonrun.c:1559
#14 0xae0286ce in Py_InitializeEx (install_sigs=1) at Python/pythonrun.c:180
#15 0xae0287ee in Py_Initialize () at Python/pythonrun.c:321
#16 0xb1cdf4f0 in TpythonInterpreter::TpythonInterpreter () from /usr/autodesk/maya2008/lib/libCommandEngine.so
#17 0xb34893f9 in TbaseApp::initGeneral () from /usr/autodesk/maya2008/lib/libShared.so
#18 0xb3488335 in TlibModeApp::initGeneral () from /usr/autodesk/maya2008/lib/libShared.so
#19 0xaf0beb8c in Tapplication::start () from /usr/autodesk/maya2008/lib/../lib/libExtensionLayer.so
#20 0xb34891c2 in libmain () from /usr/autodesk/maya2008/lib/libShared.so
#21 0x080c7f18 in MLibrary::initialize ()
#22 0x080c7fc7 in MLibrary::initialize ()
#23 0x08091480 in MayaApi::MayaApi ()
#24 0x0809266f in MayaApi::open_api ()
#25 0x0806315e in MayaToEggConverter::open_api ()
#26 0x0805a538 in MayaToEgg::run ()
#27 0x0805e037 in main ()

drwr, that’s a very good possibility. Python calls PyThreadState_New internally and if it is NULL, throws this error. Since panda’s pystub functions always return 0 I bet this is the issue.
Odd that this doesn’t occur on windows though.

Would just making sure pystub doesn’t get linked into the maya binaries work?

Different OS’s have different rules when two different shared libraries define the same symbol. In this case, it sounds like Windows may have made the right choice, while Linux has made the wrong chioce; whether this is by luck or by design is a question for philosophers.

It’s certainly worth a try. There may still be issues if there are version differences between Maya’s Python and Panda’s Python; in this case, some of the symbols that Panda attempts to link to may not be provided by Maya, and then the link operation may croak.

But on Linux, I think that may not be an issue, since Linux supports lazy binding; if it is an issue at all, it will be so on Windows. We’ll cross that bridge when we come to it.

David

Hmm. Unfortunately, I can’t test it since I don’t have my hands on a copy of Maya right now, but can you try this, Ben:
Edit makepanda.py, go to the part about “pandatool/src/mayaprogs”, remove the line about libp3pystub.dll, and replace all instances of COMMON_EGG2X_LIBS_PYSTUB with COMMON_EGG2X_LIBS in this scope.

Thanks, I’ll try that. by “in this scope” you mean just in the section related to mayaprogs, right?

btw my python version is 2.5.2.

a little later …

g++ -o built/bin/maya2egg2008-wrapped -Lbuilt/lib -L/usr/X11R6/lib built/tmp/maya2egg2008_mayaToEgg.o built/lib/libmayaegg2008.a built/lib/libmaya2008.a built/lib/libeggbase.a built/lib/libprogbase.a built/lib/libconverter.a built/lib/libpandatoolbase.a -lpandaegg -lpanda -lpandaexpress -lp3dtool -lp3dtoolconfig -L"/usr/autodesk/maya2008/lib" -Wl,-rpath,/usr/autodesk/maya2008/lib -lOpenMayalib -lOpenMaya -lOpenMayaAnim -lAnimSlice -lDeformSlice -lModifiers -lDynSlice -lKinSlice -lModelSlice -lNurbsSlice -lPolySlice -lProjectSlice -lImage -lShared -lTranslators -lDataModel -lRenderModel -lNurbsEngine -lDependEngine -lCommandEngine -lFoundation -lIMFbase -lpthread -ldl
built/tmp/maya2egg2008_mayaToEgg.o: In function `main':
mayaToEgg.cxx:(.text+0x3c0b): undefined reference to `pystub()'

do I need to completely rebuild all of panda? I did just remove the maya-related parts from built/tmp and built/lib to force a recompile, but that’s probably not the cleanest way to do it…

Just for kicks I thought I’d trying hiding maya’s version of libpython, as with it’s special libstdc++, etc., and compile with pystub still included. I get a different segfault in maya2egg:

Initializing Maya.
Fatal Python error: Can't initialize 'type'

here’s the stack trace:

Core was generated by `/usr/bin/maya2egg2008 -a model -o skull.egg skull.mb'.
Program terminated with signal 11, Segmentation fault.
[New process 7544]
[New process 7547]
#0  0xb2dd86f6 in Tmodel::delayActiveListModified () from /usr/autodesk/maya2008/lib/libDataModel.so
(gdb) bt
#0  0xb2dd86f6 in Tmodel::delayActiveListModified () from /usr/autodesk/maya2008/lib/libDataModel.so
#1  0xb3509e3c in TfileCmd::doCommand () from /usr/autodesk/maya2008/lib/libShared.so
#2  0xb1bf56f1 in Mel_Command_Dispatch () from /usr/autodesk/maya2008/lib/libCommandEngine.so
#3  0xb1c18160 in node_exec () from /usr/autodesk/maya2008/lib/libCommandEngine.so
#4  0xb1c18326 in sophia_call_executable () from /usr/autodesk/maya2008/lib/libCommandEngine.so
#5  0xb1c3485a in SophiaExecutable::evaluate () from /usr/autodesk/maya2008/lib/libCommandEngine.so
#6  0xb1bfb393 in TcommandEngine::executeCommand () from /usr/autodesk/maya2008/lib/libCommandEngine.so
#7  0xaf045038 in ?? () from /usr/autodesk/maya2008/lib/../lib/libExtensionLayer.so
#8  0xaf046200 in ?? () from /usr/autodesk/maya2008/lib/../lib/libExtensionLayer.so
#9  <signal handler called>
#10 0xb7f5e410 in __kernel_vsyscall ()
#11 0xafcca085 in raise () from /lib/tls/i686/cmov/libc.so.6
#12 0xafccba01 in abort () from /lib/tls/i686/cmov/libc.so.6
#13 0xadfabad8 in Py_FatalError () from /usr/lib/libpython2.5.so.1.0
#14 0xadf3c7e2 in _Py_ReadyTypes () from /usr/lib/libpython2.5.so.1.0
#15 0xadfada7b in Py_InitializeEx () from /usr/lib/libpython2.5.so.1.0
#16 0xadfae13e in Py_Initialize () from /usr/lib/libpython2.5.so.1.0
#17 0xb1c654f0 in TpythonInterpreter::TpythonInterpreter ()
   from /usr/autodesk/maya2008/lib/libCommandEngine.so
#18 0xb340f3f9 in TbaseApp::initGeneral () from /usr/autodesk/maya2008/lib/libShared.so
#19 0xb340e335 in TlibModeApp::initGeneral () from /usr/autodesk/maya2008/lib/libShared.so
#20 0xaf044b8c in Tapplication::start () from /usr/autodesk/maya2008/lib/../lib/libExtensionLayer.so
#21 0xb340f1c2 in libmain () from /usr/autodesk/maya2008/lib/libShared.so
#22 0x080c7f18 in MLibrary::initialize ()
#23 0x080c7fc7 in MLibrary::initialize ()
#24 0x08091480 in MayaApi::MayaApi ()
#25 0x0809266f in MayaApi::open_api ()
#26 0x0806315e in MayaToEggConverter::open_api ()
#27 0x0805a538 in MayaToEgg::run ()
#28 0x0805e037 in main ()

So, I don’t know what pystub is exactly but it sounds like it’s maybe not needed for this part … ? So I tried commenting it out maya2egg.cxx also. that solved the build errors, and I now have different crash results :slight_smile:

maya2egg2008 -a model -o table.egg table.mb

Initializing Maya.
'import site' failed; use -v for traceback
ImportError: No module named maya.app.python

Python Evironment:
  PYTHONHOME not set!
ImportError: No module named site
  Python cannot find site module!
  Python cannot find sys module!
ImportError: No module named maya.app.python

Python Evironment:
  PYTHONHOME not set!
ImportError: No module named site
  Python cannot find site module!
  Python cannot find sys module!
ImportError: No module named maya
ImportError: No module named maya.cmds
ImportError: No module named maya.utils
ImportError: No module named maya.mel
ImportError: No module named maya.app

Python Evironment:
  PYTHONHOME not set!
ImportError: No module named site
  Python cannot find site module!
  Search path (sys.path):

ImportError: No module named maya.app.startup.batch

that’s after I’ve put the python2.5/site-packages/maya folder into /usr/lib/python2.5/site-packages. I can in fact import all of those things successfully from the python interpreter. interesting…

I’m only guessing here, since I don’t have maya myself, but I think maya wants to use its own python libs. mayaWrapper.cxx is supposed to set the correct environment variables for that, but the problem is, maya lacks the files such as site.py, which are essential to python.

I’ve just checked in some changes to pandatool/src/mayaprogs/mayaWrapper.cxx. Can you try that out?

PS. pystub is a shadow of most functions in the Python C API – however, the pystub functions are all empty and just return 0.

Trying it out now …

This is interesting: I started looking at the examples in the maya/devkit folder to see how this -supposed- to work. So, mayapy is just a wrapper that sets the env variables and then runs maya’s own python interpreter, /usr/autodesk/maya/bin/python-bin.

But when I try running that by itself, it looks to be almost exactly the same as my default system-installed python!

./python-bin
'import site' failed; use -v for traceback
Python 2.5.2 (r252:60911, Apr 21 2008, 11:29:43)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
/usr/autodesk/maya/bin$ python
'import site' failed; use -v for traceback
Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

That seems really strange. I wonder if I botched something when I converted those RPM’s to DEB’s.

I see that in Maya 8.5, the maya/lib/python2.4 directory is chock full of stuff, everything that’s in a normal /usr/lib/pythonXXX install; and it has a site.py. In maya2008 there is only site-packages and lib-dynload…

Is the end goal to make maya2egg use maya’s python, or to make it use normal python … or not try to use python at all?

Alas, still the same error about not being able to import ‘site’.

I tried a couple of different values for PYTHONHOME - /usr/autodesk/maya, /usr/lib/python2.5, /usr … if I do that I can get past the python import errors and it’s back to a segfault. Here’s another trace …

#0  0xb009fa72 in Tstring::formatToWidth () from /usr/autodesk/maya2008/lib/libFoundation.so
(gdb) bt
#0  0xb009fa72 in Tstring::formatToWidth () from /usr/autodesk/maya2008/lib/libFoundation.so
#1  0xb32d8ef0 in TaboutAction::doCommand () from /usr/autodesk/maya2008/lib/libShared.so
#2  0xb1b766f1 in Mel_Command_Dispatch () from /usr/autodesk/maya2008/lib/libCommandEngine.so
#3  0xb1b99160 in node_exec () from /usr/autodesk/maya2008/lib/libCommandEngine.so
#4  0xb1b99326 in sophia_call_executable () from /usr/autodesk/maya2008/lib/libCommandEngine.so
#5  0xb1bb585a in SophiaExecutable::evaluate () from /usr/autodesk/maya2008/lib/libCommandEngine.so
#6  0xb1b7c393 in TcommandEngine::executeCommand () from /usr/autodesk/maya2008/lib/libCommandEngine.so
#7  0xb32a9139 in TsceneFile::initializeFileInfo () from /usr/autodesk/maya2008/lib/libShared.so
#8  0xb348b536 in TsceneOperator::saveScene () from /usr/autodesk/maya2008/lib/libShared.so
#9  0xb34812fc in TfileCmd::handleFileSaveFlag () from /usr/autodesk/maya2008/lib/libShared.so
#10 0xb348a65d in TfileCmd::handleFlags () from /usr/autodesk/maya2008/lib/libShared.so
#11 0xb348af1b in TfileCmd::doCommand () from /usr/autodesk/maya2008/lib/libShared.so
#12 0xb1b766f1 in Mel_Command_Dispatch () from /usr/autodesk/maya2008/lib/libCommandEngine.so
#13 0xb1b99160 in node_exec () from /usr/autodesk/maya2008/lib/libCommandEngine.so
#14 0xb1b99326 in sophia_call_executable () from /usr/autodesk/maya2008/lib/libCommandEngine.so
#15 0xb1bb585a in SophiaExecutable::evaluate () from /usr/autodesk/maya2008/lib/libCommandEngine.so
#16 0xb1b7c393 in TcommandEngine::executeCommand () from /usr/autodesk/maya2008/lib/libCommandEngine.so
#17 0xaefc717c in ?? () from /usr/autodesk/maya2008/lib/../lib/libExtensionLayer.so
#18 0xaefc8200 in ?? () from /usr/autodesk/maya2008/lib/../lib/libExtensionLayer.so
#19 <signal handler called>
#20 0xb009fa72 in Tstring::formatToWidth () from /usr/autodesk/maya2008/lib/libFoundation.so
#21 0xb32d8ef0 in TaboutAction::doCommand () from /usr/autodesk/maya2008/lib/libShared.so
#22 0xb1be54b3 in TpythonInterpreter::dispatchMayaCommand () from /usr/autodesk/maya2008/lib/libCommandEngine.so
#23 0xadebef1a in PyCFunction_Call (func=0xaba0886c, arg=0xaba1802c, kw=0x0) at Objects/methodobject.c:77
#24 0xade89587 in PyObject_Call (func=0xbfd47b44, arg=0xaba1802c, kw=0xab99b13c) at Objects/abstract.c:1860
#25 0xadf07af3 in PyEval_EvalFrameEx (f=0x8359bdc, throwflag=0) at Python/ceval.c:3775
#26 0xadf0c7e8 in PyEval_EvalFrameEx (f=0x8358a04, throwflag=0) at Python/ceval.c:3650
#27 0xadf0d8d3 in PyEval_EvalCodeEx (co=0xab99a068, globals=0xaba01cec, locals=0xaba01cec, args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:2831
#28 0xadf0d945 in PyEval_EvalCode (co=0xab99a068, globals=0xaba01cec, locals=0xaba01cec) at Python/ceval.c:494
#29 0xadf2205b in PyImport_ExecCodeModuleEx (name=0xbfd4ad97 "maya.app.startup.basic", co=0xab99a068, pathname=0xbfd48cbb "/usr/lib/python2.5/site-packages/maya/app/startup/basic.pyc")
    at Python/import.c:669
#30 0xadf243b6 in load_source_module (name=0xbfd4ad97 "maya.app.startup.basic", pathname=0xbfd48cbb "/usr/lib/python2.5/site-packages/maya/app/startup/basic.pyc", fp=0x8358890) at Python/import.c:953
#31 0xadf24a40 in import_submodule (mod=0xaba1859c, subname=0xbfd4ada8 "basic", fullname=0xbfd4ad97 "maya.app.startup.basic") at Python/import.c:2394
#32 0xadf24f18 in load_next (mod=0xaba1859c, altmod=0xaba1859c, p_name=<value optimized out>, buf=0xbfd4ad97 "maya.app.startup.basic", p_buflen=0xbfd4bd98) at Python/import.c:2214
#33 0xadf2514a in import_module_level (name=0x0, globals=<value optimized out>, locals=<value optimized out>, fromlist=0xadf77dc0, level=<value optimized out>) at Python/import.c:2002
#34 0xadf25783 in PyImport_ImportModuleLevel (name=0xaba0ea84 "maya.app.startup.basic", globals=0xaba01c64, locals=0xaba01c64, fromlist=0xadf77dc0, level=-1) at Python/import.c:2066
#35 0xadf052a4 in builtin___import__ (self=0x0, args=0xab9e2144, kwds=0x0) at Python/bltinmodule.c:47
#36 0xadebef1a in PyCFunction_Call (func=0xaba20e6c, arg=0xab9e2144, kw=0x0) at Objects/methodobject.c:77
#37 0xade89587 in PyObject_Call (func=0xbfd47b44, arg=0xab9e2144, kw=0x0) at Objects/abstract.c:1860
#38 0xadf05a5b in PyEval_CallObjectWithKeywords (func=0xaba20e6c, arg=0xab9e2144, kw=0x0) at Python/ceval.c:3433
#39 0xadf08121 in PyEval_EvalFrameEx (f=0x8358744, throwflag=0) at Python/ceval.c:2063
#40 0xadf0d8d3 in PyEval_EvalCodeEx (co=0xab9f9800, globals=0xaba01c64, locals=0xaba01c64, args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:2831
#41 0xadf0d945 in PyEval_EvalCode (co=0xab9f9800, globals=0xaba01c64, locals=0xaba01c64) at Python/ceval.c:494
#42 0xadf2205b in PyImport_ExecCodeModuleEx (name=0xbfd4e287 "maya.app.startup.batch", co=0xab9f9800, pathname=0xbfd4c1ab "/usr/lib/python2.5/site-packages/maya/app/startup/batch.pyc")
    at Python/import.c:669
#43 0xadf243b6 in load_source_module (name=0xbfd4e287 "maya.app.startup.batch", pathname=0xbfd4c1ab "/usr/lib/python2.5/site-packages/maya/app/startup/batch.pyc", fp=0x83585d0) at Python/import.c:953
#44 0xadf24a40 in import_submodule (mod=0xaba1859c, subname=0xbfd4e298 "batch", fullname=0xbfd4e287 "maya.app.startup.batch") at Python/import.c:2394
#45 0xadf24f18 in load_next (mod=0xaba1859c, altmod=0xaba1859c, p_name=<value optimized out>, buf=0xbfd4e287 "maya.app.startup.batch", p_buflen=0xbfd4f288) at Python/import.c:2214
#46 0xadf2514a in import_module_level (name=0x0, globals=<value optimized out>, locals=<value optimized out>, fromlist=0xaba25cac, level=<value optimized out>) at Python/import.c:2002
#47 0xadf25783 in PyImport_ImportModuleLevel (name=0xaba0ea54 "maya.app.startup.batch", globals=0xaba01b54, locals=0xaba01b54, fromlist=0xaba25cac, level=-1) at Python/import.c:2066
---Type <return> to continue, or q <return> to quit---
#48 0xadf052a4 in builtin___import__ (self=0x0, args=0xab9dc7fc, kwds=0x0) at Python/bltinmodule.c:47
#49 0xadebef1a in PyCFunction_Call (func=0xaba20e6c, arg=0xab9dc7fc, kw=0x0) at Objects/methodobject.c:77
#50 0xade89587 in PyObject_Call (func=0xbfd47b44, arg=0xab9dc7fc, kw=0x0) at Objects/abstract.c:1860
#51 0xade8b800 in PyObject_CallFunctionObjArgs (callable=0xaba20e6c) at Objects/abstract.c:2090
#52 0xadf258d7 in PyImport_Import (module_name=0xaba0ea40) at Python/import.c:2570
#53 0xadf25ab5 in PyImport_ImportModule (name=0x822c5e9 "maya.app.startup.batch") at Python/import.c:1966
#54 0xb1be91d3 in TpythonModule::import () from /usr/autodesk/maya2008/lib/libCommandEngine.so
#55 0xb338f2b7 in TlibModeApp::initBatch () from /usr/autodesk/maya2008/lib/libShared.so
#56 0xaefc6baa in Tapplication::start () from /usr/autodesk/maya2008/lib/../lib/libExtensionLayer.so
#57 0xb33901c2 in libmain () from /usr/autodesk/maya2008/lib/libShared.so
#58 0x080c9310 in MLibrary::initialize ()
#59 0x080c93bf in MLibrary::initialize ()
#60 0x0808ebb0 in MayaApi::MayaApi ()
#61 0x08090d9f in MayaApi::open_api ()
#62 0x08063f1e in MayaToEggConverter::open_api ()
#63 0x0805a588 in MayaToEgg::run ()
#64 0x0805e082 in main ()

:smiley: :open_mouth: :smiley: :open_mouth: :smiley: :open_mouth: :smiley: :open_mouth:

on a whim I tried using maya2egg2008-wrapped instead of maya2egg2008.

here’s what worked:

export MAYA_LOCATION=/usr/autodesk/maya
export LD_LIBRARY_PATH=/usr/autodesk/maya/lib

maya2egg2008-wrapped -o awesome.egg unbelievable.mb

This still throws python import errors, but the conversion is successful. To get rid of those errors, add

export PYTHONHOME=/usr/autodesk/maya

as well.

so, do those just need to get set in the wrapper?

so by the way the first thing we’re going to be making, 99% sure with Panda, is a multiuser environment for experimental audio. it’s a collaboration between SAIC and Locus Sonus (Ecole des Beaux Arts / Aix-en-Provence + Villa Arson / Nice). the workshop’ll be happening in january. you can see some pix from last year’s workshop, which was Panda + PureData + WiiMote + HMD + stereoscopic projection, and the previous year’s, which was OpenGL Performer + Ascension Flock + SuperCollider + Pd, at www.transatlab.net. I’ll post more as it develops but right now i’m just super excited. thanks much.

Awesome! I’ve put your changes in mayaWrapper.cxx – can you run a “cvs update” on that file and try again, to see if I did it right?

pandatool/src/mayaprogs/mayaWrapper.cxx: In function ‘int main(int, char**)’:
pandatool/src/mayaprogs/mayaWrapper.cxx:162: error: incompatible types in assign                                                         ment of ‘char*’ to ‘char [1024]’
pandatool/src/mayaprogs/mayaWrapper.cxx:182: warning: deprecated conversion from                                                          string constant to ‘char*’

which is from

 loc=getenv("MAYA_LOCATION");

perhaps have to use strcpy() instead. On Linux, I don’t think the MAYA_LOCATION variable is actually set, normally. For anything before Maya 8 I think you can assume MAYA_LOCATION is /usr/aw/maya, and for 8 and above it’s /usr/autodesk/maya, unless you have different maya versions installed and then you’d set that variable manually.

here’s a suggested patch:

  if (getenv("MAYA_LOCATION") == NULL)
  {
    printf("$MAYA_LOCATION is not set - using default /usr/autodesk/maya\n");
    strcpy (loc,"/usr/autodesk/maya");
  }
  else
  {
  	strcpy(loc,getenv("MAYA_LOCATION"));
  }

It works!

does need the modifications to makepanda.py, mayaToegg.cxx and mayaCopy.cxx to not use pystub.

Ah, that’s my mistake. Sorry about that. Just fixed it at CVS.

I would rather not hardcode that path into mayaWrapper, since it is built to be able to switch between maya versions easily – e.g. you can have maya 2008 and 2007 installed at the same time and use maya2egg2007 and maya2egg2008 without them using the wrong version of maya. But yes, with reading out MAYA_LOCATION that kind of defeats that purpose as well (but you’re still able to configure what version to use by setting the path.). I’ll create a better solution later, when I have more time.

Also, if I entirely remove pystub from the maya exporter, I’m afraid I might break something on Windows. Maybe David can comment on that? Does it really need to depend on pystub?

Thanks a lot for helping to test this, Ben! It’s greatly appreciated.

PS. Your code forgot to delete the pointer after you were done with it.

pystub is not necessary so long as Maya provides a version of Python that satisfies all of the references within libpanda.dll et al.

I’m not sure how much of a guarantee we have that this will be true, though. Certainly version of Maya prior to Maya 2008 did not provide any version of Python at all.

David

Hmm. Do you guys at the VR Studio compile Maya on Linux? If so, how did you solve the problems, or are you using Maya versions older than 2008? If the latter, we can maybe just solve this with a preprocessor definition, e.g. (pseudo)

#if MAYAVERSION >= 2008
  #define MAYA_DONT_USE_PYSTUB
#endif
...
int main(...) {
#ifndef MAYA_DONT_USE_PYSTUB
  pystub();
#endif
  ...
}

Though that might be a bit clumsy, it would work.

In fact, we don’t compile maya2egg for Linux, so we’ve never run into this problem before.

I dunno, maybe we could just for now use #if $[WINDOWS_PLATFORM] as the switch, at least until we stop supporting versions of Maya prior to 2008.

David