[Bf-python] Loading shared library in Blender Python

Christopher Barry christopher.r.barry at gmail.com
Thu Jun 18 01:23:23 CEST 2015


On Wed, 17 Jun 2015 16:53:56 +0200
Arnaud Degroote <arnaud.degroote at laas.fr> wrote:

>On 17/Jun - 15:59, Sybren A. Stüvel wrote:
>> Hi Pierrick,
>> 
>> On Wed, Jun 17, 2015 at 03:49:23PM +0200, Pierrick Koch wrote:
>> > I'd like to imort python package from ubuntu distribution into
>> > blender. Their shared object extension is
>> > .cpython-34m-x86_64-linux-gnu.so, while Blender look for
>> > .cpython-34m.so (without "-x86_64-linux-gnu").
>> 
>> How did you gather this knowledge? It helps a lot to see what you're
>> actually doing.
>
>To be more precise, what we try is doing
>
>import numpy
>
>which fails with 
>
>ImportError: cannot import name 'multiarray'
>
>(whole discussion is here :
>https://github.com/morse-simulator/morse/pull/630)
>
>It basically fails because python from Ubuntu is built with multiarch
>option and so the libraries have extension
>cpython-34m-x86_64-linux-gnu.so. It is not the case of the python
>embedded in binary blender.
>
>Of course, it is always possible, in this case, to use the numpy copy
>from blender (but it is not a generic solution), or to hack the
>filesystem (but it is cumbersome for users).
>
>Best regards,

Actually the symlink solution presented in the text you removed on
reply is the typical 'behind the scenes' way this kind of thing usually
gets done by the package manager at install time, using the packages'
postinst script (in debian-derived distributions anyway). 

In a terminal run:

$ ls -la /{usr/,}lib{,64}

on your ubuntu box to see a good example of how prevalent this method
is with system libraries.

also:

$ man update-alternatives

for how this methodology is used also for command aliasing and
prioritizing.

try:

$ update-alternatives --display java

to see how java is configured, and

$ for a in $(update-alternatives --get-selections \
  | awk '{ print $1 }'); do
       update-alternatives --display "$a"; 
       echo;
  done | less

to see how all commands with alternatives are setup.


So, it's really not a filesystem 'hack', it's a convenient and simple
way that works for all programs and libs.

(heh, and i swear i did not pick this fortune either, but it's very
apropos... :)
--
Regards,
Christopher Barry

Random geeky fortune:
Those who do not understand Unix are condemned to reinvent it, poorly.
		-- Henry Spencer, University of Toronto Unix hack



More information about the Bf-python mailing list