Skip to content

meson discards the pre-defined environment variable PKG_CONFIG_LIBDIR when finding Python dependency #14461

@lbmeng

Description

@lbmeng

When cross-compiling NumPy against aarch64 from an x86_64 build machine, I invoked meson setup like this:

PKG_CONFIG_LIBDIR=/path/to/host/sysroot/usr/lib/pkgconfig \
    PKG_CONFIG_SYSROOT_DIR=/path/to/host/sysroot \
    PKG_CONFIG_SYSTEM_INCLUDE_PATH=/path/to/host/sysroot/usr/include \
    PKG_CONFIG_SYSTEM_LIBRARY_PATH=/path/to/host/sysroot/usr/lib \
    meson setup build_dir --cross-file=/path/to/my/cross-file.txt

with a cross-file.txt that does NOT have pkg_config_libdir in the [properties] section. I got the following output in the message in the meson-log.txt file:

Found pkg-config: YES (/path/to/build/x86_64-linux/usr/bin/pkg-config) 0.29.2
Determining dependency 'python-3.10' with pkg-config executable '/path/to/build/x86_64-linux/usr/bin/pkg-config'
env[PKG_CONFIG_SYSROOT_DIR]: /path/to/host/sysroot/sysroot
env[PKG_CONFIG_SYSTEM_LIBRARY_PATH]: /path/to/host/sysroot/usr/lib
env[PKG_CONFIG_SYSTEM_INCLUDE_PATH]: /path/to/host/sysroot/usr/include
env[PKG_CONFIG_LIBDIR]: /usr/lib/pkgconfig
env[PKG_CONFIG_PATH]:
env[PKG_CONFIG]: /path/to/build/x86_64-linux/usr/bin/pkg-config
-----------
Called: `/path/to/build/x86_64-linux/usr/bin/pkg-config --modversion python-3.10` -> 1
stderr:
Package python-3.10 was not found in the pkg-config search path.
Perhaps you should add the directory containing `python-3.10.pc'
to the PKG_CONFIG_PATH environment variable
No package 'python-3.10' found
-----------
"python-3.10" could not be found in LIBPC, this is likely due to a relocated python installation
Searching for 'python-3.10' via fallback pkgconfig lookup in default paths

-----------

This will add "-I/usr/include/python3.10 -I/path/to/build/x86_64-linux/usr/include/python3.10" when compiling NumPy sources, which is apparently wrong.

After I added pkg_config_libdir in the [properties] section like below:

[properties]
pkg_config_libdir = '/path/to/host/sysroot/usr/lib/pkgconfig'

Then I got the following in the meson log:

env[PKG_CONFIG_LIBDIR]: /path/to/host/sysroot/usr/lib/pkgconfig
env[PKG_CONFIG]: /path/to/build/x86_64-linux/usr/bin/pkg-config
-----------
Called: `/path/to/build/x86_64-linux/usr/bin/pkg-config --modversion python-3.10` -> 0
stdout:
3.10
-----------

Is this behavior by design?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions