[BUG]: MacMini M4 clang does not properly support pybind11
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18k
- Forks
- 2.3k
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 10
Description
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided example.cpp and reproduce the clang++ command using the pybind11 installation under env/lib/python3.10/site-packages. Check the output of python3 -m pybind11 --includes and whether the reported include path resolves; done means the command finds pybind11/pybind11.h and creates example.so on the stated macOS and Python setup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100