Can you add external python libraries/modules to HDAs?

   4706   7   2
User Avatar
Member
4491 posts
Joined: Feb. 2012
Offline
If you need a Python library that's not available in Houdini, can you add it to your HDA and use it in that HDA?

I haven't done this but need it for a few small python libraries that are compatible with the Python version that comes with Houdini.

Anyone have done this before?
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
User Avatar
Member
23 posts
Joined: Sept. 2015
Offline
Hi,

I've done that already with the “external files” of an HDA, you can store whatever you want in here … and you can import a python code from there using the imp module. (https://docs.python.org/2/library/imp.html) [docs.python.org]

The question is do you really want to do that ? why not just put these libraries in the PYTHON_PATH of your houdini ? like that they will be available in all HDA or whatever python scripts you'll need to run
http://cgtoolbox.com/ [cgtoolbox.com] Houdini tools and scripts for free ! :)
User Avatar
Member
453 posts
Joined: Feb. 2013
Offline
GuillaumeJ
The question is do you really want to do that ? why not just put these libraries in the PYTHON_PATH of your houdini ? like that they will be available in all HDA or whatever python scripts you'll need to run

I don't quite understand this. This only works on a local machine, right?
The point of putting the Python library into the HDA is to make the HDA usable on other machines and possibly future-proof it a bit, right?
User Avatar
Member
23 posts
Joined: Sept. 2015
Offline
It really depends on your needs. If it's for a medium / large studio you could have a sharable PYTHON_PATH folder across the studio.
Or you can have a system which deploy these modules to you user machines when needed.

If it is an otl you want to share on internet or to another users not related to the same project / studio, yes you'll need to embedded these python modules with the otl.
http://cgtoolbox.com/ [cgtoolbox.com] Houdini tools and scripts for free ! :)
User Avatar
Member
4491 posts
Joined: Feb. 2012
Offline
Thanks guys, yeah DASD is right. I am trying to embed a python module so it becomes self sufficient, distributable, especially in some environments where it's not allowed to install such modules.

So you just add all the files one by one into Extra Sections of your HDA?

Do you guys know what the import syntax will be like? Will it work automatically when you use “import moduleName”?
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
User Avatar
Member
1904 posts
Joined: Nov. 2006
Offline
The toolutils module has a convenience function to create a module based on extra sections in a digital asset: toolutils.createModuleFromSection()

Some kind of docs on it, but not really…

http://www.sidefx.com/docs/houdini15.0/hom/locations#asset_modules [sidefx.com]
http://www.sidefx.com/docs/houdini15.0/hom/hou/HDAModule [sidefx.com]
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
23 posts
Joined: Sept. 2015
Offline
Oh ! thanks graham, didn't know that function
http://cgtoolbox.com/ [cgtoolbox.com] Houdini tools and scripts for free ! :)
User Avatar
Member
4491 posts
Joined: Feb. 2012
Offline
Thanks graham that will come in handy
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
  • Quick Links