diff options
author | Cole Robinson <crobinso@redhat.com> | 2014-03-22 19:08:26 -0400 |
---|---|---|
committer | Cole Robinson <crobinso@redhat.com> | 2014-03-25 13:37:02 -0400 |
commit | cac45e1b1c0d92d6aba4133b2c95d0798c57c098 (patch) | |
tree | 335205eb18dec6dade19bfa2f2b41a9c3a7fa747 | |
parent | 61529f54d2d19fe2ddad7dc5fe6ae3a7b8300eed (diff) | |
download | libvirt-python-cac45e1b1c0d92d6aba4133b2c95d0798c57c098.tar.gz |
setup.py: Move module list building to its own function
Makes it a bit more clear what all that code is used for, rather than
intermixing it with function definitions.
Besides the comment additions, this is a no-op and just reindents the
block, into a function.
-rwxr-xr-x | setup.py | 97 |
1 files changed, 57 insertions, 40 deletions
@@ -72,49 +72,59 @@ def get_api_xml_files(): return (libvirt_api, libvirt_qemu_api, libvirt_lxc_api) -ldflags = get_pkgconfig_data(["--libs-only-L"], "libvirt", False) -cflags = get_pkgconfig_data(["--cflags"], "libvirt", False) - -c_modules = [] -py_modules = [] - -module = Extension('libvirtmod', - sources = ['libvirt-override.c', 'build/libvirt.c', 'typewrappers.c', 'libvirt-utils.c'], - libraries = [ "virt" ], - include_dirs = [ "." ]) -if cflags != "": - module.extra_compile_args.append(cflags) -if ldflags != "": - module.extra_link_args.append(ldflags) - -c_modules.append(module) -py_modules.append("libvirt") - -moduleqemu = Extension('libvirtmod_qemu', - sources = ['libvirt-qemu-override.c', 'build/libvirt-qemu.c', 'typewrappers.c', 'libvirt-utils.c'], - libraries = [ "virt-qemu" ], +def get_module_lists(): + """ + Determine which modules we are actually building, and all their + required config + """ + c_modules = [] + py_modules = [] + ldflags = get_pkgconfig_data(["--libs-only-L"], "libvirt", False) + cflags = get_pkgconfig_data(["--cflags"], "libvirt", False) + + module = Extension('libvirtmod', + sources = ['libvirt-override.c', 'build/libvirt.c', 'typewrappers.c', 'libvirt-utils.c'], + libraries = [ "virt" ], include_dirs = [ "." ]) -if cflags != "": - moduleqemu.extra_compile_args.append(cflags) -if ldflags != "": - moduleqemu.extra_link_args.append(ldflags) - -c_modules.append(moduleqemu) -py_modules.append("libvirt_qemu") - -if have_libvirt_lxc: - modulelxc = Extension('libvirtmod_lxc', - sources = ['libvirt-lxc-override.c', 'build/libvirt-lxc.c', 'typewrappers.c', 'libvirt-utils.c'], - libraries = [ "virt-lxc" ], - include_dirs = [ "." ]) if cflags != "": - modulelxc.extra_compile_args.append(cflags) + module.extra_compile_args.append(cflags) if ldflags != "": - modulelxc.extra_link_args.append(ldflags) + module.extra_link_args.append(ldflags) - c_modules.append(modulelxc) - py_modules.append("libvirt_lxc") + c_modules.append(module) + py_modules.append("libvirt") + moduleqemu = Extension('libvirtmod_qemu', + sources = ['libvirt-qemu-override.c', 'build/libvirt-qemu.c', 'typewrappers.c', 'libvirt-utils.c'], + libraries = [ "virt-qemu" ], + include_dirs = [ "." ]) + if cflags != "": + moduleqemu.extra_compile_args.append(cflags) + if ldflags != "": + moduleqemu.extra_link_args.append(ldflags) + + c_modules.append(moduleqemu) + py_modules.append("libvirt_qemu") + + if have_libvirt_lxc: + modulelxc = Extension('libvirtmod_lxc', + sources = ['libvirt-lxc-override.c', 'build/libvirt-lxc.c', 'typewrappers.c', 'libvirt-utils.c'], + libraries = [ "virt-lxc" ], + include_dirs = [ "." ]) + if cflags != "": + modulelxc.extra_compile_args.append(cflags) + if ldflags != "": + modulelxc.extra_link_args.append(ldflags) + + c_modules.append(modulelxc) + py_modules.append("libvirt_lxc") + + return c_modules, py_modules + + +################### +# Custom commands # +################### class my_build(build): @@ -281,14 +291,21 @@ class my_clean(clean): if os.path.exists("build"): remove_tree("build") + +################## +# Invoke setup() # +################## + +_c_modules, _py_modules = get_module_lists() + setup(name = 'libvirt-python', version = '1.2.3', url = 'http://www.libvirt.org', maintainer = 'Libvirt Maintainers', maintainer_email = 'libvir-list@redhat.com', description = 'The libvirt virtualization API', - ext_modules = c_modules, - py_modules = py_modules, + ext_modules = _c_modules, + py_modules = _py_modules, package_dir = { '': 'build' }, |