Skip to content

[BUG]: MacMini M4 clang does not properly support pybind11  #5455

Open
@bgold04

Description

@bgold04

Required prerequisites

What version (or hash if on master) of pybind11 are you using?

pybind11-2.13.6

Problem description

#macOS version (macOS 15.1.1).
#Python version (Python 3.10.0).
#pybind11 version (pybind11-2.13.6 installed via pip).
#Apple clang version 16.0.0 (clang-1600.0.26.4)
#Target: arm64-apple-darwin24.1.0

The code below tests clang for a pybind11 requiring compilation on the system described above using example.cpp as target. The expectation is that example.so will be created. That example is not created and instead results in an error message having to do with an inavailability of pybind11.h Several compile attempts were made using different parameters.

Reproducible example code

#macOS version (macOS 15.1.1).
#Python version (Python 3.10.0).
#pybind11 version (pybind11-2.13.6 installed via pip).
#Apple clang version 16.0.0 (clang-1600.0.26.4)
#Target: arm64-apple-darwin24.1.0

example.cpp

include <pybind11/pybind11.h>

namespace py = pybind11;

int add(int i, int j) {
    return i + j;
}

PYBIND11_MODULE(example, m) {
    m.def("add", &add, "A function which adds two numbers");
}

______________________

clang++ -std=c++11 -shared -fPIC `python3 -m pybind11 --includes` example.cpp -o example.so

Also tried

clang++ -std=c++11 -shared -fPIC $(python3-config --includes) example.cpp -L$(python3-config --libdir) -lpython3.10 -o example.so

_________________________

example.so is expected but none is found.  Error message is:
Usage: /Users/bgold/.pyenv/versions/3.10.0/bin/python3-config [--prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir|--embed]
example.cpp:1:10: fatal error: 'pybind11/pybind11.h' file not found
    1 | #include <pybind11/pybind11.h>
      |          ^~~~~~~~~~~~~~~~~~~~~
1 error generated.

________________________________________

NB: ls -l env/lib/python3.10/site-packages/pybind11/include/pybind11/pybind11.h
-rw-r--r--  1 user  staff  129898 Nov 28 08:09 env/lib/python3.10/site-packages/pybind11/include/pybind11/pybind11.h

Is this a regression? Put the last known working version here if it is.

Not a regression

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageNew bug, unverified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions