pandas: TRACKER: Getting Started with Meson/Bug Reports

Background

In pandas-dev/pandas#49115, we are adding support for a new build system meson. This build system addresses some of the flaws of the setuptools-based build system, such as race conditions on parallel builds. It is also much simpler and easier to understand, and we’ll be able to clean up a bunch of build related code once it’s merged.

How to build/test with meson

# Create a new conda environment, or update your existing one
conda env create --file=environment.yml
# conda env update --file environment.yml --prune # For updating your existing environment, make sure "pandas-dev" is activated 
pip install oldest-supported-numpy>=0.10 # Needed since pip will not auto pull dependencies in no-build-isolation mode

# This is the build command. 
# On your first run, it'll create the build directory(named builddir here).
# Subsequent builds will re-use it.
pip install . -ve --no-build-isolation --config-settings="builddir=builddir" 

# If you want to debug, pass -Ddebug=true, e.g.
pip install . -ve --no-build-isolation --config-settings builddir="builddir" --config-settings setup-args="-Dbuildtype=debug"

# Test command (same as with pandas built by setuptools)
# e.g.
# Note: If you built pandas in editable mode, you now don't have to rebuild the C extensions every time you change a C/Cython file. It will now be automatically rebuilt on import.
pytest pandas

Timeline

  • Enable meson based builds in the CI( pandas-dev/pandas#49115)
  • Move to using a stable version of meson/meson-python once all fixes have been upstreamed, and released.
  • Update documentation for setting up and building pandas with meson. - Mostly done. The debugging docs need to be updated
  • Remove all setuptools code.

Ideally, meson build support and removal of setuptools should be fully complete by 2.1 (the next minor release).

Known Issues

N/A.

Purpose of this thread

I’ve opened this thread to get some feedback and to track any build issues users might be having with meson.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 17 (17 by maintainers)

Most upvoted comments

After starting again from scratch (removing my local pandas repo and cloning it again as well as creating a new dev environment) I was able to successfully build pandas with meson. The good old “Have you tried turning it off and on again?” did the trick. 😄

You’ll need to remove the build folder I think, and do a clean rebuild.

I don’t think meson tracked when the include directory changed, so didn’t mark the affected files as needing a rebuild.

I ran into this today.

(pandas-dev) fangchenli@Fangchens-MacBook-Pro-2 pandas-fangchenli % pip install -e . --no-build-isolation -v
Using pip 23.1.2 from /Users/fangchenli/mambaforge/envs/pandas-dev/lib/python3.10/site-packages/pip (python 3.10)
Obtaining file:///Users/fangchenli/Workspace/pandas-fangchenli
  Running command Checking if build backend supports build_editable
  Checking if build backend supports build_editable ... done
  Running command Preparing editable metadata (pyproject.toml)
  + meson setup --reconfigure /Users/fangchenli/Workspace/pandas-fangchenli /Users/fangchenli/Workspace/pandas-fangchenli/build/cp310 -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --vsenv --native-file=/Users/fangchenli/Workspace/pandas-fangchenli/build/cp310/meson-python-native-file.ini
  Cleaning... 0 files.
  The Meson build system
  Version: 1.0.1
  Source dir: /Users/fangchenli/Workspace/pandas-fangchenli
  Build dir: /Users/fangchenli/Workspace/pandas-fangchenli/build/cp310
  Build type: native build
  Project name: pandas
  Project version: 2.1.0.dev0+901.g4d217a42f0
  C compiler for the host machine: arm64-apple-darwin20.0.0-clang (clang 14.0.6 "clang version 14.0.6")
  C linker for the host machine: arm64-apple-darwin20.0.0-clang ld64 609
  C++ compiler for the host machine: arm64-apple-darwin20.0.0-clang++ (clang 14.0.6 "clang version 14.0.6")
  C++ linker for the host machine: arm64-apple-darwin20.0.0-clang++ ld64 609
  Cython compiler for the host machine: cython (cython 0.29.34)
  Host machine cpu family: aarch64
  Host machine cpu: aarch64
  Program python found: YES (/Users/fangchenli/mambaforge/envs/pandas-dev/bin/python3.10)
  Build targets in project: 54

  pandas 2.1.0.dev0+901.g4d217a42f0

    User defined options
      Native files: /Users/fangchenli/Workspace/pandas-fangchenli/build/cp310/meson-python-native-file.ini
      buildtype   : release
      b_ndebug    : if-release
      b_vscrt     : md

  Found ninja-1.11.1 at /Users/fangchenli/mambaforge/envs/pandas-dev/bin/ninja
  + /Users/fangchenli/mambaforge/envs/pandas-dev/bin/ninja
  [1/79] Generating pandas/_libs/algos_common_helper_pxi with a custom command
  [2/79] Generating pandas/_libs/hashtable_class_helper_pxi with a custom command
  [3/79] Generating pandas/_libs/algos_take_helper_pxi with a custom command
  [4/79] Generating pandas/_libs/khash_primitive_helper_pxi with a custom command
  [5/79] Generating pandas/_libs/index_class_helper_pxi with a custom command
  [6/79] Generating pandas/_libs/intervaltree_helper_pxi with a custom command
  [7/79] Generating pandas/_libs/sparse_op_helper_pxi with a custom command
  [8/79] Generating pandas/_libs/hashtable_func_helper_pxi with a custom command
  [9/79] Linking target pandas/_libs/arrays.cpython-310-darwin.so
  ld: warning: -pie being ignored. It is only used when linking a main executable
  [10/79] Linking target pandas/_libs/hashing.cpython-310-darwin.so
  ld: warning: -pie being ignored. It is only used when linking a main executable
  [11/79] Linking target pandas/_libs/indexing.cpython-310-darwin.so
  ld: warning: -pie being ignored. It is only used when linking a main executable
  [12/79] Linking target pandas/_libs/internals.cpython-310-darwin.so
  ld: warning: -pie being ignored. It is only used when linking a main executable
  [13/79] Generating write_version_file with a custom command
  [14/79] Compiling C object pandas/_libs/tslibs/timedeltas.cpython-310-darwin.so.p/meson-generated_pandas__libs_tslibs_timedeltas.pyx.c.o
  FAILED: pandas/_libs/tslibs/timedeltas.cpython-310-darwin.so.p/meson-generated_pandas__libs_tslibs_timedeltas.pyx.c.o
  arm64-apple-darwin20.0.0-clang -Ipandas/_libs/tslibs/timedeltas.cpython-310-darwin.so.p -Ipandas/_libs/tslibs -I../../pandas/_libs/tslibs -I../../../../mambaforge/envs/pandas-dev/lib/python3.10/site-packages/numpy/core/include -I../../pandas/_libs/include -I/Users/fangchenli/mambaforge/envs/pandas-dev/include/python3.10 -fvisibility=hidden -fcolor-diagnostics -DNDEBUG -w -std=c99 -O3 -DNPY_NO_DEPRECATED_API=0 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isystem /Users/fangchenli/mambaforge/envs/pandas-dev/include -D_FORTIFY_SOURCE=2 -isystem /Users/fangchenli/mambaforge/envs/pandas-dev/include -MD -MQ pandas/_libs/tslibs/timedeltas.cpython-310-darwin.so.p/meson-generated_pandas__libs_tslibs_timedeltas.pyx.c.o -MF pandas/_libs/tslibs/timedeltas.cpython-310-darwin.so.p/meson-generated_pandas__libs_tslibs_timedeltas.pyx.c.o.d -o pandas/_libs/tslibs/timedeltas.cpython-310-darwin.so.p/meson-generated_pandas__libs_tslibs_timedeltas.pyx.c.o -c pandas/_libs/tslibs/timedeltas.cpython-310-darwin.so.p/pandas/_libs/tslibs/timedeltas.pyx.c
  pandas/_libs/tslibs/timedeltas.cpython-310-darwin.so.p/pandas/_libs/tslibs/timedeltas.pyx.c:755:10: fatal error: 'src/datetime/pd_datetime.h' file not found
  #include "src/datetime/pd_datetime.h"
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1 error generated.
  [15/79] Compiling C object pandas/_libs/lib.cpython-310-darwin.so.p/src_parser_tokenizer.c.o
  [16/79] Compiling C object pandas/_libs/index.cpython-310-darwin.so.p/meson-generated_pandas__libs_index.pyx.c.o
  FAILED: pandas/_libs/index.cpython-310-darwin.so.p/meson-generated_pandas__libs_index.pyx.c.o
  arm64-apple-darwin20.0.0-clang -Ipandas/_libs/index.cpython-310-darwin.so.p -Ipandas/_libs -I../../pandas/_libs -I../../../../mambaforge/envs/pandas-dev/lib/python3.10/site-packages/numpy/core/include -I../../pandas/_libs/include -I/Users/fangchenli/mambaforge/envs/pandas-dev/include/python3.10 -fvisibility=hidden -fcolor-diagnostics -DNDEBUG -w -std=c99 -O3 -DNPY_NO_DEPRECATED_API=0 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isystem /Users/fangchenli/mambaforge/envs/pandas-dev/include -D_FORTIFY_SOURCE=2 -isystem /Users/fangchenli/mambaforge/envs/pandas-dev/include -MD -MQ pandas/_libs/index.cpython-310-darwin.so.p/meson-generated_pandas__libs_index.pyx.c.o -MF pandas/_libs/index.cpython-310-darwin.so.p/meson-generated_pandas__libs_index.pyx.c.o.d -o pandas/_libs/index.cpython-310-darwin.so.p/meson-generated_pandas__libs_index.pyx.c.o -c pandas/_libs/index.cpython-310-darwin.so.p/pandas/_libs/index.pyx.c
  pandas/_libs/index.cpython-310-darwin.so.p/pandas/_libs/index.pyx.c:756:10: fatal error: 'khash_python.h' file not found
  #include "khash_python.h"
           ^~~~~~~~~~~~~~~~
  1 error generated.
  Note that this error message can also be triggered by
  external dependencies being installed within your source
  tree - it's not recommended to do this.

This snippet of the error message was added by @rgommers to provide a hint about the problem. The relpath trick seems apropos here, indeed.

(More generally, the long-term idea is to create some dependency interface for numpy, so people can just use that directly and not need to worry about running numpy.get_include() via manual code snippets.)