1
0
mirror of https://gitlab.com/libvirt/libvirt-python.git synced 2025-07-22 20:59:34 +03:00

setup: replace distutils.spawn with subprocess

The distutils.spawn method has no compelling benefit over using the
standard python subprocess module.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé
2022-03-22 19:55:40 +00:00
parent 7d14f77224
commit 9d4b183b4e

View File

@ -5,8 +5,6 @@ from distutils.command.build import build
from distutils.command.sdist import sdist from distutils.command.sdist import sdist
from distutils.dir_util import remove_tree from distutils.dir_util import remove_tree
from distutils.util import get_platform from distutils.util import get_platform
from distutils.spawn import spawn
from distutils.errors import DistutilsExecError
import sys import sys
import os import os
@ -42,19 +40,18 @@ def check_pkgcfg():
check_pkgcfg() check_pkgcfg()
def check_minimum_libvirt_version(): def check_minimum_libvirt_version():
spawn(["pkg-config", subprocess.check_call(["pkg-config",
"--print-errors", "--print-errors",
"--atleast-version=%s" % MIN_LIBVIRT, "--atleast-version=%s" % MIN_LIBVIRT,
"libvirt"]) "libvirt"])
def have_libvirt_lxc(): def have_libvirt_lxc():
try: proc = subprocess.run(["pkg-config",
spawn(["pkg-config", "--atleast-version=%s" % MIN_LIBVIRT_LXC,
"--atleast-version=%s" % MIN_LIBVIRT_LXC, "libvirt"])
"libvirt"]) if proc.returncode == 0:
return True return True
except DistutilsExecError: return False
return False
def get_pkgconfig_data(args, mod, required=True): def get_pkgconfig_data(args, mod, required=True):
"""Run pkg-config to and return content associated with it""" """Run pkg-config to and return content associated with it"""
@ -142,10 +139,10 @@ class my_build(build):
check_minimum_libvirt_version() check_minimum_libvirt_version()
apis = get_api_xml_files() apis = get_api_xml_files()
self.spawn([sys.executable, "generator.py", "libvirt", apis[0]]) subprocess.check_call([sys.executable, "generator.py", "libvirt", apis[0]])
self.spawn([sys.executable, "generator.py", "libvirt-qemu", apis[1]]) subprocess.check_call([sys.executable, "generator.py", "libvirt-qemu", apis[1]])
if have_libvirt_lxc(): if have_libvirt_lxc():
self.spawn([sys.executable, "generator.py", "libvirt-lxc", apis[2]]) subprocess.check_call([sys.executable, "generator.py", "libvirt-lxc", apis[2]])
shutil.copy('libvirtaio.py', 'build') shutil.copy('libvirtaio.py', 'build')
build.run(self) build.run(self)
@ -295,7 +292,7 @@ class my_test(Command):
if "LIBVIRT_API_COVERAGE" in os.environ: if "LIBVIRT_API_COVERAGE" in os.environ:
self.spawn([sys.executable, "sanitytest.py", self.build_platlib, apis[0]]) self.spawn([sys.executable, "sanitytest.py", self.build_platlib, apis[0]])
pytest = self.find_pytest_path() pytest = self.find_pytest_path()
self.spawn([sys.executable, pytest]) subprocess.check_call([pytest])
class my_clean(Command): class my_clean(Command):