From patchwork Tue Jan 4 12:38:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Bres X-Patchwork-Id: 1575229 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=JUJEhWHG; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=buildroot.org (client-ip=140.211.166.133; helo=smtp2.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JSsdD21gYz9t0k for ; Tue, 4 Jan 2022 23:39:44 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 8A7DB40156; Tue, 4 Jan 2022 12:39:41 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TyEKoHhWUm3A; Tue, 4 Jan 2022 12:39:40 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp2.osuosl.org (Postfix) with ESMTP id 416AC401CA; Tue, 4 Jan 2022 12:39:39 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id D387A1BF288 for ; Tue, 4 Jan 2022 12:39:37 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id C22B982881 for ; Tue, 4 Jan 2022 12:39:37 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ixDRxNRy6Van for ; Tue, 4 Jan 2022 12:39:36 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by smtp1.osuosl.org (Postfix) with ESMTPS id 90BA3818D0 for ; Tue, 4 Jan 2022 12:39:36 +0000 (UTC) Received: by mail-wr1-x42f.google.com with SMTP id i22so75887337wrb.13 for ; Tue, 04 Jan 2022 04:39:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oJ27Vm0FtdWBJvouoH8IqDU2IeyOva6QRGRdEU/hFRk=; b=JUJEhWHG81RrDpoU2aKieGwzGcyDmx5+uDZMhMo4yL4ZC70lkF/EbevMLKDwgwKBgK 21dN6gwv5aAvPN7++uc0lucmPCmcC5qAk+2nZh+6VhInra6fx/F9oAN+WjV1KEBy3StD D1/KsowzNOo5Z4haJnXqnoOvPEuPbUXYwbu++xkhMrkPUxjvwK9oIURFiU5ZzBCh0LwE WmEKPB9kq1LknWt/Fuz2wUcFPi4VR4aRU5StpbjTjMFdi70GPNeS86aobTYXlv/YWe1U Loslp2YbqpaoeceLktNy+lMUiucgYUMLYbV4gFn1O98DTBHQAqkmqykv/yi/j+BQV8/E 2/sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oJ27Vm0FtdWBJvouoH8IqDU2IeyOva6QRGRdEU/hFRk=; b=6w4c/Scny93y8qu7xqsAre+N/md168Q6rrZDLdkBI6L/KZAKEErA1BAcgFGMvMU70X 5wh2gcr0js9tP5wQM52havdW4TNWA2AiFDBDlcs0Z/kscq+3dCk5NEcTMm6OlT0X5IZC qiG2ws+Tw1wz8H2p0Xv7zrP+glR9q7ejYTDlXr6bAyKDqEWRONxiaq99pjyv7oANdmbL YVwE5rap6zHzYWDGphD53LFs5V17JuCovi+/wfcM6sj8HBkjZBe/nQYV0LvqeGI0aTSL YSRq0fJEu1G1GKiz3sBnS4gKv+T33YSGOkF+ZTEdeIukVQBHx5J2N2PMXXA1RFQNcBTk HYUg== X-Gm-Message-State: AOAM533umHgAt73BNk3tK3TVccZyUfB259kb/MDjhxA1Hv67A457w8Uj xQAKksx5+0vBjkBZj/Rwl80pwNKKmFQ= X-Google-Smtp-Source: ABdhPJxo8sR+1tiwjbwNuZnW+3+0ASrXVUS0jwcQ4mVnH3wS+ZeuG1AZJ/x+iRJRLFrLxE8X4ljJZg== X-Received: by 2002:a5d:6c68:: with SMTP id r8mr41445511wrz.281.1641299974415; Tue, 04 Jan 2022 04:39:34 -0800 (PST) Received: from pc-140.home ([2a01:cb15:81e5:ad00:7afb:407b:e9ac:7e79]) by smtp.gmail.com with ESMTPSA id g7sm38712303wrx.104.2022.01.04.04.39.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jan 2022 04:39:34 -0800 (PST) From: guillaume.bressaix@gmail.com To: buildroot@busybox.net Date: Tue, 4 Jan 2022 13:38:59 +0100 Message-Id: <20220104123901.23929-1-guillaume.bressaix@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Buildroot] [PATCH v2 1/3] package/python-pybind: fix upgrade to 2.6.1 X-BeenThere: buildroot@buildroot.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tomi.valkeinen@ideasonboard.com, yann.morin.1998@free.fr, "Guillaume W. Bres" Errors-To: buildroot-bounces@buildroot.org Sender: "buildroot" From: "Guillaume W. Bres" Fixes http://autobuild.buildroot.net/results/b89f1de64b308dffa73675f1f31ccb0b7be5a10d http://autobuild.buildroot.net/results/d0287b7f64f206b0f074908c5780a3632e0cb799 http://autobuild.buildroot.net/results/27efb545a5a719a5581c8f746d3a3555ff4216ce http://autobuild.buildroot.net/results/d2f0a0ad8f6c7178517df109e7d885dac9134c3a http://autobuild.buildroot.net/results/b57e9a3279260dae4a590f9421238fcabb2f7cab http://autobuild.buildroot.net/results/515e6f2fc6b5780260d98d6bb52b541ce4bf1afe http://autobuild.buildroot.net/results/d89c4ecc81222d4f80c951da2232d2e393fa1c69 Signed-off-by: Guillaume W. Bres --- setup.py now calls 'cmake', as is, internally, with DESTDIR=$(@D) to provide some setup.py build requirements. The autobuild failures were actually of different kinds: (1) 'cmake' too old causes an early crash as it is unable to parse their CMakeList.txt (host machine dependent) (2) $(@D)/pybind missing because cmake call was faulty (happened all the time) The provided patch allows us to fully control the hidden cmake context: * which 'cmake' is actually called is important, as most of the time we end up using /usr/bin/cmake. By adding BR2_CMAKE_DEPENDENCY we make sure (1) never happens and (2) is always solved with a complete cmake context control. We could convert python-pybind to a cmake package but it involves so much patching and tweaking (mostly for the python install), that it is now clear that keeping the package as is, is the best option. I also fixed the previous package declaration / handling: * this is a header only lib, so installing to target does not make sense, and installing to staging is mandatory * most of the time, this package will be used at compile time, on host, so having the host-package option is mandatory. This package is then used to customize the host/usr/python capacity, with C++ macro bindings. This patch serie provides an example of use, that does exactly that, and works for both python2 and python3 (refer to following patch) --- ...-py-improve-cmake-context-definition.patch | 48 +++++++++++++++++++ package/python-pybind/python-pybind.mk | 47 ++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 package/python-pybind/0001-setup-py-improve-cmake-context-definition.patch diff --git a/package/python-pybind/0001-setup-py-improve-cmake-context-definition.patch b/package/python-pybind/0001-setup-py-improve-cmake-context-definition.patch new file mode 100644 index 0000000000..0952d44464 --- /dev/null +++ b/package/python-pybind/0001-setup-py-improve-cmake-context-definition.patch @@ -0,0 +1,48 @@ +From aeee170bc90d89973268f286c8bfa12afd8f330c Mon Sep 17 00:00:00 2001 +From: "Guillaume W. Bres" +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 +--- + 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 + diff --git a/package/python-pybind/python-pybind.mk b/package/python-pybind/python-pybind.mk index a6a1bdb976..442ed3328f 100644 --- a/package/python-pybind/python-pybind.mk +++ b/package/python-pybind/python-pybind.mk @@ -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)) From patchwork Tue Jan 4 12:39:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Bres X-Patchwork-Id: 1575230 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=WvkXdz/3; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=buildroot.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JSsdS0djjz9t0k for ; Tue, 4 Jan 2022 23:39:56 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 0E35560BD0; Tue, 4 Jan 2022 12:39:54 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ReKNx9x3DDg6; Tue, 4 Jan 2022 12:39:53 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id 5CEAC60AB0; Tue, 4 Jan 2022 12:39:52 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 507531BF288 for ; Tue, 4 Jan 2022 12:39:48 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 3C63482881 for ; Tue, 4 Jan 2022 12:39:48 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5LtY7QrvlWrX for ; Tue, 4 Jan 2022 12:39:47 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by smtp1.osuosl.org (Postfix) with ESMTPS id 9836C818D0 for ; Tue, 4 Jan 2022 12:39:47 +0000 (UTC) Received: by mail-wm1-x336.google.com with SMTP id k66-20020a1ca145000000b00345fa984108so1359884wme.2 for ; Tue, 04 Jan 2022 04:39:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mAXznq9fAYs8W1+7sXalu1lGzjV7+vPh2vsmXHbaWM8=; b=WvkXdz/389NSh8yLt3edoCHieokkJAXSSmU6CF8Mb4mRBupmjGEXMP9lt2qBE90s54 991yFBc9eZnQTniZdlmD0wboKHyuZM0xpbk76buSvXuDMK8EesKHfwW6ZfVRQCbyIWxi dSnUkkLoGNAyV9wr5zk4yF0yGPGz+6F11CRhTzZKRhXBKvVboiNRQm2uanfNJd11nHqP FRkF60ALy0xOvH79hNTO5j6FgtWV4CL0QQsOElvTCZZgNYMZmjrdOay+2u99UhiPA5rI G/wzqLI5K8ctsVasAfkXSr/J19FY2DhvsKjNLrS8uiWIoExIhJbz4SfXWzFuDKkGMb37 0VBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mAXznq9fAYs8W1+7sXalu1lGzjV7+vPh2vsmXHbaWM8=; b=zwtK00h4qbdOJfDMaR6eKeE9BBQRzwiG3LN6t6cusLORIhuFQe/reXT5Fyoq0X3Cr3 8Nd9glvmzfcW8QRF1rm7otSzSaGE5XiNLR0caoxtkv/nYp3TSmab+c13+lyElejJwQ0+ UjVXo1GWwdUVBTLQlqMN0evg6/exaU5Alb0tmCcQIyI9t2REku/K31thqdgL6ycIXqQF FW8inRQgI1KbmNCaq/JJALerqIAq83RGRBN/luCvpWioTpgK6mhKa4Kh1GSKw2oqL1IM 6I3BqDw+YkxhE4atvyGatoE62C12HtIWta7vJE15rWI/GckJAldfR3SpCJBQw6JBox6u XySg== X-Gm-Message-State: AOAM532cKt74bpFjJ+R9rfBsrvnYE0yMODQT6e2Ad6MA/QrnhbX9j5NC 8LObD/dSceuGrkdl3/dOS8ZZCnBcfTY= X-Google-Smtp-Source: ABdhPJx94tDLsaa5YsmkL7mzyk8N7I2bvbJqd5Ou9mYeNl/28hwzyP9SOqddnkefeYsxj0ZfxTvqYg== X-Received: by 2002:a1c:440a:: with SMTP id r10mr42588371wma.4.1641299985789; Tue, 04 Jan 2022 04:39:45 -0800 (PST) Received: from pc-140.home ([2a01:cb15:81e5:ad00:7afb:407b:e9ac:7e79]) by smtp.gmail.com with ESMTPSA id g7sm38712303wrx.104.2022.01.04.04.39.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jan 2022 04:39:45 -0800 (PST) From: guillaume.bressaix@gmail.com To: buildroot@busybox.net Date: Tue, 4 Jan 2022 13:39:00 +0100 Message-Id: <20220104123901.23929-2-guillaume.bressaix@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220104123901.23929-1-guillaume.bressaix@gmail.com> References: <20220104123901.23929-1-guillaume.bressaix@gmail.com> MIME-Version: 1.0 Subject: [Buildroot] [PATCH v2 2/3] package/python-pybind: bump to version 2.8.1 X-BeenThere: buildroot@buildroot.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tomi.valkeinen@ideasonboard.com, yann.morin.1998@free.fr, "Guillaume W. Bres" Errors-To: buildroot-bounces@buildroot.org Sender: "buildroot" From: "Guillaume W. Bres" Signed-off-by: Guillaume W. Bres --- package/python-pybind/python-pybind.hash | 2 +- package/python-pybind/python-pybind.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package/python-pybind/python-pybind.hash b/package/python-pybind/python-pybind.hash index a68ac846e2..e1d86a4494 100644 --- a/package/python-pybind/python-pybind.hash +++ b/package/python-pybind/python-pybind.hash @@ -1,4 +1,4 @@ # Locally calculated -sha256 cdbe326d357f18b83d10322ba202d69f11b2f49e2d87ade0dc2be0c5c34f8e2a python-pybind-2.6.1.tar.gz +sha256 f1bcc07caa568eb312411dde5308b1e250bd0e1bc020fae855bf9f43209940cc python-pybind-2.8.1.tar.gz # License files, locally calculated sha256 83965b843b98f670d3a85bd041ed4b372c8ec50d7b4a5995a83ac697ba675dcb LICENSE diff --git a/package/python-pybind/python-pybind.mk b/package/python-pybind/python-pybind.mk index 442ed3328f..cf6a642922 100644 --- a/package/python-pybind/python-pybind.mk +++ b/package/python-pybind/python-pybind.mk @@ -4,7 +4,7 @@ # ################################################################################ -PYTHON_PYBIND_VERSION = 2.6.1 +PYTHON_PYBIND_VERSION = 2.8.1 PYTHON_PYBIND_SITE = $(call github,pybind,pybind11,v$(PYTHON_PYBIND_VERSION)) PYTHON_PYBIND_LICENSE = BSD-3-Clause PYTHON_PYBIND_LICENSE_FILES = LICENSE From patchwork Tue Jan 4 12:39:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Bres X-Patchwork-Id: 1575231 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=Trrg2Vkc; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=buildroot.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JSsdj12DRz9t0k for ; Tue, 4 Jan 2022 23:40:08 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 59161409A9; Tue, 4 Jan 2022 12:40:06 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uJxkhMjDA9R0; Tue, 4 Jan 2022 12:40:05 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id 5F5A5409B4; Tue, 4 Jan 2022 12:40:04 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id A14011BF288 for ; Tue, 4 Jan 2022 12:39:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 902F682881 for ; Tue, 4 Jan 2022 12:39:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id psYYU3bHbIGT for ; Tue, 4 Jan 2022 12:39:52 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by smtp1.osuosl.org (Postfix) with ESMTPS id 29397818D0 for ; Tue, 4 Jan 2022 12:39:52 +0000 (UTC) Received: by mail-wr1-x431.google.com with SMTP id o3so17708104wrh.10 for ; Tue, 04 Jan 2022 04:39:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gOKwggmzs3ys+4qxBj5ogDOwZ04VRiaRGE1C858jtmA=; b=Trrg2VkcBuZz+MExyaFglzk+dqMqBhEmToQYfnhWlAvNLAJBdq0mB1RRRk96deRMwN MvotOck/z2nUWsfFsO4n6q5SpaCkxSc4ytmfSCB8d345I0/cTKN5CtooDmN4T9AkAQUC jNFUMFAwLjYBT/x8+4ULQsU6TIL4G5U95cwzb6HMqz0nkivYlxw5+NX6HwWQqgAt26DR gYHUBUhunqJZ1RS+BvdXSSjsR4VuVUkLLS+CofDNLD651FR2b5Xpxbr1ER+GVNJKH9np IcSC/jjw5tkG/ClccuNy6x5i4fhoQ/Q8yUO/1EalU+/pCGc+ptEpGupnQ6DJextlWMZP dY9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gOKwggmzs3ys+4qxBj5ogDOwZ04VRiaRGE1C858jtmA=; b=EnwVQ05fAashnEZ4b7bWWcZyKr5P1r1xH3HcWsVva9seQ49m4DOgGGfI1cyw8FXkiY plaZfLFHdZUo10S1bqh6el+GAAvgIcNTZ2LgYYYQOaKVudij98K0GcqHVPcOKQv1JeGh HgzSgJofnnWlNZpGrJ29Owq05OdK/f2RSyjoRLEeCZ5W9DeP8fGPhyWyMysw+r+6KOVG GPvJ1jVlHkLKii8vv5AjNPIhbkHHeRf+IFMINVmU4eaEAJ/2Rgux+WfOkMmbdeXYqKBD EWWx9V2jAv3GmLfPu35LAxXXo1GBXWXVCDODED4OVhoKvFL4vmhouqoZTVk2fiEYzAFZ gzfA== X-Gm-Message-State: AOAM531abutdt9EG2aEcWv5CuIOhkGfOadvVNoqpxkldDWtkkK0fzO4i WLCol4ZuUKKmxjZLAZfV9YQacGpehRQ= X-Google-Smtp-Source: ABdhPJy1b2gWJqruEnaTCUzcfxf1LP44/c+YAnCLNmNTwX7N5Ip65Jmwm2RvOzljKg8rq11Hf2/SiA== X-Received: by 2002:a05:6000:18aa:: with SMTP id b10mr42539282wri.305.1641299990241; Tue, 04 Jan 2022 04:39:50 -0800 (PST) Received: from pc-140.home ([2a01:cb15:81e5:ad00:7afb:407b:e9ac:7e79]) by smtp.gmail.com with ESMTPSA id g7sm38712303wrx.104.2022.01.04.04.39.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jan 2022 04:39:50 -0800 (PST) From: guillaume.bressaix@gmail.com To: buildroot@busybox.net Date: Tue, 4 Jan 2022 13:39:01 +0100 Message-Id: <20220104123901.23929-3-guillaume.bressaix@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220104123901.23929-1-guillaume.bressaix@gmail.com> References: <20220104123901.23929-1-guillaume.bressaix@gmail.com> MIME-Version: 1.0 Subject: [Buildroot] [PATCH v2 3/3] support/testing: add test for python-pybind X-BeenThere: buildroot@buildroot.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tomi.valkeinen@ideasonboard.com, yann.morin.1998@free.fr, "Guillaume W. Bres" Errors-To: buildroot-bounces@buildroot.org Sender: "buildroot" From: "Guillaume W. Bres" python-pybind is a header only library, most of the time used as a host-package, to customize the host/usr/python interpreter capacity (at build time) with C++ based features. Signed-off-by: Guillaume W. Bres --- This test case enhances the /host/usr/python interpreter with a C++ macro. The test delivers a C++ macro contained in its br-external/example.cpp. We compile it against the host context. We install it to $(HOST_DIR)/usr/lib/python3.9 as it is natively contained in the host-python system path (import is easy). The macro is an integer adder, written in C++ that we can now call in host-python. The test infrastructure should actually be declared "host-generic-package" instead of "generic-package", to be consistent with Buildroot infrastructure. But I am not able to get this to actually do anything, if I declare this package as a host-generic and "Config.in.host" instead of "Config.in". To me, this is not too important * TestPythonPybind allows testing for both Py2 and Py3 like it is done in many other packages * TestPythonPybind does not inherit from TestPythonPackageBase as usually done (1) because I need the br2-external feature to ship the example.cpp containing the custom macro (2) because TestPythonPackageBase always involves the emulator, which we do not want in our context * Although TestPythonPybind does have a TestPythonBase.config base at the same time, as it is most convenient to have a valid python context * TestPythonPybind uses subprocess, as similarly done in 'core' on 'infra' test cases, because we do not involve the emulator * TestPythonPybind tests (1+2)=3 written in C++, used in Python 2/3 * TestPythonPybind tests a custom module attribute, written in C++, used in Python 2/3 --- DEVELOPERS | 3 ++ .../br2-external/python-pybind/Config.in | 1 + .../br2-external/python-pybind/external.desc | 1 + .../br2-external/python-pybind/external.mk | 1 + .../package/python-pybind-example/Config.in | 5 ++ .../package/python-pybind-example/example.cpp | 16 +++++++ .../python-pybind-example.mk | 47 ++++++++++++++++++ .../tests/package/sample_python_pybind.py | 4 ++ .../tests/package/test_python_pybind.py | 48 +++++++++++++++++++ 9 files changed, 126 insertions(+) create mode 100644 support/testing/tests/package/br2-external/python-pybind/Config.in create mode 100644 support/testing/tests/package/br2-external/python-pybind/external.desc create mode 100644 support/testing/tests/package/br2-external/python-pybind/external.mk create mode 100644 support/testing/tests/package/br2-external/python-pybind/package/python-pybind-example/Config.in create mode 100644 support/testing/tests/package/br2-external/python-pybind/package/python-pybind-example/example.cpp create mode 100644 support/testing/tests/package/br2-external/python-pybind/package/python-pybind-example/python-pybind-example.mk create mode 100644 support/testing/tests/package/sample_python_pybind.py create mode 100644 support/testing/tests/package/test_python_pybind.py diff --git a/DEVELOPERS b/DEVELOPERS index 21e4f2a84c..130ac3db73 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -1120,6 +1120,9 @@ F: package/liquid-dsp/ F: package/pixiewps/ F: package/python-pybind/ F: package/reaver/ +F: support/testing/tests/package/br2-external/python-pybind +F: support/testing/tests/package/sample_python_pybind.py +F: support/testing/tests/package/test_python_pybind.py N: Guo Ren F: arch/Config.in.csky diff --git a/support/testing/tests/package/br2-external/python-pybind/Config.in b/support/testing/tests/package/br2-external/python-pybind/Config.in new file mode 100644 index 0000000000..70c77157b3 --- /dev/null +++ b/support/testing/tests/package/br2-external/python-pybind/Config.in @@ -0,0 +1 @@ +source "$BR2_EXTERNAL_PYTHON_PYBIND_PATH/package/python-pybind-example/Config.in" diff --git a/support/testing/tests/package/br2-external/python-pybind/external.desc b/support/testing/tests/package/br2-external/python-pybind/external.desc new file mode 100644 index 0000000000..eef5e0f5a0 --- /dev/null +++ b/support/testing/tests/package/br2-external/python-pybind/external.desc @@ -0,0 +1 @@ +name: PYTHON_PYBIND diff --git a/support/testing/tests/package/br2-external/python-pybind/external.mk b/support/testing/tests/package/br2-external/python-pybind/external.mk new file mode 100644 index 0000000000..3501f3135e --- /dev/null +++ b/support/testing/tests/package/br2-external/python-pybind/external.mk @@ -0,0 +1 @@ +include $(sort $(wildcard $(BR2_EXTERNAL_PYTHON_PYBIND_PATH)/package/*/*.mk)) diff --git a/support/testing/tests/package/br2-external/python-pybind/package/python-pybind-example/Config.in b/support/testing/tests/package/br2-external/python-pybind/package/python-pybind-example/Config.in new file mode 100644 index 0000000000..773d021a53 --- /dev/null +++ b/support/testing/tests/package/br2-external/python-pybind/package/python-pybind-example/Config.in @@ -0,0 +1,5 @@ +config BR2_PACKAGE_PYTHON_PYBIND_EXAMPLE + bool "python-pybind-example" + depends on BR2_PACKAGE_PYTHON_PYBIND + help + This test creates a cpp macro later used on target in python diff --git a/support/testing/tests/package/br2-external/python-pybind/package/python-pybind-example/example.cpp b/support/testing/tests/package/br2-external/python-pybind/package/python-pybind-example/example.cpp new file mode 100644 index 0000000000..f2eea8e48d --- /dev/null +++ b/support/testing/tests/package/br2-external/python-pybind/package/python-pybind-example/example.cpp @@ -0,0 +1,16 @@ +#include +namespace py = pybind11; + +int add (int i, int j) { + return i + j; +} + +PYBIND11_MODULE (example, m) { + // optional module description + m.doc() = "pybind11 example plugin"; + // test a module method + m.def("add", &add, "example::add adds two integer numbers"); + // test a module attribute + py::object hello = py::cast("Hello World"); + m.attr("says") = hello; +} diff --git a/support/testing/tests/package/br2-external/python-pybind/package/python-pybind-example/python-pybind-example.mk b/support/testing/tests/package/br2-external/python-pybind/package/python-pybind-example/python-pybind-example.mk new file mode 100644 index 0000000000..85dd09d93f --- /dev/null +++ b/support/testing/tests/package/br2-external/python-pybind/package/python-pybind-example/python-pybind-example.mk @@ -0,0 +1,47 @@ +################################################################################ +# +# python-pybind-example +# +################################################################################ + +# this builds a C++ macro "add(a,b)" +# that we expose to host-python with a custom install +# and that the python test script will later use +PYTHON_PYBIND_EXAMPLE_DEPENDENCIES = host-python-pybind + +PYTHON_PYBIND_EXAMPLE_CXX_FLAGS = $(HOST_CXXFLAGS) +PYTHON_PYBIND_EXAMPLE_CXX_FLAGS += -Wall -shared +PYTHON_PYBIND_EXAMPLE_CXX_FLAGS += -std=c++11 -fPIC + +ifeq ($(BR2_PACKAGE_PYTHON3),y) +PYTHON_PYBIND_PYVER = python$(PYTHON3_VERSION_MAJOR) +PYTHON_PYBIND_PYTHON = $(HOST_DIR)/usr/bin/python3 +else +PYTHON_PYBIND_PYVER = python$(PYTHON_VERSION_MAJOR) +PYTHON_PYBIND_PYTHON = $(HOST_DIR)/usr/bin/python2 +endif + +# retrieve pybind11 include paths +PYTHON_PYBIND_EXAMPLE_CXX_FLAGS += \ + $(shell $(PYTHON_PYBIND_PYTHON) -m pybind11 --includes) + +# .so to be installed must have exact suffix +# otherwise import() in python will not work +HOST_LIB_BINARY_SUFFIX = \ + $(shell $(PYTHON_PYBIND_PYTHON)-config --extension-suffix) + +define PYTHON_PYBIND_EXAMPLE_BUILD_CMDS + $(INSTALL) $(PYTHON_PYBIND_EXAMPLE_PKGDIR)/example.cpp $(@D) + cd $(@D); \ + $(HOSTCXX) $(PYTHON_PYBIND_EXAMPLE_CXX_FLAGS) \ + example.cpp -o example$(HOST_LIB_BINARY_SUFFIX) +endef + +# installs into host/python sys.path +# so the new macro is naturally known +define PYTHON_PYBIND_EXAMPLE_INSTALL_TARGET_CMDS + $(INSTALL) -D -m 755 $(@D)/example$(HOST_LIB_BINARY_SUFFIX) \ + $(HOST_DIR)/usr/lib/$(PYTHON_PYBIND_PYVER)/example$(HOST_LIB_BINARY_SUFFIX) +endef + +$(eval $(generic-package)) diff --git a/support/testing/tests/package/sample_python_pybind.py b/support/testing/tests/package/sample_python_pybind.py new file mode 100644 index 0000000000..605c0bab15 --- /dev/null +++ b/support/testing/tests/package/sample_python_pybind.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python +import example +print(example.add(1, 2)) +print(example.says) diff --git a/support/testing/tests/package/test_python_pybind.py b/support/testing/tests/package/test_python_pybind.py new file mode 100644 index 0000000000..7a68d6512a --- /dev/null +++ b/support/testing/tests/package/test_python_pybind.py @@ -0,0 +1,48 @@ +import os +import infra +import subprocess +from tests.package.test_python import TestPythonPackageBase + +class TestPythonPybind (infra.basetest.BRTest): + config = TestPythonPackageBase.config # python minimal requirements + sample_script = "tests/package/sample_python_pybind.py" + # ship examples macro & installs it to host + br2_external = [infra.filepath("tests/package/br2-external/python-pybind")] + +class TestPythonPy2Pybind (TestPythonPybind): + __test__ = True + config = TestPythonPybind.config + \ + """ + BR2_PACKAGE_PYTHON=y + BR2_PACKAGE_PYTHON_PYBIND=y + BR2_PACKAGE_PYTHON_PYBIND_EXAMPLE=y + """ + + def test_run(self): + host_interpreter = os.path.join(self.builddir,"host","usr","bin","python") + # test new c++->py macro exposed to host interpreter + cmd = [host_interpreter, infra.filepath(self.sample_script)] + output = subprocess.check_output(cmd) + result = int(output.splitlines()[0]) + attribute = output.splitlines()[1].decode("utf-8") + self.assertEqual(result,3) # 2+1 using '+' macro from cpp + self.assertEqual(attribute,"Hello World") # macro special attribute + +class TestPythonPy3Pybind (TestPythonPybind): + __test__ = True + config = TestPythonPybind.config + \ + """ + BR2_PACKAGE_PYTHON3=y + BR2_PACKAGE_PYTHON_PYBIND=y + BR2_PACKAGE_PYTHON_PYBIND_EXAMPLE=y + """ + + def test_run(self): + host_interpreter = os.path.join(self.builddir,"host","usr","bin","python") + # test new c++->py macro exposed to host interpreter + cmd = [host_interpreter, infra.filepath(self.sample_script)] + output = subprocess.check_output(cmd) + result = int(output.splitlines()[0]) + attribute = output.splitlines()[1].decode("utf-8") + self.assertEqual(result,3) # 2+1 using '+' macro from cpp + self.assertEqual(attribute,"Hello World") # macro special attribute