new file mode 100644
@@ -0,0 +1,48 @@
+From aeee170bc90d89973268f286c8bfa12afd8f330c Mon Sep 17 00:00:00 2001
+From: "Guillaume W. Bres" <guillaume.bressaix@gmail.com>
+Date: Thu, 9 Dec 2021 20:30:08 +0100
+Subject: [PATCH] setup.py: improve cmake context definition
+
+Use two env. variables to define which cmake
+is internally called and pass a toolchain file
+for complex cross-compilation contexts.
+
+Signed-off-by: Guillaume W. Bres <guillaume.bressaix@gmail.com>
+---
+ setup.py | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/setup.py b/setup.py
+index 3a03279..2dff721 100644
+--- a/setup.py
++++ b/setup.py
+@@ -23,6 +23,8 @@ VERSION_REGEX = re.compile(
+ # files, and the sys.prefix files (CMake and headers).
+
+ global_sdist = os.environ.get("PYBIND11_GLOBAL_SDIST", False)
++global_cmake = os.environ.get("PYBIND11_CMAKE", "unknown")
++global_cmake_toolchain_file = os.environ.get("PYBIND11_CMAKE_TOOLCHAIN_FILE", "unknown")
+
+ setup_py = "tools/setup_global.py.in" if global_sdist else "tools/setup_main.py.in"
+ extra_cmd = 'cmdclass["sdist"] = SDist\n'
+@@ -101,14 +103,15 @@ def remove_output(*sources):
+ with remove_output("pybind11/include", "pybind11/share"):
+ # Generate the files if they are not present.
+ with TemporaryDirectory() as tmpdir:
+- cmd = ["cmake", "-S", ".", "-B", tmpdir] + [
++ cmd = [global_cmake, "-S", ".", "-B", tmpdir] + [
+ "-DCMAKE_INSTALL_PREFIX=pybind11",
++ "-DCMAKE_TOOLCHAIN_FILE={:s}".format(global_cmake_toolchain_file),
+ "-DBUILD_TESTING=OFF",
+ "-DPYBIND11_NOPYTHON=ON",
+ ]
+ cmake_opts = dict(cwd=DIR, stdout=sys.stdout, stderr=sys.stderr)
+ subprocess.check_call(cmd, **cmake_opts)
+- subprocess.check_call(["cmake", "--install", tmpdir], **cmake_opts)
++ subprocess.check_call([global_cmake, "--install", tmpdir], **cmake_opts)
+
+ txt = get_and_replace(setup_py, version=version, extra_cmd=extra_cmd)
+ code = compile(txt, setup_py, "exec")
+--
+1.8.3.1
+
@@ -10,4 +10,51 @@ PYTHON_PYBIND_LICENSE = BSD-3-Clause
PYTHON_PYBIND_LICENSE_FILES = LICENSE
PYTHON_PYBIND_SETUP_TYPE = setuptools
+# Only installs header files
+PYTHON_PYBIND_INSTALL_TARGET = NO
+PYTHON_PYBIND_INSTALL_STAGING = YES
+
+# their cmakelist.txt file needs a recent cmake
+PYTHON_PYBIND_DEPENDENCIES += $(BR2_CMAKE_HOST_DEPENDENCY)
+HOST_PYTHON_PYBIND_DEPENDENCIES += $(BR2_CMAKE_HOST_DEPENDENCY)
+
+# every single setup.py interaction calls 'cmake' (as is) intrinsicly.
+# we deliver a patch to customize setup.py to define the cmake context
+# using the following variables
+PYTHON_PYBIND_MAKE_ENV = $(MAKE_ENV)
+PYTHON_PYBIND_SETUPTOOLS_ENV = $(PKG_PYTHON_SETUPTOOLS_ENV)
+PYTHON_PYBIND_SETUPTOOLS_ENV += PYBIND11_CMAKE=$(BR2_CMAKE)
+PYTHON_PYBIND_SETUPTOOLS_ENV += PYBIND11_CMAKE_TOOLCHAIN_FILE=$(HOST_DIR)/share/buildroot/toolchainfile.cmake
+
+HOST_PYTHON_PYBIND_MAKE_ENV = $(MAKE_ENV)
+HOST_PYTHON_PYBIND_SETUPTOOLS_ENV = $(PKG_PYTHON_SETUPTOOLS_ENV)
+HOST_PYTHON_PYBIND_SETUPTOOLS_ENV += PYBIND11_CMAKE=$(BR2_CMAKE)
+HOST_PYTHON_PYBIND_SETUPTOOLS_ENV += PYBIND11_CMAKE_TOOLCHAIN_FILE=$(HOST_DIR)/share/buildroot/toolchainfile.cmake
+
+define PYTHON_PYBIND_BUILD_CMDS
+ cd $(@D); \
+ $(PYTHON_PYBIND_SETUPTOOLS_ENV) $(HOST_DIR)/usr/bin/python setup.py build
+endef
+
+define HOST_PYTHON_PYBIND_BUILD_CMDS
+ cd $(@D); \
+ $(PYTHON_PYBIND_SETUPTOOLS_ENV) $(HOST_DIR)/usr/bin/python setup.py build
+endef
+
+# define installation destinations properly
+define PYTHON_PYBIND_INSTALL_STAGING_CMDS
+ cd $(@D); \
+ $(PYTHON_PYBIND_SETUPTOOLS_ENV) \
+ PREFIX=$(STAGING_DIR)/usr \
+ $(HOST_DIR)/bin/python setup.py install
+endef
+
+define HOST_PYTHON_PYBIND_INSTALL_CMDS
+ cd $(@D); \
+ $(PYTHON_PYBIND_SETUPTOOLS_ENV) \
+ PREFIX=$(HOST_DIR)/usr \
+ $(HOST_DIR)/bin/python setup.py install
+endef
+
$(eval $(python-package))
+$(eval $(host-python-package))