[libvirt] [python PATCH] setup: Use cflags and ldflags properly

Pavel Hrdina phrdina at redhat.com
Mon Jan 18 14:25:37 UTC 2016


On Mon, Jan 18, 2016 at 03:05:14PM +0100, Jiri Denemark wrote:
> The setup.py script reads cflags and ldflags from pkg-config and uses
> them when compiling/linking C modules. Since both cflags and ldflags may
> include multiple compiler arguments we need to split them rather than
> concatenating them into a single argument.
> 
> Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
> ---
>  setup.py | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/setup.py b/setup.py
> index 9bf583b..6994e75 100755
> --- a/setup.py
> +++ b/setup.py
> @@ -96,9 +96,9 @@ def get_module_lists():
>                         libraries = [ "virt" ],
>                         include_dirs = [ "." ])
>      if cflags != "":
> -        module.extra_compile_args.append(cflags)
> +        module.extra_compile_args.extend(cflags.split())
>      if ldflags != "":
> -        module.extra_link_args.append(ldflags)
> +        module.extra_link_args.extend(ldflags.split())
>  
>      c_modules.append(module)
>      py_modules.append("libvirt")
> -- 
> 2.7.0

This works but only for main module, you've missed moduleqemu and modulelxc.

We could split the string returned from get_pkgconfig_data like this:

ldflags = get_pkgconfig_data(["--libs-only-L"], "libvirt", False).split()

and for each module remove the check for != "" and simply extend the
extra_*_args list.  If the string returned from get_pkgconfig_data is "",
.split() will produce empty array which is safe to pass to extend() function.

Pavel




More information about the libvir-list mailing list