Skip to content

hard time installing the python bindings #8

Open

Description

@ctorres-addc

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.

Activity

  1. rwmjones commented on Aug 17, 2023

    @rwmjones
    Member

    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?

  2. ctorres-addc commented on Aug 17, 2023

    @ctorres-addc
    Author

    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.

  3. rwmjones commented on Aug 17, 2023

    @rwmjones
    Member

    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??)

  4. ctorres-addc commented on Aug 17, 2023

    @ctorres-addc
    Author

    Thank you.

  5. nirs commented on Aug 18, 2023

    @nirs
    Contributor

    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??)

    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

  6. ctorres-addc commented on Aug 18, 2023

    @ctorres-addc
    Author

    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.

  7. nirs commented on Aug 18, 2023

    @nirs
    Contributor
  8. rwmjones commented on Aug 18, 2023

    @rwmjones
    Member

    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.

  9. rwmjones commented on Aug 18, 2023

    @rwmjones
    Member

    To be clear there is never any file called libnbdmod.py

  10. ctorres-addc commented on Aug 18, 2023

    @ctorres-addc
    Author

    F
    libs-missing
    or some reason python/.libs is missing. Do you have any idea why this might be?

  11. rwmjones commented on Aug 18, 2023

    @rwmjones
    Member

    It doesn't look like anything was built in the python directory.

    Did it detect Python during the ./configure step and did it build without errors?

    What happens if you do make -C python check ?

  12. ctorres-addc commented on Aug 21, 2023

    @ctorres-addc
    Author

    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 :
    make-c-python-check

  13. rwmjones commented on Aug 21, 2023

    @rwmjones
    Member

    Python wasn't configured. You need to install libpython3-dev (or it might be python3-dev)

  14. rwmjones commented on Aug 21, 2023

    @rwmjones
    Member

    Or install all the build dependencies listed here: https://salsa.debian.org/debian/libnbd/-/blob/debian/master/debian/control

  15. ctorres-addc commented on Aug 30, 2023

    @ctorres-addc
    Author

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions