You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would you please care to explain how to install the python bindings, I already built the code and I don't know how to make this library available to python. Thank you.
Thank you for the quick response, so I'm using ubuntu 22.04 and I installed a package called virtnbdbackup: https://github.com/abbbi/virtnbdbackup which creates full backups for running virtual machines. The virtnbdbackup package has a "python3-libnbd" dependency, unfortunately the "python3-libnbd" package provided by ubuntu is an old version "1.10.5-1". So I downloaded the latest tarball https://download.libguestfs.org/libnbd/1.16-stable/libnbd-1.16.3.tar.gz. I followed the instructions to build it:
./configure
make
make check
It built the code without any errors, the problem is that I don't know how to integrate the python library that was built into the ubuntu's python packages. Since you are the author I was hoping that maybe you could guide me in the right direction.
One way to use libnbd & python is to use the ./run script in the directory after you have built the package. You do not need to install it, in fact, installing it is a bad idea. Just do:
/path/to/libnbd/run yourprogram
which will set up some PYTHON* and LD_LIBRARY_PATH environment variables so that the version from the build directory is used. It's best to examine the ./run script to see what it does as it is quite simple.
Another way would be to use a Python virtualenv, but TBH I'm not very familiar with how that would work with the libnbd bindings. We might be able to add support for building a venv possibly. (@nirs any ideas??)
Another way would be to use a Python virtualenv, but TBH I'm not very familiar with how that would work with the libnbd bindings. We might be able to add support for building a venv possibly. (@nirs any ideas??)
I tested the basic steps and they work. But the venv does not isolate from
libnbd.so dependencies, so it may break because of old libraries on the host.
Unfortunately a docker container is not an option for this project, however the solution you suggested about running the program this way kind of works:
/path/to/libnbd/run yourprogram
The above solution tries to run virtnbdbackup but then it throws the following error:
File "/home/addc/libnbd-1.16.3/python/nbd.py", line 34, in <module> import libnbdmod ModuleNotFoundError: No module named 'libnbdmod'
Then I checked the libnbd python directory and the libnbdmod.py is missing, however there is a libnbdmod.c, it looks like the libnbdmod.py is not being generated at built time.
File "/home/addc/libnbd-1.16.3/python/nbd.py", line 34, in <module> import libnbdmod ModuleNotFoundError: No module named 'libnbdmod'
Then I checked the libnbd python directory and the libnbdmod.py is missing, however there is a libnbdmod.c, it looks like the libnbdmod.py is not being generated at built time.
There should exist python/.libs/libnbdmod.cpython-312-x86_64-linux-gnu.so (possibly with a slightly different name). This is libnbdmod — this module is written in C, not Python. ./run adds python/.libs to PYTHONPATH so the library is picked up.
Activity
rwmjones commentedon Aug 17, 2023
So you probably want to know first of all that this isn't the main libnbd repo, that's: https://gitlab.com/nbdkit/libnbd
But in answer to your question, can you give a bit more information like .. what system you're using, what you've tried, and that sort of thing?
ctorres-addc commentedon Aug 17, 2023
Thank you for the quick response, so I'm using ubuntu 22.04 and I installed a package called virtnbdbackup: https://github.com/abbbi/virtnbdbackup which creates full backups for running virtual machines. The virtnbdbackup package has a "python3-libnbd" dependency, unfortunately the "python3-libnbd" package provided by ubuntu is an old version "1.10.5-1". So I downloaded the latest tarball https://download.libguestfs.org/libnbd/1.16-stable/libnbd-1.16.3.tar.gz. I followed the instructions to build it:
./configure
make
make check
It built the code without any errors, the problem is that I don't know how to integrate the python library that was built into the ubuntu's python packages. Since you are the author I was hoping that maybe you could guide me in the right direction.
Thank you.
rwmjones commentedon Aug 17, 2023
One way to use libnbd & python is to use the
./runscript in the directory after you have built the package. You do not need to install it, in fact, installing it is a bad idea. Just do:which will set up some
PYTHON*andLD_LIBRARY_PATHenvironment variables so that the version from the build directory is used. It's best to examine the./runscript to see what it does as it is quite simple.Another way would be to use a Python virtualenv, but TBH I'm not very familiar with how that would work with the libnbd bindings. We might be able to add support for building a venv possibly. (@nirs any ideas??)
ctorres-addc commentedon Aug 17, 2023
Thank you.
nirs commentedon Aug 18, 2023
There is a script for creating venv here:
https://github.com/abbbi/virtnbdbackup/blob/master/venv/create.sh
I tested the basic steps and they work. But the venv does not isolate from
libnbd.so dependencies, so it may break because of old libraries on the host.
I think a better way would be to install virtnbdbackup in a container:
https://github.com/abbbi/virtnbdbackup/tree/master/docker
ctorres-addc commentedon Aug 18, 2023
Unfortunately a docker container is not an option for this project, however the solution you suggested about running the program this way kind of works:
/path/to/libnbd/run yourprogramThe above solution tries to run virtnbdbackup but then it throws the following error:
File "/home/addc/libnbd-1.16.3/python/nbd.py", line 34, in <module> import libnbdmod ModuleNotFoundError: No module named 'libnbdmod'Then I checked the libnbd python directory and the libnbdmod.py is missing, however there is a libnbdmod.c, it looks like the libnbdmod.py is not being generated at built time.
nirs commentedon Aug 18, 2023
@ctorres-addc did you check the script for creating venv?
https://github.com/abbbi/virtnbdbackup/blob/master/venv/create.sh
rwmjones commentedon Aug 18, 2023
There should exist
python/.libs/libnbdmod.cpython-312-x86_64-linux-gnu.so(possibly with a slightly different name). This is libnbdmod — this module is written in C, not Python../runaddspython/.libstoPYTHONPATHso the library is picked up.rwmjones commentedon Aug 18, 2023
To be clear there is never any file called
libnbdmod.pyctorres-addc commentedon Aug 18, 2023
F

or some reason
python/.libsis missing. Do you have any idea why this might be?rwmjones commentedon Aug 18, 2023
It doesn't look like anything was built in the
pythondirectory.Did it detect Python during the
./configurestep and did it build without errors?What happens if you do
make -C python check?ctorres-addc commentedon Aug 21, 2023
Hello, this is what I get when I run
./configure:configure.log
and this is what I get when I run

make -C python check:rwmjones commentedon Aug 21, 2023
Python wasn't configured. You need to install
libpython3-dev(or it might bepython3-dev)rwmjones commentedon Aug 21, 2023
Or install all the build dependencies listed here: https://salsa.debian.org/debian/libnbd/-/blob/debian/master/debian/control
ocaml: Release runtime lock around call to nbd_close
ctorres-addc commentedon Aug 30, 2023
Thank you for the support and the quick responses, I solved the issue by using Debian 12 instead of Ubuntu 22.04 and installing this package https://packages.debian.org/bookworm/virtnbdbackup.