I stumble upon this great tool called matrix-commander that I think is the simplest way to programmatically interact with your Matrix server. I’m using these tools in order to send notifications from my server to my matrix room whenever something interesting happens (i.e when my backup is done, or when someone login to my server). It is based on matrix-nio, and only a large single file python. But I found one of the dependencies, libolm, is quite difficult to install (especially in my raspberry pi). They do have a package in pip, but it’s only for python version 2. Here is what I do to build this library from source.
Installation
- Clone the repo,
git clone https://gitlab.matrix.org/matrix-org/olm
- Build the library like the documentation says:
cmake . -Bbuild
cmake --build build
- Go to build directory, and you will find
libolm.so.3.2.6
along with it’s sym link. Copy that to permanent location, like/usr/local/lib
. - Optionally: you could check the content of the build with command
nm -D -C -g libolm.so.3.2.6
, make sure we have olm related function defined. - Now it’s time to build the python binding. Go to python folder (on the root folder of olm). Set
LD_LIBRARY_PATH
to the path of your olm library permanent location, i.e:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
- Install the package by
make DESTDIR=/ install-python3
. Note about DESTDIR, for some reason, in my case, the root directory isn’t included. - You can test this by trying
import olm
in your python.
Debugging
Use this commands to start debuging if something wrong happens:
nm -D -C -g module.so
to list the required function inside an object, and whether it’s present or not.- When installing python package, you could see the shared object output in build directory, find a file called
_libolm.abi3.so
. You can inspect the required module by usingldd module.so
. Make sure the required module are present.