mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-21 09:34:12 +03:00
meson: build and install bin wrappers
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
01acaa3836
commit
0f9d89e069
19
meson.build
19
meson.build
@ -8,6 +8,7 @@ python3 = python.find_installation('python3')
|
||||
|
||||
prefix = get_option('prefix')
|
||||
datadir = prefix / get_option('datadir')
|
||||
bindir = prefix / get_option('bindir')
|
||||
pkgdir = datadir / 'virt-manager'
|
||||
|
||||
# figure out if we are building from git
|
||||
@ -21,6 +22,24 @@ subdir('virtinst')
|
||||
subdir('virtManager')
|
||||
subdir('po')
|
||||
|
||||
bin_data = [
|
||||
{'pkgname': 'virtinst', 'filename': 'virtinstall', 'toolname': 'virt-install'},
|
||||
{'pkgname': 'virtinst', 'filename': 'virtclone', 'toolname': 'virt-clone'},
|
||||
{'pkgname': 'virtinst', 'filename': 'virtxml', 'toolname': 'virt-xml'},
|
||||
{'pkgname': 'virtManager', 'filename': 'virtmanager', 'toolname': 'virt-manager'},
|
||||
]
|
||||
|
||||
foreach bin : bin_data
|
||||
custom_target(
|
||||
command: [make_bin_wrapper_prog, pkgdir, bin['pkgname'], bin['filename']],
|
||||
capture: true,
|
||||
output: bin['toolname'],
|
||||
install: true,
|
||||
install_dir: bindir,
|
||||
install_mode: 'rwxr-xr-x',
|
||||
)
|
||||
endforeach
|
||||
|
||||
if git
|
||||
spec_conf = configuration_data({
|
||||
'VERSION': meson.project_version(),
|
||||
|
19
scripts/make_bin_wrapper.py
Normal file
19
scripts/make_bin_wrapper.py
Normal file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("sharepath")
|
||||
parser.add_argument("pkgname")
|
||||
parser.add_argument("filename")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
print(f"""#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
sys.path.insert(0, "{args.sharepath}")
|
||||
from {args.pkgname} import {args.filename}
|
||||
|
||||
{args.filename}.runcli()""")
|
@ -1,4 +1,5 @@
|
||||
scripts = [
|
||||
'make_bin_wrapper.py',
|
||||
'meson_dist.py',
|
||||
]
|
||||
|
||||
|
47
setup.py
47
setup.py
@ -49,44 +49,6 @@ def _import_buildconfig():
|
||||
BuildConfig = _import_buildconfig()
|
||||
|
||||
|
||||
class my_build(BUILD_COMMAND_CLASS):
|
||||
def _make_bin_wrappers(self):
|
||||
template = """#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
sys.path.insert(0, "%(sharepath)s")
|
||||
from %(pkgname)s import %(filename)s
|
||||
|
||||
%(filename)s.runcli()
|
||||
"""
|
||||
if not os.path.exists("build"):
|
||||
os.mkdir("build")
|
||||
sharepath = os.path.join(BuildConfig.prefix, "share", "virt-manager")
|
||||
|
||||
def make_script(pkgname, filename, toolname):
|
||||
assert os.path.exists(pkgname + "/" + filename + ".py")
|
||||
content = template % {
|
||||
"sharepath": sharepath,
|
||||
"pkgname": pkgname,
|
||||
"filename": filename}
|
||||
|
||||
newpath = os.path.abspath(os.path.join("build", toolname))
|
||||
print("Generating %s" % newpath)
|
||||
open(newpath, "w").write(content)
|
||||
|
||||
make_script("virtinst", "virtinstall", "virt-install")
|
||||
make_script("virtinst", "virtclone", "virt-clone")
|
||||
make_script("virtinst", "virtxml", "virt-xml")
|
||||
make_script("virtManager", "virtmanager", "virt-manager")
|
||||
|
||||
|
||||
def run(self):
|
||||
self._make_bin_wrappers()
|
||||
|
||||
super().run()
|
||||
|
||||
|
||||
class my_egg_info(setuptools.command.install_egg_info.install_egg_info):
|
||||
"""
|
||||
Disable egg_info installation, seems pointless for a non-library
|
||||
@ -293,13 +255,6 @@ setuptools.setup(
|
||||
url="https://virt-manager.org",
|
||||
license="GPLv2+",
|
||||
|
||||
# These wrappers are generated in our custom build command
|
||||
scripts=([
|
||||
"build/virt-manager",
|
||||
"build/virt-clone",
|
||||
"build/virt-install",
|
||||
"build/virt-xml"]),
|
||||
|
||||
data_files=[
|
||||
("share/virt-manager/virtinst",
|
||||
glob.glob("virtinst/build.cfg")),
|
||||
@ -309,8 +264,6 @@ setuptools.setup(
|
||||
py_modules=[],
|
||||
|
||||
cmdclass={
|
||||
'build': my_build,
|
||||
|
||||
'install': my_install,
|
||||
'install_egg_info': my_egg_info,
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user