Git Product home page Git Product logo

libvirt-python's Introduction

Libvirt Python Binding README
=============================

This package provides a module that permits applications
written in the Python 3.x programming language to call the interface
supplied by the libvirt library, to manage the virtualization
capabilities of recent versions of Linux (and other OSes).
As such, the module exposes Python bindings to to the libvirt.so,
libvirt-qemu.so and libvirt-lxc.so library APIs.

It is written to build against any version of libvirt that
is 0.9.11 or newer.

This code is distributed under the terms of the LGPL version
2 or later.

Requirements
------------

To build the libvirt python binary requires the GCC and pkg-config
tools, and development headers for the libvirt and python libraries.

Building and installing
-----------------------

The module can be built by following the normal python module
build process

  $ python3 -m build

for testing and distributing purposes or it can be installed directly via pip
as

  $ python3 -m pip install .

without explicit building.

In order to test the package, you'll need either tox or at least pytest,
depending on whether you want to test an already installed package in which
case the latter is sufficient or if you wish to test in a virtual
environment you'd need tox. Depending on your preferred setup, you can run the
tests either as

  $ python3 -m pytest

or as

  $ tox

A makefile shim is also provided for your convenience, so that you don't have
to care about the exact operations mentioned above and instead you simply do

  $ make && make check

As of libvirt 1.2.6, it is possible to develop against an uninstalled
libvirt.git checkout, by setting PKG_CONFIG_PATH and LD_LIBRARY_PATH
environment variables to point into that libvirt tree; you can even
automate this by using libvirt's run script:

  /path/to/libvirt/run python3 -m build

Patches for this code should be submitted as merge requests to the
project page on gitlab. See CONTRIBUTING.rst for more information.

libvirt-python's People

Contributors

agx avatar andreabolognani avatar berrange avatar cardoe avatar chuanchangjia avatar crobinso avatar cwize1 avatar dankenigsberg avatar ebblake avatar eskultety avatar izumi777 avatar janotomko avatar jferlan avatar jgulic avatar jirkade avatar jonner avatar luyaohuang avatar markmc avatar nertpinx avatar nirs avatar osier avatar photron avatar phrdina avatar pipo avatar pmhahn avatar ptoscano avatar rwmjones avatar veillard avatar woju avatar zippy2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libvirt-python's Issues

error installing on opensuse leap 15.5

Building wheel for libvirt-python (pyproject.toml) ... error
error: subprocess-exited-with-error

 Building wheel for libvirt-python (pyproject.toml) did not run successfully.
  exit code: 1
  [59 lines of output]
  running bdist_wheel
  running build
  running build_py
  Package libvirt was not found in the pkg-config search path.
  Perhaps you should add the directory containing `libvirt.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'libvirt' found
  Traceback (most recent call last):
    File "/usr/lib/python3.11/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 351, in <module>
      main()
    File "/usr/lib/python3.11/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 333, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3.11/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 249, in build_wheel
      return _build_backend().build_wheel(wheel_directory, config_settings,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/tmp/pip-build-env-l41c65p4/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 434, in build_wheel
      return self._build_with_temp_dir(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/tmp/pip-build-env-l41c65p4/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 419, in _build_with_temp_dir
      self.run_setup()
    File "/tmp/pip-build-env-l41c65p4/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 341, in run_setup
      exec(code, locals())
    File "<string>", line 284, in <module>
    File "/tmp/pip-build-env-l41c65p4/overlay/lib/python3.11/site-packages/setuptools/__init__.py", line 107, in setup
      return distutils.core.setup(**attrs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/tmp/pip-build-env-l41c65p4/overlay/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 185, in setup
      return run_commands(dist)
             ^^^^^^^^^^^^^^^^^^
    File "/tmp/pip-build-env-l41c65p4/overlay/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
      dist.run_commands()
    File "/tmp/pip-build-env-l41c65p4/overlay/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
      self.run_command(cmd)
    File "/tmp/pip-build-env-l41c65p4/overlay/lib/python3.11/site-packages/setuptools/dist.py", line 1233, in run_command
      super().run_command(command)
    File "/tmp/pip-build-env-l41c65p4/overlay/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
      cmd_obj.run()
    File "/tmp/pip-build-env-l41c65p4/normal/lib/python3.11/site-packages/wheel/bdist_wheel.py", line 349, in run
      self.run_command("build")
    File "/tmp/pip-build-env-l41c65p4/overlay/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
      self.distribution.run_command(command)
    File "/tmp/pip-build-env-l41c65p4/overlay/lib/python3.11/site-packages/setuptools/dist.py", line 1233, in run_command
      super().run_command(command)
    File "/tmp/pip-build-env-l41c65p4/overlay/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
      cmd_obj.run()
    File "/tmp/pip-build-env-l41c65p4/overlay/lib/python3.11/site-packages/setuptools/_distutils/command/build.py", line 131, in run
      self.run_command(cmd_name)
    File "/tmp/pip-build-env-l41c65p4/overlay/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
      self.distribution.run_command(command)
    File "/tmp/pip-build-env-l41c65p4/overlay/lib/python3.11/site-packages/setuptools/dist.py", line 1233, in run_command
      super().run_command(command)
    File "/tmp/pip-build-env-l41c65p4/overlay/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
      cmd_obj.run()
    File "<string>", line 166, in run
    File "<string>", line 35, in check_minimum_libvirt_version
    File "/usr/lib64/python3.11/subprocess.py", line 413, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['pkg-config', '--print-errors', '--atleast-version=0.9.11', 'libvirt']' returned non-zero exit status 1.
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for libvirt-python
Failed to build libvirt-python
ERROR: Could not build wheels for libvirt-python, which is required to install pyproject.toml-based projects

nc: unix connect failed

Hi, im running since a few hours into the following issue:

client: MacOS Big Sur: Python3 + python-libvirt / virsh also installed

if im trying to connect to a remote hypervisor i get the following error message

virsh -c qemu+ssh://root@Public_IP/system list --all

libvirtd is listening, i have absolutly no clue whats the issue, any idea ?

error: failed to connect to the hypervisor
error: End of file while reading data: nc: unix connect failed: No such file or directory: Input/output error

error during install python3.9

Hello,

I use a distibution ALMALINUX 9.1 and I have an error when i want to install libvirt-python :

sudo python3.9 -m pip --trusted-host pypi.org --trusted-host files.pythonhosted.org install libvirt-python
Collecting libvirt-python
  Using cached libvirt-python-8.10.0.tar.gz (240 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: libvirt-python
  Building wheel for libvirt-python (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [21 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build/lib.linux-x86_64-3.9
      copying build/libvirt.py -> build/lib.linux-x86_64-3.9
      copying build/libvirt_qemu.py -> build/lib.linux-x86_64-3.9
      copying build/libvirt_lxc.py -> build/lib.linux-x86_64-3.9
      copying build/libvirtaio.py -> build/lib.linux-x86_64-3.9
      running build_ext
      Generated 280 wrapper functions
      Generated 1 wrapper functions
      Generated 1 wrapper functions
      building 'libvirtmod' extension
      creating build/temp.linux-x86_64-3.9
      creating build/temp.linux-x86_64-3.9/build
      gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -DOPENSSL_LOAD_CONF -fwrapv -fno-semantic-interposition -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -IVendor/ -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -IVendor/ -fPIC -I. -I/usr/include/python3.9 -c build/libvirt.c -o build/temp.linux-x86_64-3.9/build/libvirt.o
      build/libvirt.c:3:10: fatal error: Python.h: Aucun fichier ou dossier de ce type
       #include <Python.h>
                ^~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for libvirt-python
  Running setup.py clean for libvirt-python
Failed to build libvirt-python
Installing collected packages: libvirt-python
  Running setup.py install for libvirt-python ... error
  error: subprocess-exited-with-error
  
  × Running setup.py install for libvirt-python did not run successfully.
  │ exit code: 1
  ╰─> [21 lines of output]
      running install
      running build
      running build_py
      creating build/lib.linux-x86_64-3.9
      copying build/libvirt.py -> build/lib.linux-x86_64-3.9
      copying build/libvirt_qemu.py -> build/lib.linux-x86_64-3.9
      copying build/libvirt_lxc.py -> build/lib.linux-x86_64-3.9
      copying build/libvirtaio.py -> build/lib.linux-x86_64-3.9
      running build_ext
      Generated 280 wrapper functions
      Generated 1 wrapper functions
      Generated 1 wrapper functions
      building 'libvirtmod' extension
      creating build/temp.linux-x86_64-3.9
      creating build/temp.linux-x86_64-3.9/build
      gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -DOPENSSL_LOAD_CONF -fwrapv -fno-semantic-interposition -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -IVendor/ -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -IVendor/ -fPIC -I. -I/usr/include/python3.9 -c build/libvirt.c -o build/temp.linux-x86_64-3.9/build/libvirt.o
      build/libvirt.c:3:10: fatal error: Python.h: Aucun fichier ou dossier de ce type
       #include <Python.h>
                ^~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> libvirt-python

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

How to solve this ?

Thanks

pkg-config binary is required to compile libvirt-python

$ pip install libvirt-python
Collecting libvirt-python
Using cached libvirt-python-8.7.0.tar.gz (236 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [1 lines of output]
pkg-config binary is required to compile libvirt-python
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

xml file is missing from examples.

The examples readme says: "The XML files in this directory are examples of the XML format that libvirt expects, and will have to be adapted for your setup." The XML file is missing from the directory

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.