From 39b2b6e4a303e8b108a599670c71d0b2ea2e055f Mon Sep 17 00:00:00 2001 From: Romain Naour Date: Wed, 18 Feb 2026 23:04:35 +0100 Subject: [PATCH] package/python-pybind: overwrite 'pybind11/_version.py' with a hard-coded version Fixes build error with python-pillow since its version bump to 12.0.0 which introduced a dependency to pybind with buildroot commit 5f446a8d6dd8715385d6e2df2714f064bf26243d: FileNotFoundError: [Errno 2] No such file or directory: '/home/bernd/buildroot/output/host/lib/python3.13/site-packages/include/pybind11/detail/common.h' Implement the solution suggested by Vincent Fazio [1]: Generate `pybind11/_version.py` file with a hard-coded version to avoid copying pybind11 headers in HOST_DIR. Fixes: https://gitlab.com/buildroot.org/buildroot/-/jobs/13138981946 (TestPythonPybind) [1] https://lists.busybox.net/pipermail/buildroot/2026-February/796082.html Cc: Vincent Fazio Cc: James Hilliard Cc: Bernd Kuhls Signed-off-by: Romain Naour Tested-by: Vincent Fazio Signed-off-by: Julien Olivain --- package/python-pybind/python-pybind.mk | 7 +++++++ package/python-pybind/python-pybind_version.py.in | 12 ++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 package/python-pybind/python-pybind_version.py.in diff --git a/package/python-pybind/python-pybind.mk b/package/python-pybind/python-pybind.mk index 7282c058f6..cdafc9d4c0 100644 --- a/package/python-pybind/python-pybind.mk +++ b/package/python-pybind/python-pybind.mk @@ -19,9 +19,16 @@ PYTHON_PYBIND_CONF_OPTS = \ PYTHON_PYBIND_INSTALL_PATH = $(HOST_DIR)/lib/python$(PYTHON3_VERSION_MAJOR)/site-packages/pybind11 +# Overwrite 'pybind11/_version.py' with a hard-coded version to replace +# 'pybind11/_version.py' installed by default that require +# pybind11/detail/common.h header in HOST_DIR. +# https://github.com/pybind/pybind11/blob/f5fbe867d2d26e4a0a9177a51f6e568868ad3dc8/pyproject.toml#L93 define PYTHON_PYBIND_INSTALL_MODULE mkdir -p $(PYTHON_PYBIND_INSTALL_PATH) cp -dpf $(@D)/pybind11/*.py $(PYTHON_PYBIND_INSTALL_PATH) + sed -e 's#@@PYBIND_VERSION@@#$(PYTHON_PYBIND_VERSION)#' \ + $(PYTHON_PYBIND_PKGDIR)/python-pybind_version.py.in \ + > $(PYTHON_PYBIND_INSTALL_PATH)/_version.py endef PYTHON_PYBIND_POST_INSTALL_STAGING_HOOKS += PYTHON_PYBIND_INSTALL_MODULE diff --git a/package/python-pybind/python-pybind_version.py.in b/package/python-pybind/python-pybind_version.py.in new file mode 100644 index 0000000000..c4cc5d074d --- /dev/null +++ b/package/python-pybind/python-pybind_version.py.in @@ -0,0 +1,12 @@ +from __future__ import annotations + + +def _to_int(s: str) -> int | str: + try: + return int(s) + except ValueError: + return s + + +__version__ = "@@PYBIND_VERSION@@" +version_info = tuple(_to_int(s) for s in __version__.split("."))