diff --git a/package/python-pybind/0001-pybind11-commands.py-support-STAGING_DIR.patch b/package/python-pybind/0001-pybind11-commands.py-support-STAGING_DIR.patch new file mode 100644 index 0000000000..981a387be4 --- /dev/null +++ b/package/python-pybind/0001-pybind11-commands.py-support-STAGING_DIR.patch @@ -0,0 +1,36 @@ +From 9feaba4792c1d0a28e560ae941fa9ebabbbe4013 Mon Sep 17 00:00:00 2001 +From: "Arnout Vandecappelle (Essensium/Mind)" +Date: Fri, 7 Jan 2022 19:32:18 +0100 +Subject: [PATCH] pybind11/commands.py: support STAGING_DIR + +In Buildroot, we install build-time python scripts in the host directory +(otherwise they can't be run with host python), but when running +pybind11 --includes it should return the staging directory. + +Patch commands.py to use the STAGING_DIR environment variable instead of +the current directory, if it is set. + +Signed-off-by: Arnout Vandecappelle (Essensium/Mind) +Upstream-Status: N/A, Buildroot specific +--- + pybind11/commands.py | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/pybind11/commands.py b/pybind11/commands.py +index 34dbaf8..8c4876d 100644 +--- a/pybind11/commands.py ++++ b/pybind11/commands.py +@@ -1,8 +1,8 @@ + # -*- coding: utf-8 -*- + import os + +- +-DIR = os.path.abspath(os.path.dirname(__file__)) ++DIR = os.environ.get('STAGING_DIR') or \ ++ os.path.abspath(os.path.dirname(__file__)) + + + def get_include(user=False): +-- +2.31.1 + diff --git a/package/python-pybind/Config.in b/package/python-pybind/Config.in index 604cb9ee67..27bc196e32 100644 --- a/package/python-pybind/Config.in +++ b/package/python-pybind/Config.in @@ -1,5 +1,6 @@ config BR2_PACKAGE_PYTHON_PYBIND bool "python-pybind" + depends on BR2_PACKAGE_PYTHON3 help PyBind is a lightweight header-only library that exposes C++ types in Python and vice versa, mainly to create Python diff --git a/package/python-pybind/python-pybind.mk b/package/python-pybind/python-pybind.mk index a6a1bdb976..4dd52003ad 100644 --- a/package/python-pybind/python-pybind.mk +++ b/package/python-pybind/python-pybind.mk @@ -8,6 +8,21 @@ PYTHON_PYBIND_VERSION = 2.6.1 PYTHON_PYBIND_SITE = $(call github,pybind,pybind11,v$(PYTHON_PYBIND_VERSION)) PYTHON_PYBIND_LICENSE = BSD-3-Clause PYTHON_PYBIND_LICENSE_FILES = LICENSE -PYTHON_PYBIND_SETUP_TYPE = setuptools +PYTHON_PYBIND_INSTALL_STAGING = YES +PYTHON_PYBIND_INSTALL_TARGET = NO # Header-only library +PYTHON_PYBIND_DEPENDENCIES = python3 -$(eval $(python-package)) +PYTHON_PYBIND_CONF_OPTS = \ + -DPYBIND11_INSTALL=ON \ + -DPYBIND11_TEST=OFF \ + -DPYBIND11_NOPYTHON=ON + +PYTHON_PYBIND_INSTALL_PATH = $(HOST_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/site-packages/pybind11 + +define PYTHON_PYBIND_INSTALL_MODULE + mkdir -p $(PYTHON_PYBIND_INSTALL_PATH) + cp -dpf $(@D)/pybind11/*.py $(PYTHON_PYBIND_INSTALL_PATH) +endef +PYTHON_PYBIND_POST_INSTALL_STAGING_HOOKS += PYTHON_PYBIND_INSTALL_MODULE + +$(eval $(cmake-package))