mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-06 14:13:28 -06:00
meson: add build config and its options
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
54aadf0169
commit
f41deedd52
2
.gitignore
vendored
2
.gitignore
vendored
@ -9,5 +9,3 @@
|
||||
/MANIFEST
|
||||
|
||||
/data/gschemas.compiled
|
||||
|
||||
/virtinst/build.cfg
|
||||
|
@ -1,2 +1,5 @@
|
||||
option('update-icon-cache', type: 'boolean', value: true, description: 'whether to run gtk-update-icon-cache')
|
||||
option('compile-schemas', type: 'boolean', value: true, description: 'whether to compile gsettings schemas')
|
||||
|
||||
option('default-graphics', type: 'combo', choices: ['spice', 'vnc'], value: 'spice', description: 'default graphics type')
|
||||
option('default-hvs', type: 'array', choices: ['qemu', 'xen', 'lxc', 'bhyve', 'vz'], description: 'list of hypervisors shown in "Open Connection" wizard')
|
||||
|
86
setup.py
86
setup.py
@ -29,26 +29,6 @@ except ImportError:
|
||||
BUILD_COMMAND_CLASS = distutils.command.build.build # pylint: disable=c-extension-no-member
|
||||
|
||||
|
||||
SYSPREFIX = sysconfig.get_config_var("prefix")
|
||||
|
||||
|
||||
def _import_buildconfig():
|
||||
# A bit of crazyness to import the buildconfig file without importing
|
||||
# the rest of virtinst, so the build process doesn't require all the
|
||||
# runtime deps to be installed
|
||||
spec = importlib.util.spec_from_file_location(
|
||||
'buildconfig', 'virtinst/buildconfig.py')
|
||||
buildconfig = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(buildconfig)
|
||||
if "libvirt" in sys.modules:
|
||||
raise RuntimeError("Found libvirt in sys.modules. setup.py should "
|
||||
"not import virtinst.")
|
||||
return buildconfig.BuildConfig
|
||||
|
||||
|
||||
BuildConfig = _import_buildconfig()
|
||||
|
||||
|
||||
class my_egg_info(setuptools.command.install_egg_info.install_egg_info):
|
||||
"""
|
||||
Disable egg_info installation, seems pointless for a non-library
|
||||
@ -57,30 +37,6 @@ class my_egg_info(setuptools.command.install_egg_info.install_egg_info):
|
||||
pass
|
||||
|
||||
|
||||
class my_install(setuptools.command.install.install):
|
||||
"""
|
||||
Error if we weren't 'configure'd with the correct install prefix
|
||||
"""
|
||||
def finalize_options(self):
|
||||
# pylint: disable=access-member-before-definition
|
||||
if self.prefix is None:
|
||||
if BuildConfig.prefix != SYSPREFIX:
|
||||
print("Using configured prefix=%s instead of SYSPREFIX=%s" % (
|
||||
BuildConfig.prefix, SYSPREFIX))
|
||||
self.prefix = BuildConfig.prefix
|
||||
else:
|
||||
print("Using SYSPREFIX=%s" % SYSPREFIX)
|
||||
self.prefix = SYSPREFIX
|
||||
|
||||
elif self.prefix != BuildConfig.prefix:
|
||||
print("Install prefix=%s doesn't match configure prefix=%s\n"
|
||||
"Pass matching --prefix to 'setup.py configure'" %
|
||||
(self.prefix, BuildConfig.prefix))
|
||||
sys.exit(1)
|
||||
|
||||
super().finalize_options()
|
||||
|
||||
|
||||
###################
|
||||
# Custom commands #
|
||||
###################
|
||||
@ -107,40 +63,6 @@ class my_rpm(setuptools.Command):
|
||||
subprocess.check_call(cmd)
|
||||
|
||||
|
||||
class configure(setuptools.Command):
|
||||
user_options = [
|
||||
("prefix=", None, "installation prefix"),
|
||||
("default-graphics=", None,
|
||||
"Default graphics type (spice or vnc) (default=spice)"),
|
||||
("default-hvs=", None,
|
||||
"Comma separated list of hypervisors shown in 'Open Connection' "
|
||||
"wizard. (default=all hvs)"),
|
||||
|
||||
]
|
||||
description = "Configure the build, similar to ./configure"
|
||||
|
||||
def finalize_options(self):
|
||||
pass
|
||||
|
||||
def initialize_options(self):
|
||||
self.prefix = SYSPREFIX
|
||||
self.default_graphics = None
|
||||
self.default_hvs = None
|
||||
|
||||
|
||||
def run(self):
|
||||
template = ""
|
||||
template += "[config]\n"
|
||||
template += "prefix = %s\n" % self.prefix
|
||||
if self.default_graphics is not None:
|
||||
template += "default_graphics = %s\n" % self.default_graphics
|
||||
if self.default_hvs is not None:
|
||||
template += "default_hvs = %s\n" % self.default_hvs
|
||||
|
||||
open(BuildConfig.cfgpath, "w").write(template)
|
||||
print("Generated %s" % BuildConfig.cfgpath)
|
||||
|
||||
|
||||
class TestCommand(setuptools.Command):
|
||||
user_options = []
|
||||
description = "DEPRECATED: Use `pytest`. See CONTRIBUTING.md"
|
||||
@ -229,20 +151,12 @@ setuptools.setup(
|
||||
url="https://virt-manager.org",
|
||||
license="GPLv2+",
|
||||
|
||||
data_files=[
|
||||
("share/virt-manager/virtinst",
|
||||
glob.glob("virtinst/build.cfg")),
|
||||
],
|
||||
|
||||
# stop setuptools 61+ thinking we want to include everything automatically
|
||||
py_modules=[],
|
||||
|
||||
cmdclass={
|
||||
'install': my_install,
|
||||
'install_egg_info': my_egg_info,
|
||||
|
||||
'configure': configure,
|
||||
|
||||
'pylint': CheckPylint,
|
||||
'rpm': my_rpm,
|
||||
'test': TestCommand,
|
||||
|
5
virtinst/build.cfg.in
Normal file
5
virtinst/build.cfg.in
Normal file
@ -0,0 +1,5 @@
|
||||
[config]
|
||||
version = @version@
|
||||
prefix = @prefix@
|
||||
default_graphics = @default_graphics@
|
||||
default_hvs = @default_hvs@
|
@ -45,13 +45,10 @@ def _get_param(name, default): # pragma: no cover
|
||||
return default
|
||||
|
||||
|
||||
__version__ = "4.1.0"
|
||||
|
||||
|
||||
class _BuildConfig(object):
|
||||
def __init__(self):
|
||||
self.cfgpath = _cfgpath
|
||||
self.version = __version__
|
||||
self.version = _get_param("version", "")
|
||||
|
||||
self.default_graphics = _get_param("default_graphics", "spice")
|
||||
self.default_hvs = _split_list(_get_param("default_hvs", ""))
|
||||
|
@ -36,3 +36,17 @@ install_data(
|
||||
subdir('devices')
|
||||
subdir('domain')
|
||||
subdir('install')
|
||||
|
||||
conf = configuration_data()
|
||||
conf.set('version', meson.project_version())
|
||||
conf.set('prefix', prefix)
|
||||
conf.set('default_graphics', get_option('default-graphics'))
|
||||
conf.set('default_hvs', ','.join(get_option('default-hvs')))
|
||||
|
||||
configure_file(
|
||||
input: 'build.cfg.in',
|
||||
output: 'build.cfg',
|
||||
configuration: conf,
|
||||
install: true,
|
||||
install_dir: pkgdir / 'virtinst',
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user