Skip to content

[Bug]: Can't find pybind11 headers when building from source #29741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dstansby opened this issue Mar 12, 2025 · 7 comments
Closed

[Bug]: Can't find pybind11 headers when building from source #29741

dstansby opened this issue Mar 12, 2025 · 7 comments

Comments

@dstansby
Copy link
Member

Bug summary

On macOS I am failing to build Matplotlib from source, because the c++ compiler cannot find Pybind11 headers. I've followed instructions at https://matplotlib.org/devdocs/devel/development_setup.html, and I get the same issue in a virtual environment, a virtual environment managed with uv, and a conda environment.

I have pybind11 installed globally (using brew), and in the Python virtual environment:

% python -c "import pybind11; print(pybind11.__version__)"
2.13.6

Code for reproduction

python -m pip install --verbose --no-build-isolation --editable ".[dev]"

Actual outcome

% uv pip install --verbose --no-build-isolation --editable ".[dev]"

DEBUG uv 0.6.5 (Homebrew 2025-03-06)
DEBUG Searching for default Python interpreter in virtual environments
DEBUG Found `cpython-3.12.8-macos-aarch64-none` at `/Users/dstansby/software/matplotlib/.venv/bin/python3` (active virtual environment)
DEBUG Using Python 3.12.8 environment at: .venv
DEBUG Acquired lock for `.venv`
DEBUG At least one requirement is not satisfied: file:///Users/dstansby/software/matplotlib
DEBUG Using request timeout of 30s
DEBUG Found PEP 621 metadata for /Users/dstansby/software/matplotlib in `pyproject.toml` (matplotlib)
DEBUG No static `pyproject.toml` available for: matplotlib @ file:///Users/dstansby/software/matplotlib (DynamicField("version"))
DEBUG Acquired lock for `/Users/dstansby/.cache/uv/sdists-v8/editable/a93b495625504936`
DEBUG Preparing metadata for: matplotlib @ file:///Users/dstansby/software/matplotlib
DEBUG No workspace root found, using project root
DEBUG Proceeding without build isolation
DEBUG Calling `mesonpy.prepare_metadata_for_build_editable()`
   Building matplotlib @ file:///Users/dstansby/software/matplotlib
DEBUG Building: matplotlib @ file:///Users/dstansby/software/matplotlib
DEBUG No workspace root found, using project root
DEBUG Proceeding without build isolation
DEBUG Calling `mesonpy.build_editable("/Users/dstansby/.cache/uv/builds-v0/.tmppFdYgl", {}, None)`
DEBUG + meson setup --reconfigure /Users/dstansby/software/matplotlib /Users/dstansby/software/matplotlib/build/cp312 -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=/Users/dstansby/software/matplotlib/build/cp312/meson-python-native-file.ini
DEBUG Cleaning... 0 files.
DEBUG The Meson build system
DEBUG Version: 1.7.0
DEBUG Source dir: /Users/dstansby/software/matplotlib
DEBUG Build dir: /Users/dstansby/software/matplotlib/build/cp312
DEBUG Build type: native build
DEBUG Program python3 found: YES (/Users/dstansby/software/matplotlib/.venv/bin/python3)
DEBUG Project name: matplotlib
DEBUG Project version: 3.11.0.dev547+gb0153b17b6
DEBUG C compiler for the host machine: cc (clang 16.0.0 "Apple clang version 16.0.0 (clang-1600.0.26.6)")
DEBUG C linker for the host machine: cc ld64 1115.7.3
DEBUG C++ compiler for the host machine: c++ (clang 16.0.0 "Apple clang version 16.0.0 (clang-1600.0.26.6)")
DEBUG C++ linker for the host machine: c++ ld64 1115.7.3
DEBUG Host machine cpu family: aarch64
DEBUG Host machine cpu: aarch64
DEBUG Program python found: YES (/Users/dstansby/software/matplotlib/.venv/bin/python3)
DEBUG Dependency pybind11 found: YES 2.13.6 (cached)
DEBUG 
DEBUG Executing subproject freetype-2.6.1 
DEBUG 
DEBUG freetype-2.6.1| Project name: freetype2
DEBUG freetype-2.6.1| Project version: 2.6.1
DEBUG freetype-2.6.1| C compiler for the host machine: cc (clang 16.0.0 "Apple clang version 16.0.0 (clang-1600.0.26.6)")
DEBUG freetype-2.6.1| C linker for the host machine: cc ld64 1115.7.3
DEBUG freetype-2.6.1| Has header "unistd.h" : YES (cached)
DEBUG freetype-2.6.1| Has header "fcntl.h" : YES (cached)
DEBUG freetype-2.6.1| Has header "stdint.h" : YES (cached)
DEBUG freetype-2.6.1| Configuring ftconfig.h using configuration
DEBUG freetype-2.6.1| Configuring ftoption.h using configuration
DEBUG freetype-2.6.1| Build targets in project: 2
DEBUG freetype-2.6.1| Subproject freetype-2.6.1 finished.
DEBUG 
DEBUG 
DEBUG Executing subproject qhull 
DEBUG 
DEBUG qhull| Project name: qhull
DEBUG qhull| Project version: 8.0.2
DEBUG qhull| C compiler for the host machine: cc (clang 16.0.0 "Apple clang version 16.0.0 (clang-1600.0.26.6)")
DEBUG qhull| C linker for the host machine: cc ld64 1115.7.3
DEBUG qhull| Build targets in project: 3
DEBUG qhull| Subproject qhull finished.
DEBUG 
DEBUG Dependency dl found: YES unknown (cached)
DEBUG Objective-C compiler for the host machine: clang (clang 16.0.0)
DEBUG Objective-C linker for the host machine: clang ld64 1115.7.3
DEBUG Dependency appleframeworks (modules: Cocoa) found: YES unknown (cached)
DEBUG Configuring _version.py using configuration
DEBUG Program /Users/dstansby/software/matplotlib/tools/generate_matplotlibrc.py found: YES (/Users/dstansby/software/matplotlib/tools/generate_matplotlibrc.py)
DEBUG Build targets in project: 13
DEBUG 
DEBUG matplotlib 3.11.0.dev547+gb0153b17b6
DEBUG 
DEBUG   Subprojects
DEBUG     freetype-2.6.1: YES
DEBUG     qhull         : YES
DEBUG 
DEBUG   User defined options
DEBUG     Native files  : /Users/dstansby/software/matplotlib/build/cp312/meson-python-native-file.ini
DEBUG     b_ndebug      : if-release
DEBUG     b_vscrt       : md
DEBUG     buildtype     : release
DEBUG 
DEBUG Found ninja-1.11.1.git.kitware.jobserver-1 at /Users/dstansby/software/matplotlib/.venv/bin/ninja
DEBUG + /Users/dstansby/software/matplotlib/.venv/bin/ninja
DEBUG [1/23] Compiling C++ object src/_image.cpython-312-darwin.so.p/py_converters.cpp.o
DEBUG FAILED: src/_image.cpython-312-darwin.so.p/py_converters.cpp.o 
DEBUG c++ -Isrc/_image.cpython-312-darwin.so.p -Isrc -I../../src -I../../extern/agg24-svn/include -I/Users/dstansby/.local/share/uv/python/cpython-3.12.8-macos-aarch64-none/include/python3.12 -I/Users/dstansby/.cache/uv/builds-v0/.tmp4X2jQO/lib/python3.12/site-packages/pybind11/include -I/install/include/python3.12 -fvisibility=hidden -fvisibility-inlines-hidden -flto -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=c++17 -O3 -MD -MQ src/_image.cpython-312-darwin.so.p/py_converters.cpp.o -MF src/_image.cpython-312-darwin.so.p/py_converters.cpp.o.d -o src/_image.cpython-312-darwin.so.p/py_converters.cpp.o -c ../../src/py_converters.cpp
DEBUG In file included from ../../src/py_converters.cpp:1:
DEBUG ../../src/py_converters.h:12:10: fatal error: 'pybind11/pybind11.h' file not found
DEBUG    12 | #include <pybind11/pybind11.h>
DEBUG       |          ^~~~~~~~~~~~~~~~~~~~~
DEBUG 1 error generated.
DEBUG [2/23] Compiling C++ object src/_c_internal_utils.cpython-312-darwin.so.p/_c_internal_utils.cpp.o
DEBUG FAILED: src/_c_internal_utils.cpython-312-darwin.so.p/_c_internal_utils.cpp.o 
DEBUG c++ -Isrc/_c_internal_utils.cpython-312-darwin.so.p -Isrc -I../../src -I/Users/dstansby/.local/share/uv/python/cpython-3.12.8-macos-aarch64-none/include/python3.12 -I/Users/dstansby/.cache/uv/builds-v0/.tmp4X2jQO/lib/python3.12/site-packages/pybind11/include -I/install/include/python3.12 -fvisibility=hidden -fvisibility-inlines-hidden -flto -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=c++17 -O3 -MD -MQ src/_c_internal_utils.cpython-312-darwin.so.p/_c_internal_utils.cpp.o -MF src/_c_internal_utils.cpython-312-darwin.so.p/_c_internal_utils.cpp.o.d -o src/_c_internal_utils.cpython-312-darwin.so.p/_c_internal_utils.cpp.o -c ../../src/_c_internal_utils.cpp
DEBUG ../../src/_c_internal_utils.cpp:19:10: fatal error: 'pybind11/pybind11.h' file not found
DEBUG    19 | #include <pybind11/pybind11.h>
DEBUG       |          ^~~~~~~~~~~~~~~~~~~~~
DEBUG 1 error generated.
DEBUG [3/23] Compiling C++ object src/_image.cpython-312-darwin.so.p/_image_wrapper.cpp.o
DEBUG FAILED: src/_image.cpython-312-darwin.so.p/_image_wrapper.cpp.o 
DEBUG c++ -Isrc/_image.cpython-312-darwin.so.p -Isrc -I../../src -I../../extern/agg24-svn/include -I/Users/dstansby/.local/share/uv/python/cpython-3.12.8-macos-aarch64-none/include/python3.12 -I/Users/dstansby/.cache/uv/builds-v0/.tmp4X2jQO/lib/python3.12/site-packages/pybind11/include -I/install/include/python3.12 -fvisibility=hidden -fvisibility-inlines-hidden -flto -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=c++17 -O3 -MD -MQ src/_image.cpython-312-darwin.so.p/_image_wrapper.cpp.o -MF src/_image.cpython-312-darwin.so.p/_image_wrapper.cpp.o.d -o src/_image.cpython-312-darwin.so.p/_image_wrapper.cpp.o -c ../../src/_image_wrapper.cpp
DEBUG ../../src/_image_wrapper.cpp:1:10: fatal error: 'pybind11/pybind11.h' file not found
DEBUG     1 | #include <pybind11/pybind11.h>
DEBUG       |          ^~~~~~~~~~~~~~~~~~~~~
DEBUG 1 error generated.
DEBUG [4/23] Compiling C++ object src/_tkagg.cpython-312-darwin.so.p/_tkagg.cpp.o
DEBUG FAILED: src/_tkagg.cpython-312-darwin.so.p/_tkagg.cpp.o 
DEBUG c++ -Isrc/_tkagg.cpython-312-darwin.so.p -Isrc -I../../src -I../../extern/agg24-svn/include -I/Users/dstansby/.local/share/uv/python/cpython-3.12.8-macos-aarch64-none/include/python3.12 -I/Users/dstansby/.cache/uv/builds-v0/.tmp4X2jQO/lib/python3.12/site-packages/pybind11/include -I/install/include/python3.12 -fvisibility=hidden -fvisibility-inlines-hidden -flto -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=c++17 -O3 -MD -MQ src/_tkagg.cpython-312-darwin.so.p/_tkagg.cpp.o -MF src/_tkagg.cpython-312-darwin.so.p/_tkagg.cpp.o.d -o src/_tkagg.cpython-312-darwin.so.p/_tkagg.cpp.o -c ../../src/_tkagg.cpp
DEBUG ../../src/_tkagg.cpp:32:10: fatal error: 'pybind11/pybind11.h' file not found
DEBUG    32 | #include <pybind11/pybind11.h>
DEBUG       |          ^~~~~~~~~~~~~~~~~~~~~
DEBUG 1 error generated.
DEBUG [5/23] Compiling C++ object src/_qhull.cpython-312-darwin.so.p/_qhull_wrapper.cpp.o
DEBUG FAILED: src/_qhull.cpython-312-darwin.so.p/_qhull_wrapper.cpp.o 
DEBUG c++ -Isrc/_qhull.cpython-312-darwin.so.p -Isrc -I../../src -I../../subprojects/qhull-8.0.2/src -I/Users/dstansby/.local/share/uv/python/cpython-3.12.8-macos-aarch64-none/include/python3.12 -I/Users/dstansby/.cache/uv/builds-v0/.tmp4X2jQO/lib/python3.12/site-packages/pybind11/include -I/install/include/python3.12 -fvisibility=hidden -fvisibility-inlines-hidden -flto -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=c++17 -O3 -DMPL_DEVNULL=/dev/null -MD -MQ src/_qhull.cpython-312-darwin.so.p/_qhull_wrapper.cpp.o -MF src/_qhull.cpython-312-darwin.so.p/_qhull_wrapper.cpp.o.d -o src/_qhull.cpython-312-darwin.so.p/_qhull_wrapper.cpp.o -c ../../src/_qhull_wrapper.cpp
DEBUG ../../src/_qhull_wrapper.cpp:8:10: fatal error: 'pybind11/pybind11.h' file not found
DEBUG     8 | #include <pybind11/pybind11.h>
DEBUG       |          ^~~~~~~~~~~~~~~~~~~~~
DEBUG 1 error generated.
DEBUG [6/23] Compiling C++ object src/ft2font.cpython-312-darwin.so.p/ft2font_wrapper.cpp.o
DEBUG FAILED: src/ft2font.cpython-312-darwin.so.p/ft2font_wrapper.cpp.o 
DEBUG c++ -Isrc/ft2font.cpython-312-darwin.so.p -Isrc -I../../src -I../../subprojects/freetype-2.6.1/include -I../../extern/agg24-svn/include -I/Users/dstansby/.local/share/uv/python/cpython-3.12.8-macos-aarch64-none/include/python3.12 -I/Users/dstansby/.cache/uv/builds-v0/.tmp4X2jQO/lib/python3.12/site-packages/pybind11/include -I/install/include/python3.12 -fvisibility=hidden -fvisibility-inlines-hidden -flto -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=c++17 -O3 '-DFREETYPE_BUILD_TYPE="local"' -MD -MQ src/ft2font.cpython-312-darwin.so.p/ft2font_wrapper.cpp.o -MF src/ft2font.cpython-312-darwin.so.p/ft2font_wrapper.cpp.o.d -o src/ft2font.cpython-312-darwin.so.p/ft2font_wrapper.cpp.o -c ../../src/ft2font_wrapper.cpp
DEBUG ../../src/ft2font_wrapper.cpp:2:10: fatal error: 'pybind11/pybind11.h' file not found
DEBUG     2 | #include <pybind11/pybind11.h>
DEBUG       |          ^~~~~~~~~~~~~~~~~~~~~
DEBUG 1 error generated.
DEBUG [7/23] Compiling C++ object src/_path.cpython-312-darwin.so.p/_path_wrapper.cpp.o
DEBUG FAILED: src/_path.cpython-312-darwin.so.p/_path_wrapper.cpp.o 
DEBUG c++ -Isrc/_path.cpython-312-darwin.so.p -Isrc -I../../src -I../../extern/agg24-svn/include -I/Users/dstansby/.local/share/uv/python/cpython-3.12.8-macos-aarch64-none/include/python3.12 -I/Users/dstansby/.cache/uv/builds-v0/.tmp4X2jQO/lib/python3.12/site-packages/pybind11/include -I/install/include/python3.12 -fvisibility=hidden -fvisibility-inlines-hidden -flto -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=c++17 -O3 -MD -MQ src/_path.cpython-312-darwin.so.p/_path_wrapper.cpp.o -MF src/_path.cpython-312-darwin.so.p/_path_wrapper.cpp.o.d -o src/_path.cpython-312-darwin.so.p/_path_wrapper.cpp.o -c ../../src/_path_wrapper.cpp
DEBUG ../../src/_path_wrapper.cpp:1:10: fatal error: 'pybind11/pybind11.h' file not found
DEBUG     1 | #include <pybind11/pybind11.h>
DEBUG       |          ^~~~~~~~~~~~~~~~~~~~~
DEBUG 1 error generated.
DEBUG [8/23] Compiling C++ object src/_backend_agg.cpython-312-darwin.so.p/_backend_agg_wrapper.cpp.o
DEBUG FAILED: src/_backend_agg.cpython-312-darwin.so.p/_backend_agg_wrapper.cpp.o 
DEBUG c++ -Isrc/_backend_agg.cpython-312-darwin.so.p -Isrc -I../../src -I../../extern/agg24-svn/include -I../../subprojects/freetype-2.6.1/include -I/Users/dstansby/.local/share/uv/python/cpython-3.12.8-macos-aarch64-none/include/python3.12 -I/Users/dstansby/.cache/uv/builds-v0/.tmp4X2jQO/lib/python3.12/site-packages/pybind11/include -I/install/include/python3.12 -fvisibility=hidden -fvisibility-inlines-hidden -flto -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=c++17 -O3 -MD -MQ src/_backend_agg.cpython-312-darwin.so.p/_backend_agg_wrapper.cpp.o -MF src/_backend_agg.cpython-312-darwin.so.p/_backend_agg_wrapper.cpp.o.d -o src/_backend_agg.cpython-312-darwin.so.p/_backend_agg_wrapper.cpp.o -c ../../src/_backend_agg_wrapper.cpp
DEBUG ../../src/_backend_agg_wrapper.cpp:1:10: fatal error: 'pybind11/pybind11.h' file not found
DEBUG     1 | #include <pybind11/pybind11.h>
DEBUG       |          ^~~~~~~~~~~~~~~~~~~~~
DEBUG 1 error generated.
DEBUG [9/23] Compiling C++ object src/_backend_agg.cpython-312-darwin.so.p/_backend_agg.cpp.o
DEBUG FAILED: src/_backend_agg.cpython-312-darwin.so.p/_backend_agg.cpp.o 
DEBUG c++ -Isrc/_backend_agg.cpython-312-darwin.so.p -Isrc -I../../src -I../../extern/agg24-svn/include -I../../subprojects/freetype-2.6.1/include -I/Users/dstansby/.local/share/uv/python/cpython-3.12.8-macos-aarch64-none/include/python3.12 -I/Users/dstansby/.cache/uv/builds-v0/.tmp4X2jQO/lib/python3.12/site-packages/pybind11/include -I/install/include/python3.12 -fvisibility=hidden -fvisibility-inlines-hidden -flto -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=c++17 -O3 -MD -MQ src/_backend_agg.cpython-312-darwin.so.p/_backend_agg.cpp.o -MF src/_backend_agg.cpython-312-darwin.so.p/_backend_agg.cpp.o.d -o src/_backend_agg.cpython-312-darwin.so.p/_backend_agg.cpp.o -c ../../src/_backend_agg.cpp
DEBUG In file included from ../../src/_backend_agg.cpp:6:
DEBUG ../../src/_backend_agg.h:9:10: fatal error: 'pybind11/pybind11.h' file not found
DEBUG     9 | #include <pybind11/pybind11.h>
DEBUG       |          ^~~~~~~~~~~~~~~~~~~~~
DEBUG 1 error generated.
DEBUG [10/23] Compiling C++ object src/ft2font.cpython-312-darwin.so.p/ft2font.cpp.o
DEBUG FAILED: src/ft2font.cpython-312-darwin.so.p/ft2font.cpp.o 
DEBUG c++ -Isrc/ft2font.cpython-312-darwin.so.p -Isrc -I../../src -I../../subprojects/freetype-2.6.1/include -I../../extern/agg24-svn/include -I/Users/dstansby/.local/share/uv/python/cpython-3.12.8-macos-aarch64-none/include/python3.12 -I/Users/dstansby/.cache/uv/builds-v0/.tmp4X2jQO/lib/python3.12/site-packages/pybind11/include -I/install/include/python3.12 -fvisibility=hidden -fvisibility-inlines-hidden -flto -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=c++17 -O3 '-DFREETYPE_BUILD_TYPE="local"' -MD -MQ src/ft2font.cpython-312-darwin.so.p/ft2font.cpp.o -MF src/ft2font.cpython-312-darwin.so.p/ft2font.cpp.o.d -o src/ft2font.cpython-312-darwin.so.p/ft2font.cpp.o -c ../../src/ft2font.cpp
DEBUG In file included from ../../src/ft2font.cpp:13:
DEBUG ../../src/mplutils.h:54:10: fatal error: 'pybind11/pybind11.h' file not found
DEBUG    54 | #include <pybind11/pybind11.h>
DEBUG       |          ^~~~~~~~~~~~~~~~~~~~~
DEBUG 1 error generated.
DEBUG ninja: build stopped: subcommand failed.
DEBUG Released lock at `/Users/dstansby/.cache/uv/sdists-v8/editable/a93b495625504936/.lock`
  × Failed to build `matplotlib @ file:///Users/dstansby/software/matplotlib`
  ├─▶ The build backend returned an error
  ╰─▶ Call to `mesonpy.build_editable` failed (exit status: 1)

      [stdout]
      + meson setup --reconfigure /Users/dstansby/software/matplotlib /Users/dstansby/software/matplotlib/build/cp312 -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md
      --native-file=/Users/dstansby/software/matplotlib/build/cp312/meson-python-native-file.ini
      Cleaning... 0 files.
      The Meson build system
      Version: 1.7.0
      Source dir: /Users/dstansby/software/matplotlib
      Build dir: /Users/dstansby/software/matplotlib/build/cp312
      Build type: native build
      Program python3 found: YES (/Users/dstansby/software/matplotlib/.venv/bin/python3)
      Project name: matplotlib
      Project version: 3.11.0.dev547+gb0153b17b6
      C compiler for the host machine: cc (clang 16.0.0 "Apple clang version 16.0.0 (clang-1600.0.26.6)")
      C linker for the host machine: cc ld64 1115.7.3
      C++ compiler for the host machine: c++ (clang 16.0.0 "Apple clang version 16.0.0 (clang-1600.0.26.6)")
      C++ linker for the host machine: c++ ld64 1115.7.3
      Host machine cpu family: aarch64
      Host machine cpu: aarch64
      Program python found: YES (/Users/dstansby/software/matplotlib/.venv/bin/python3)
      Dependency pybind11 found: YES 2.13.6 (cached)

      Executing subproject freetype-2.6.1

      freetype-2.6.1| Project name: freetype2
      freetype-2.6.1| Project version: 2.6.1
      freetype-2.6.1| C compiler for the host machine: cc (clang 16.0.0 "Apple clang version 16.0.0 (clang-1600.0.26.6)")
      freetype-2.6.1| C linker for the host machine: cc ld64 1115.7.3
      freetype-2.6.1| Has header "unistd.h" : YES (cached)
      freetype-2.6.1| Has header "fcntl.h" : YES (cached)
      freetype-2.6.1| Has header "stdint.h" : YES (cached)
      freetype-2.6.1| Configuring ftconfig.h using configuration
      freetype-2.6.1| Configuring ftoption.h using configuration
      freetype-2.6.1| Build targets in project: 2
      freetype-2.6.1| Subproject freetype-2.6.1 finished.


      Executing subproject qhull

      qhull| Project name: qhull
      qhull| Project version: 8.0.2
      qhull| C compiler for the host machine: cc (clang 16.0.0 "Apple clang version 16.0.0 (clang-1600.0.26.6)")
      qhull| C linker for the host machine: cc ld64 1115.7.3
      qhull| Build targets in project: 3
      qhull| Subproject qhull finished.

      Dependency dl found: YES unknown (cached)
      Objective-C compiler for the host machine: clang (clang 16.0.0)
      Objective-C linker for the host machine: clang ld64 1115.7.3
      Dependency appleframeworks (modules: Cocoa) found: YES unknown (cached)
      Configuring _version.py using configuration
      Program /Users/dstansby/software/matplotlib/tools/generate_matplotlibrc.py found: YES (/Users/dstansby/software/matplotlib/tools/generate_matplotlibrc.py)
      Build targets in project: 13

      matplotlib 3.11.0.dev547+gb0153b17b6

        Subprojects
          freetype-2.6.1: YES
          qhull         : YES

        User defined options
          Native files  : /Users/dstansby/software/matplotlib/build/cp312/meson-python-native-file.ini
          b_ndebug      : if-release
          b_vscrt       : md
          buildtype     : release

      Found ninja-1.11.1.git.kitware.jobserver-1 at /Users/dstansby/software/matplotlib/.venv/bin/ninja
      + /Users/dstansby/software/matplotlib/.venv/bin/ninja
      [1/23] Compiling C++ object src/_image.cpython-312-darwin.so.p/py_converters.cpp.o
      FAILED: src/_image.cpython-312-darwin.so.p/py_converters.cpp.o
      c++ -Isrc/_image.cpython-312-darwin.so.p -Isrc -I../../src -I../../extern/agg24-svn/include
      -I/Users/dstansby/.local/share/uv/python/cpython-3.12.8-macos-aarch64-none/include/python3.12
      -I/Users/dstansby/.cache/uv/builds-v0/.tmp4X2jQO/lib/python3.12/site-packages/pybind11/include -I/install/include/python3.12 -fvisibility=hidden
      -fvisibility-inlines-hidden -flto -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=c++17 -O3 -MD -MQ src/_image.cpython-312-darwin.so.p/py_converters.cpp.o -MF
      src/_image.cpython-312-darwin.so.p/py_converters.cpp.o.d -o src/_image.cpython-312-darwin.so.p/py_converters.cpp.o -c ../../src/py_converters.cpp
      In file included from ../../src/py_converters.cpp:1:
      ../../src/py_converters.h:12:10: fatal error: 'pybind11/pybind11.h' file not found
         12 | #include <pybind11/pybind11.h>
            |          ^~~~~~~~~~~~~~~~~~~~~
      1 error generated.
      [2/23] Compiling C++ object src/_c_internal_utils.cpython-312-darwin.so.p/_c_internal_utils.cpp.o
      FAILED: src/_c_internal_utils.cpython-312-darwin.so.p/_c_internal_utils.cpp.o
      c++ -Isrc/_c_internal_utils.cpython-312-darwin.so.p -Isrc -I../../src -I/Users/dstansby/.local/share/uv/python/cpython-3.12.8-macos-aarch64-none/include/python3.12
      -I/Users/dstansby/.cache/uv/builds-v0/.tmp4X2jQO/lib/python3.12/site-packages/pybind11/include -I/install/include/python3.12 -fvisibility=hidden -fvisibility-inlines-hidden
      -flto -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=c++17 -O3 -MD -MQ src/_c_internal_utils.cpython-312-darwin.so.p/_c_internal_utils.cpp.o
      -MF src/_c_internal_utils.cpython-312-darwin.so.p/_c_internal_utils.cpp.o.d -o src/_c_internal_utils.cpython-312-darwin.so.p/_c_internal_utils.cpp.o -c
      ../../src/_c_internal_utils.cpp
      ../../src/_c_internal_utils.cpp:19:10: fatal error: 'pybind11/pybind11.h' file not found
         19 | #include <pybind11/pybind11.h>
            |          ^~~~~~~~~~~~~~~~~~~~~
      1 error generated.
      [3/23] Compiling C++ object src/_image.cpython-312-darwin.so.p/_image_wrapper.cpp.o
      FAILED: src/_image.cpython-312-darwin.so.p/_image_wrapper.cpp.o
      c++ -Isrc/_image.cpython-312-darwin.so.p -Isrc -I../../src -I../../extern/agg24-svn/include
      -I/Users/dstansby/.local/share/uv/python/cpython-3.12.8-macos-aarch64-none/include/python3.12
      -I/Users/dstansby/.cache/uv/builds-v0/.tmp4X2jQO/lib/python3.12/site-packages/pybind11/include -I/install/include/python3.12 -fvisibility=hidden
      -fvisibility-inlines-hidden -flto -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=c++17 -O3 -MD -MQ src/_image.cpython-312-darwin.so.p/_image_wrapper.cpp.o -MF
      src/_image.cpython-312-darwin.so.p/_image_wrapper.cpp.o.d -o src/_image.cpython-312-darwin.so.p/_image_wrapper.cpp.o -c ../../src/_image_wrapper.cpp
      ../../src/_image_wrapper.cpp:1:10: fatal error: 'pybind11/pybind11.h' file not found
          1 | #include <pybind11/pybind11.h>
            |          ^~~~~~~~~~~~~~~~~~~~~
      1 error generated.
      [4/23] Compiling C++ object src/_tkagg.cpython-312-darwin.so.p/_tkagg.cpp.o
      FAILED: src/_tkagg.cpython-312-darwin.so.p/_tkagg.cpp.o
      c++ -Isrc/_tkagg.cpython-312-darwin.so.p -Isrc -I../../src -I../../extern/agg24-svn/include
      -I/Users/dstansby/.local/share/uv/python/cpython-3.12.8-macos-aarch64-none/include/python3.12
      -I/Users/dstansby/.cache/uv/builds-v0/.tmp4X2jQO/lib/python3.12/site-packages/pybind11/include -I/install/include/python3.12 -fvisibility=hidden
      -fvisibility-inlines-hidden -flto -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=c++17 -O3 -MD -MQ src/_tkagg.cpython-312-darwin.so.p/_tkagg.cpp.o -MF
      src/_tkagg.cpython-312-darwin.so.p/_tkagg.cpp.o.d -o src/_tkagg.cpython-312-darwin.so.p/_tkagg.cpp.o -c ../../src/_tkagg.cpp
      ../../src/_tkagg.cpp:32:10: fatal error: 'pybind11/pybind11.h' file not found
         32 | #include <pybind11/pybind11.h>
            |          ^~~~~~~~~~~~~~~~~~~~~
      1 error generated.
      [5/23] Compiling C++ object src/_qhull.cpython-312-darwin.so.p/_qhull_wrapper.cpp.o
      FAILED: src/_qhull.cpython-312-darwin.so.p/_qhull_wrapper.cpp.o
      c++ -Isrc/_qhull.cpython-312-darwin.so.p -Isrc -I../../src -I../../subprojects/qhull-8.0.2/src
      -I/Users/dstansby/.local/share/uv/python/cpython-3.12.8-macos-aarch64-none/include/python3.12
      -I/Users/dstansby/.cache/uv/builds-v0/.tmp4X2jQO/lib/python3.12/site-packages/pybind11/include -I/install/include/python3.12 -fvisibility=hidden -fvisibility-inlines-hidden
      -flto -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=c++17 -O3 -DMPL_DEVNULL=/dev/null -MD -MQ src/_qhull.cpython-312-darwin.so.p/_qhull_wrapper.cpp.o -MF
      src/_qhull.cpython-312-darwin.so.p/_qhull_wrapper.cpp.o.d -o src/_qhull.cpython-312-darwin.so.p/_qhull_wrapper.cpp.o -c ../../src/_qhull_wrapper.cpp
      ../../src/_qhull_wrapper.cpp:8:10: fatal error: 'pybind11/pybind11.h' file not found
          8 | #include <pybind11/pybind11.h>
            |          ^~~~~~~~~~~~~~~~~~~~~
      1 error generated.
      [6/23] Compiling C++ object src/ft2font.cpython-312-darwin.so.p/ft2font_wrapper.cpp.o
      FAILED: src/ft2font.cpython-312-darwin.so.p/ft2font_wrapper.cpp.o
      c++ -Isrc/ft2font.cpython-312-darwin.so.p -Isrc -I../../src -I../../subprojects/freetype-2.6.1/include
      -I../../extern/agg24-svn/include -I/Users/dstansby/.local/share/uv/python/cpython-3.12.8-macos-aarch64-none/include/python3.12
      -I/Users/dstansby/.cache/uv/builds-v0/.tmp4X2jQO/lib/python3.12/site-packages/pybind11/include -I/install/include/python3.12 -fvisibility=hidden -fvisibility-inlines-hidden
      -flto -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=c++17 -O3 '-DFREETYPE_BUILD_TYPE="local"' -MD -MQ src/ft2font.cpython-312-darwin.so.p/ft2font_wrapper.cpp.o
      -MF src/ft2font.cpython-312-darwin.so.p/ft2font_wrapper.cpp.o.d -o src/ft2font.cpython-312-darwin.so.p/ft2font_wrapper.cpp.o -c ../../src/ft2font_wrapper.cpp
      ../../src/ft2font_wrapper.cpp:2:10: fatal error: 'pybind11/pybind11.h' file not found
          2 | #include <pybind11/pybind11.h>
            |          ^~~~~~~~~~~~~~~~~~~~~
      1 error generated.
      [7/23] Compiling C++ object src/_path.cpython-312-darwin.so.p/_path_wrapper.cpp.o
      FAILED: src/_path.cpython-312-darwin.so.p/_path_wrapper.cpp.o
      c++ -Isrc/_path.cpython-312-darwin.so.p -Isrc -I../../src -I../../extern/agg24-svn/include
      -I/Users/dstansby/.local/share/uv/python/cpython-3.12.8-macos-aarch64-none/include/python3.12
      -I/Users/dstansby/.cache/uv/builds-v0/.tmp4X2jQO/lib/python3.12/site-packages/pybind11/include -I/install/include/python3.12 -fvisibility=hidden
      -fvisibility-inlines-hidden -flto -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=c++17 -O3 -MD -MQ src/_path.cpython-312-darwin.so.p/_path_wrapper.cpp.o -MF
      src/_path.cpython-312-darwin.so.p/_path_wrapper.cpp.o.d -o src/_path.cpython-312-darwin.so.p/_path_wrapper.cpp.o -c ../../src/_path_wrapper.cpp
      ../../src/_path_wrapper.cpp:1:10: fatal error: 'pybind11/pybind11.h' file not found
          1 | #include <pybind11/pybind11.h>
            |          ^~~~~~~~~~~~~~~~~~~~~
      1 error generated.
      [8/23] Compiling C++ object src/_backend_agg.cpython-312-darwin.so.p/_backend_agg_wrapper.cpp.o
      FAILED: src/_backend_agg.cpython-312-darwin.so.p/_backend_agg_wrapper.cpp.o
      c++ -Isrc/_backend_agg.cpython-312-darwin.so.p -Isrc -I../../src -I../../extern/agg24-svn/include
      -I../../subprojects/freetype-2.6.1/include -I/Users/dstansby/.local/share/uv/python/cpython-3.12.8-macos-aarch64-none/include/python3.12
      -I/Users/dstansby/.cache/uv/builds-v0/.tmp4X2jQO/lib/python3.12/site-packages/pybind11/include -I/install/include/python3.12 -fvisibility=hidden -fvisibility-inlines-hidden
      -flto -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=c++17 -O3 -MD -MQ src/_backend_agg.cpython-312-darwin.so.p/_backend_agg_wrapper.cpp.o
      -MF src/_backend_agg.cpython-312-darwin.so.p/_backend_agg_wrapper.cpp.o.d -o src/_backend_agg.cpython-312-darwin.so.p/_backend_agg_wrapper.cpp.o -c
      ../../src/_backend_agg_wrapper.cpp
      ../../src/_backend_agg_wrapper.cpp:1:10: fatal error: 'pybind11/pybind11.h' file not found
          1 | #include <pybind11/pybind11.h>
            |          ^~~~~~~~~~~~~~~~~~~~~
      1 error generated.
      [9/23] Compiling C++ object src/_backend_agg.cpython-312-darwin.so.p/_backend_agg.cpp.o
      FAILED: src/_backend_agg.cpython-312-darwin.so.p/_backend_agg.cpp.o
      c++ -Isrc/_backend_agg.cpython-312-darwin.so.p -Isrc -I../../src -I../../extern/agg24-svn/include
      -I../../subprojects/freetype-2.6.1/include -I/Users/dstansby/.local/share/uv/python/cpython-3.12.8-macos-aarch64-none/include/python3.12
      -I/Users/dstansby/.cache/uv/builds-v0/.tmp4X2jQO/lib/python3.12/site-packages/pybind11/include -I/install/include/python3.12 -fvisibility=hidden -fvisibility-inlines-hidden
      -flto -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=c++17 -O3 -MD -MQ src/_backend_agg.cpython-312-darwin.so.p/_backend_agg.cpp.o -MF
      src/_backend_agg.cpython-312-darwin.so.p/_backend_agg.cpp.o.d -o src/_backend_agg.cpython-312-darwin.so.p/_backend_agg.cpp.o -c ../../src/_backend_agg.cpp
      In file included from ../../src/_backend_agg.cpp:6:
      ../../src/_backend_agg.h:9:10: fatal error: 'pybind11/pybind11.h' file not found
          9 | #include <pybind11/pybind11.h>
            |          ^~~~~~~~~~~~~~~~~~~~~
      1 error generated.
      [10/23] Compiling C++ object src/ft2font.cpython-312-darwin.so.p/ft2font.cpp.o
      FAILED: src/ft2font.cpython-312-darwin.so.p/ft2font.cpp.o
      c++ -Isrc/ft2font.cpython-312-darwin.so.p -Isrc -I../../src -I../../subprojects/freetype-2.6.1/include
      -I../../extern/agg24-svn/include -I/Users/dstansby/.local/share/uv/python/cpython-3.12.8-macos-aarch64-none/include/python3.12
      -I/Users/dstansby/.cache/uv/builds-v0/.tmp4X2jQO/lib/python3.12/site-packages/pybind11/include -I/install/include/python3.12 -fvisibility=hidden -fvisibility-inlines-hidden
      -flto -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=c++17 -O3 '-DFREETYPE_BUILD_TYPE="local"' -MD -MQ src/ft2font.cpython-312-darwin.so.p/ft2font.cpp.o -MF
      src/ft2font.cpython-312-darwin.so.p/ft2font.cpp.o.d -o src/ft2font.cpython-312-darwin.so.p/ft2font.cpp.o -c ../../src/ft2font.cpp
      In file included from ../../src/ft2font.cpp:13:
      ../../src/mplutils.h:54:10: fatal error: 'pybind11/pybind11.h' file not found
         54 | #include <pybind11/pybind11.h>
            |          ^~~~~~~~~~~~~~~~~~~~~
      1 error generated.
      ninja: build stopped: subcommand failed.

      hint: This usually indicates a problem with the package or the build environment.
DEBUG Released lock at `/Users/dstansby/software/matplotlib/.venv/.lock`

Expected outcome

A working install

Additional information

No response

Operating system

macOS

Matplotlib Version

Latest main branch

Matplotlib Backend

No response

Python version

Python 3.12.8

Jupyter version

No response

Installation

git checkout

@QuLogic
Copy link
Member

QuLogic commented Mar 18, 2025

Without build isolation in pip, you need to install build dependencies before Matplotlib. The .[dev] was a sort of workaround, but it didn't work. I'm not sure if it applies to uv as well, but if it's emulating pip, then it probably wouldn't work either.

For now, you should install the build dependencies first (you can use requirements/dev/build-requirements.txt), and after #29281, the dependency groups will help make these explicit.

@dstansby
Copy link
Member Author

Even if I go through conda, and I have pybind11 in my conda environment, I still get this error.

@dstansby
Copy link
Member Author

I suspect this might be because meson is trying to compile files with c++, which points to /usr/bin/c++ instead of somewhere inside my (activated) conda environment...?

@dstansby
Copy link
Member Author

I tried installing a c and cxx compiler into the conda environment (as should now happen anyway after #28352), and it didn't help. I'm still getting errors finding pybind11.h, like this:

  [10/26] Compiling C++ object src/ft2font.cpython-312-darwin.so.p/ft2font.cpp.o
  FAILED: src/ft2font.cpython-312-darwin.so.p/ft2font.cpp.o
  c++ -Isrc/ft2font.cpython-312-darwin.so.p -Isrc -I../../src -I../../subprojects/freetype-2.6.1/include -I../../extern/agg24-svn/include -I/opt/homebrew/opt/pybind11/include -I/Users/dstansby/miniforge3/envs/mpl-dev/include/python3.12 -fvisibility=hidden -fvisibility-inlines-hidden -flto -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=c++17 -O3 '-DFREETYPE_BUILD_TYPE="local"' -MD -MQ src/ft2font.cpython-312-darwin.so.p/ft2font.cpp.o -MF src/ft2font.cpython-312-darwin.so.p/ft2font.cpp.o.d -o src/ft2font.cpython-312-darwin.so.p/ft2font.cpp.o -c ../../src/ft2font.cpp
  In file included from ../../src/ft2font.cpp:13:
  ../../src/mplutils.h:54:10: fatal error: 'pybind11/pybind11.h' file not found
     54 | #include <pybind11/pybind11.h>
        |          ^~~~~~~~~~~~~~~~~~~~~
  1 error generated.
  ninja: build stopped: subcommand failed.
  error: subprocess-exited-with-error

@QuLogic
Copy link
Member

QuLogic commented Mar 20, 2025

-I/opt/homebrew/opt/pybind11/include

This doesn't look right. Do you have the wrong pybind11-config in your path somehow? Or is uv pip not adding it to your path like it should?

@dstansby
Copy link
Member Author

Ah, thanks - I have no idea why that's where the build is trying to find the pybind11 headers, perhaps because I installed and uninstalled it in the past using brew? Anyway, I've installed pybind11 again globally using brew and it seems to be working now. I'll close this, and if I manage to reproduce again I'll open a fresh issue.

@user202729
Copy link

user202729 commented Apr 25, 2025

I tracked this issue down. It happens when e.g. no pybind11 is installed globally but pybind11 is installed locally in user's home directly.

Global install can be done with sudo pacman -S pybind11 (if Arch). Local install can be done with pip install --user pybind11.

The reason is the following.

  1. Matplotlib uses meson dependency function to find pybind11.
  2. meson has custom logic that calls pybind11-config executable https://github.com/mesonbuild/meson/blob/1.7.2/mesonbuild/dependencies/python.py#L48-L63
  3. the pybind11-config executable returns sysconfig.get_path("include") https://github.com/pybind/pybind11/blob/v2.13.6/pybind11/__main__.py#L35-L40
  4. if it does that in pip isolated environment, it will return the include path to the temporary overlay environment instead. (/tmp/pip-build-env-???/overlay) If you pass --verbose to pip then you can search for overlay in the log to see this is the cause.

I'd say the cause is at pybind11-config. Meson and matplotlib just invoke it.

Temporary workaround is of course to install globally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants