Houdini Engine vs PySide
-
On 25/07/2017 at 15:17, xxxxxxxx wrote:
Hello guys !
Greetings from a new developer on C4D, but definitely not new on Python
I'm currently trying to bring some tools to C4D, through python plugins creation, and including PySide interfaces. Everything seemed fine thanks to Python but a friend of mine just discovered a huge drawback ... Houdini Engine seem unable to load if PySide was imported first !
As far as I could google, there was known issues with other plugins (ie: some users discoverd that disabling the VRay plugin helped to load the engine), and on Maya for example the author disabled PySide imports on Houdini side to prevent errors.
I'm now facing two options :
- launch my apps in another thread / context / python interpreter and communicate with c4d by any mean (RPC calls etc.)
- find a way to pre-load the Houdini Engine -before- importing PySide, since once loaded it won't complain anymore.The second option would be really nice but I can't find a way to just load the engine, the only command I could dump was the "Load Assets ..." triggered by the Pipeline menu : c4d.CallCommand(1032265, 1032265), and it's definitely not what I want since it's opening a file browser.
Any through would be greatly appreciated, I hope there is a decent way to make PySide and Houdini work together !
Thanks in advance, and thanks a lot for all the resources I already found on this forum, it's a great addition to the official API documentation
-
On 26/07/2017 at 09:10, xxxxxxxx wrote:
Hi Tonio,
welcome to the Plugin Café forums
Unfortunately MAXON's SDK Team can't be of much help here. We have no experience with PySide and actually do not support any 3rd party modules.
In a C++ plugin you could at least influence the priority of your plugin (PluginMessage(C4DMSG_PRIORITY)), but that's no option for Python plugins. -
On 26/07/2017 at 11:34, xxxxxxxx wrote:
Hello Andreas, thanks for your answer !
I finally found the culprit, I'm using my own Qt import wrapper to add some abstract layer over PySide vs PyQt, and the default PySide I import is the one coming with Shotgun Desktop since it's available on all the workstations I manage ... but it seems that Houdini is not happy with this version !
I played around and finally found a way to import the PySide module coming with Houdini (15), and now everything seems to work fine.
Steps :
- add Houdini's PySide folder in your PYTHONPATH at startup (ie: in python_init.py), in my case : C:\\Program Files\\Side Effects Software\\Houdini 15.5.632\\python27\\lib\\site-packages-ui-forced
- make sure PySide DLLs are available, since tweaking the PATH didn't work I had to copy these DLLs directly in the Cinema4D folder, next to CINEMA 4D.exeRequired libs list :
- pyside-python2.7.dll
- Qt*.dll (QtCore4, QtGui4, QtOpenGL4 etc.)
- shiboken-python2.7.dll
- zlib1.dllIll make some tests on OSX later but I suppose it will be the same process, hope that the DYLD_LIBRARY_PATH will work this time !
Some hints to see what libs are required by a pyd module and get rid of "DLL cannot be found" errors :
- copy your .pyd and rename it with the .dll extension
- use ldd in a mingw / cygwin / git or whatever unix shell available (ie: ldd QtGui.dll)
- note the list of file names not located in your system folder (ie: C;\Windows\System32)Launch this code snippet in Cinema 4d, with your names list and you'll be able to identify the missing libs:
import ctypes
dlls = ['pyside-python2.7.dll', 'shiboken-python2.7.dll', 'QtGui4.dll', 'python27.dll', 'QtCore4.dll', 'zlib1.dll']
for name in dlls:
try:
ctypes.WinDLL(name)
except Exception as e:
print("{0} failed : {1}".format(name, e))Cheers !
-
On 26/07/2017 at 12:50, xxxxxxxx wrote:
Hi there, just a quick followup after some tests.
Tweaking the PATH definitely won't work, and putting libs in the resource/libs/win64 is also broken, so the root folder is my only option right now.
I saw threads about this issue recommending to load DLLs with the plugin (or link it statically) but examples are for C++ plugins and I don't know how to do it in python. By the way, a standard location in user folders (appdata / application support ...) would be nice since we don't always have administrative privileges on our workstations !
A good news, no tweak needed on OSX, the Houdini Engine there is able to load whatever the PySide version involved.
Thanks
-
On 26/07/2017 at 12:57, xxxxxxxx wrote:
I don't have pyside here but a couple of import good practise inside c4d.
Use https://github.com/NiklasRosenstein/py-localimport (read https://developers.maxon.net/forum/topic/8229/10727_best-practice-for-imports for more informations) when it's possible.
There is an user folder for import C:\Users\UserName\AppData\Roaming\MAXON\CINEMA 4D RXX\library\python\packages\win64
-
On 26/07/2017 at 13:08, xxxxxxxx wrote:
Thanks a lot gr4ph0s !
Sadly, putting libs (dlls) in this folder won't do the trick, DLL load failed I suppose it's only meant to receive python modules.
And yes, I'll have to rewrite my import statements in plugins, but hopefully I'm already using my own routines to dynamically import modules from source path, and my submodules in the main pyp file are just local instances, so nothing remains in sys.modules and everything seems to work as expected when receiving internal messages (RELOADPYTHONPLUGINS, ENDACTIVITY etc.)
-
On 26/07/2017 at 14:01, xxxxxxxx wrote:
Don't know if it can be a solution. But you can installing PySide through pip which seem to be ok.
So my step were:
download https://bootstrap.pypa.io/get-pip.pycd C:\Program Files\MAXON\CINEMA 4D R17\resource\modules\python\Python.win64.framework
run c4d python to get pip so
python.exe get-pip.py
then install PySide
python.exe -m pip install PySide
I have to admit it's not the cleanest way of doing it, but it's working and it's easy to install, and can be easily replicated with a stupid bash for install into other workstation.
Finally keep in mind Pyside is not supported by c4d then you may have weird behavior. Moreover as I know they can't be docked like a GeDialog can be a real part of a c4d UI. So it's sure in term of developpment speed it can be quicker for you to translate code from different DCC but GeDialog/GeUserArea/CustomGui can do everything that PySide does.
-
On 26/07/2017 at 14:20, xxxxxxxx wrote:
Thanks again for spending time on this gr4ph0s, I feel less alone
Unfortunately it's not working here (Win10 / C4D R18.057 / Houdini 15.5.632). While PySide is able to import smoothly, Houdini assets loads after that are still broken : Houdini server failed to start
Nice tip anyway, now I know where is installed the python interpreter, and I prefer managing dependencies with pip rather than duplicating modules in some system wide external folder !
-
On 26/07/2017 at 14:50, xxxxxxxx wrote:
I don't have Hou licence so I can't really test, but does it can be a workaround to install the same PySide version than the one shipped with the Houdini exchange module?
Then I guess you should wait other guys, I know some already did some test with PySide so they should know more than me.
-
On 26/07/2017 at 15:40, xxxxxxxx wrote:
Yes, that's the way I have ended, just importing the PySide module from Houdini and not my dependency folder.
Not a big deal except that I had to copy Qt libs in Cinema 4d root folder and I don't like it, since it requires to have admin rights to do it but hell ... it's working, I can't complain anymore, and I'm pretty aware I'm doing unsupported stuff in there
And sorry about my poor english, hope it was not too hard to understand me !