← All tasks
pythonpython-lz4/python-lz4 #200Not a task: already works

Compilation fails when `pkg-config` gives multiple arguments

envgap__python-lz4__python-lz4-200

01 / FAILURE SIGNATURE

As reported upstream

No identifying execution failure has been captured.
Not a benchmark task.
  • The project already builds and runs before the fix, so there is nothing to repair.

02 / ENVIRONMENT RECIPE

Base commit
048390910606d49aef05ee5a412ee0595c6ff6c4
Manifest
setup.py
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

python-lz4/python-lz4 #200 · read the original issue
`setup.py` uses the `pkgconfig` package to query the `pkg-config` database to learn the flags to use for compiling against `liblz4`. The `pkgconfig.cflags()` and `pkgconfig.libs()` functions each return a single string that might represent multiple arguments, which are then being appended to `extra_compile_args` and `extra_link_args` as though they're a single argument, resulting in link failures when the appropriate linker flags include a `-L/path/to/lib/dir`, for instance, in addition to `-llz4`.



At a minimum, this code:

```py

    if liblz4_found:

        extra_link_args.append(pkgconfig_libs('liblz4'))

        if pkgconfig_cflags('liblz4'):

            extra_compile_args.append(pkgconfig_cflags('liblz4'))

```



Should be changed to:

```py

    if liblz4_found:

        extra_link_args.extend(pkgconfig_libs('liblz4').split())

        extra_compile_args.extend(pkgconfig_cflags('liblz4').split())

```



Or, better still, instead of packing everything into `extra_link_args` and `extra_compile_args` using `pkgconfig.libs()` and `pkgconfig.cflags()`, it's more typical to use `pkgconfig.parse()`, which splits it out into separate lists to be passed for the `define_macros`, `include_dirs`, `library_dirs`, and `libraries` keyword arguments to the `Extension` constructor.
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]