Skip to content

Cython sanity check uses PKG_CONFIG_PATH while python.find_installation().dependency() does not #15740

Description

@jorisvandenbossche

Describe the bug

I noticed that building pandas from source in a conda environment with the latest meson 1.11 stopped working (and downgrading just meson to 1.10 made it work), with a ERROR: Compiler cython cannot compile programs. error.

Looking at the logs, it seems that cython is now failing in the sanity check step, because it finds system Python instead of the Python inside the conda environment.

Relevant part of meson-log.txt
Detecting compiler via: `cython -V` -> 0
stdout:
Cython version 3.2.4
-----------
stderr:
Cython version 3.2.4
-----------
Sanity check transpiler command line: cython --fast-fail -o sanity_check_for_cython.c sanity_check_for_cython.pyx -3
Sanity check transpiler stdout:

-----
Sanity check transpiler stderr:

-----
Pkg-config binary missing from cross or native file, or env var undefined.
Trying a default Pkg-config fallback at pkg-config
Found pkg-config: YES (/usr/bin/pkg-config) 0.29.2
Determining dependency 'python3' with pkg-config executable '/usr/bin/pkg-config'
env[PKG_CONFIG_PATH]: 
env[PKG_CONFIG]: /usr/bin/pkg-config
-----------
Called: `/usr/bin/pkg-config --modversion python3` -> 0
stdout:
3.10
-----------
env[PKG_CONFIG_PATH]: 
env[PKG_CONFIG]: /usr/bin/pkg-config
-----------
Called: `/usr/bin/pkg-config --cflags python3` -> 0
stdout:
-I/usr/include/python3.10 -I/usr/include/x86_64-linux-gnu/python3.10
-----------
env[PKG_CONFIG_ALLOW_SYSTEM_LIBS]: 1
env[PKG_CONFIG_PATH]: 
env[PKG_CONFIG]: /usr/bin/pkg-config
-----------
Called: `/usr/bin/pkg-config --libs python3` -> 0
env[PKG_CONFIG_PATH]: 
env[PKG_CONFIG]: /usr/bin/pkg-config
-----------
Called: `/usr/bin/pkg-config --libs python3` -> 0
Run-time dependency python3 found: YES 3.10
checking compilation of transpiled source:
Sanity check compiler command line: /home/joris/scipy/repos/test-meson-cython/.pixi/envs/default/bin/x86_64-conda-linux-gnu-cc -D_FILE_OFFSET_BITS=64 -o sanity_check_for_cython.so sanity_check_for_cython.c -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/joris/scipy/repos/test-meson-cython/.pixi/envs/default/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/joris/scipy/repos/test-meson-cython/.pixi/envs/default/include -D_FILE_OFFSET_BITS=64 -fPIC -I/usr/include/python3.10 -I/usr/include/x86_64-linux-gnu/python3.10 -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,--allow-shlib-undefined -Wl,-rpath,/home/joris/scipy/repos/test-meson-cython/.pixi/envs/default/lib -Wl,-rpath-link,/home/joris/scipy/repos/test-meson-cython/.pixi/envs/default/lib -L/home/joris/scipy/repos/test-meson-cython/.pixi/envs/default/lib -shared -Wl,--allow-shlib-undefined
Sanity check compile stdout:

-----
Sanity check compile stderr:
In file included from /usr/include/python3.10/Python.h:8,
                 from sanity_check_for_cython.c:19:
/usr/include/python3.10/pyconfig.h:3:12: fatal error: x86_64-linux-gnu/python3.10/pyconfig.h: No such file or directory
    3 | #  include <x86_64-linux-gnu/python3.10/pyconfig.h>
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

-----

../meson.build:1:0: ERROR: Compiler cython cannot compile programs.

Things that seem to fix it (but so were not needed for older versions of meson):

  • Explicitly setting PKG_CONFIG_PATH=$CONDA_PREFIX/lib/pkgconfig
  • Installing pkg-config in the local conda environment

To Reproduce

Minimal meson.build file:

project(
  'test-cython',
  ['c', 'cython'],
  version: '0.1.0',
)

py = import('python').find_installation(pure: false)

and then running meson setup . build/ fails with meson 1.11 but works with 1.10, if running this inside a conda env (with the c compiler also getting detected from the conda env)

Expected behavior
That this keeps working as with meson 1.10 (i.e. works out of the box in a conda env without having to set env variables manually)

system parameters

  • Native build
  • Ubuntu 22.04
  • Python 3.13 (but not limited to this version)
  • what meson --version: 1.11.1

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions