I manually compiled python-openzwave to work with C++ library.
I would like to use it as Kodi addon (OpenELEC running on Pi 3), so can not use standard installation.
I've compiled everything, downloaded missing six
and louie
libs, and now try to run hello_world.py
.
My current dirs structure is the following:
- root
- bin
- .lib
- config
Alarm.o
...
libopenzwave.a
libopenzwave.so
libopenzwave.so.1.4
...
- libopenzwave
driver.pxd
group.pxd
...
- louie
__init__.py
dispatcher.py
...
- openzwave
__init__.py
command.py
...
six.py
hello_world.py
But when I run hello_world.py, I get the following error -
Traceback (most recent call last):
File "hello_world.py", line 40, in <module>
from openzwave.controller import ZWaveController
File "/storage/.kodi/addons/service.multimedia.open-zwave/openzwave/controller.py", line 34, in <module>
from libopenzwave import PyStatDriver, PyControllerState
ImportError: No module named libopenzwave
If I move libopenzwave.a
and libopenzwave.so
to root folder, then I get the following error:
Traceback (most recent call last):
File "hello_world.py", line 40, in <module>
from openzwave.controller import ZWaveController
File "/storage/.kodi/addons/service.multimedia.open-zwave/openzwave/controller.py", line 34, in <module>
from libopenzwave import PyStatDriver, PyControllerState
ImportError: dynamic module does not define init function (initlibopenzwave)
What is wrong with my setup?
In general the steps required consist of calls to
make build
which handles building the.cpp
files for openzwave and downloading all dependencies (includingCython
); andmake install
which runs thesetup-api
,setup-lib.py
(this setup script also creates theC++
Python extention for openzwave),setup-web.py
andsetup-manager.py
.Since you cannot run
make install
as you specified and are instead using the archive they provide, the only other options for creating the python extention, after building the openzwave library withmake build
, is generating the.so
files for it without installing to standard locations.Building the
.so
for the cython extention in the same folder as theCython
scripts is done by running:This should create a shared library in
src-lib
namedlibopenzwave.so
(it is different from thelibopenzwave.so
contained in thebin/
directory) which contains all the functionality specified in the extention module. You could try adding that to thelibopenzwave
folder.If you pass special compiler flags during
make build
for building the openzwave library you should specify the same ones when executing thesetup-lib.py
script. This can be done by specifying theCFLAGS
before executing it (as specified here) or else you might have issues likeerror adding symbols: File in wrong format
.