I'm trying to compile code that uses xtensor-python, but with bazel.
On macOS, I get the error: "fatal error: 'numpy/arrayobject.h' file not found". Fair enough - it cannot find the numpy include headers. I know where they are - they are in "/opt/homebrew/lib/python3.11/site-packages/numpy/core/include". But for the life of me, I can't figure out how to tell bazel that. Main question: how to get it to work on macOS?
On linux, it compiles fine. How? On linux, that file is in /usr/lib/python3/dist-packages/numpy/core/include/. I'm never telling bazel about that. How does it find it? I see that cmake does some fancy finding stuff, but my bazel lib doesn't...
In WORKSPACE I have
http_archive(
name = "xtensor_python",
build_file = "//third_party:xtensor_python.BUILD",
sha256 = "72a29daba0844b251296e99bb616f8dfe16b32d6f416fba22245ffd51eb6f4a4",
strip_prefix = "xtensor-python-0.26.1",
url = "https://github.com/xtensor-stack/xtensor-python/archive/0.26.1.zip",
)
and later
pybind_library(
name = "xtensor_python",
hdrs = glob(["include/xtensor-python/*.hpp"]),
includes = ["include"],
visibility = ["//visibility:public"],
deps = ["@xtensor"], # <- elided for brevity
)
pybind_extension(
name = "my_python_lib_ext",
srcs = [ "pybindings.cpp" ],
copts = ["-std=c++20"],
visibility = ["//visibility:public"],
deps = [
"//third_party:xtensor_python",
],
)