diff mbox series

[2/2] package/python-can: add option to install the viewer tool

Message ID 20240822095953.524686-2-buildroot@bubu1.eu
State Accepted
Headers show
Series [1/2] package/python-can: bump to 4.4.2 | expand

Commit Message

Marcus Hoffmann Aug. 22, 2024, 9:59 a.m. UTC
Enabling the option correctly select the python-curses module dependency
of the viewer tool.

Signed-off-by: Marcus Hoffmann <buildroot@bubu1.eu>
---
 package/python-can/Config.in     | 7 +++++++
 package/python-can/python-can.mk | 7 +++++++
 2 files changed, 14 insertions(+)

Comments

Thomas Petazzoni Aug. 23, 2024, 5:36 p.m. UTC | #1
On Thu, 22 Aug 2024 11:59:53 +0200
Marcus Hoffmann via buildroot <buildroot@buildroot.org> wrote:

> Enabling the option correctly select the python-curses module dependency
> of the viewer tool.
> 
> Signed-off-by: Marcus Hoffmann <buildroot@bubu1.eu>
> ---
>  package/python-can/Config.in     | 7 +++++++
>  package/python-can/python-can.mk | 7 +++++++
>  2 files changed, 14 insertions(+)
> 
> diff --git a/package/python-can/Config.in b/package/python-can/Config.in
> index 61955a2b00..36e25b8764 100644
> --- a/package/python-can/Config.in
> +++ b/package/python-can/Config.in
> @@ -11,3 +11,10 @@ config BR2_PACKAGE_PYTHON_CAN
>  	  Python.
>  
>  	  https://github.com/hardbyte/python-can
> +
> +config BR2_PACKAGE_PYTHON_CAN_VIEWER
> +	bool "python-can-viewer"
> +	depends on BR2_PACKAGE_PYTHON_CAN

We normally prefer to enclose package sub-options into a if ... endif
block even when there's only one option, so I adjusted this small
detail and applied to next. Thanks!

Thomas
diff mbox series

Patch

diff --git a/package/python-can/Config.in b/package/python-can/Config.in
index 61955a2b00..36e25b8764 100644
--- a/package/python-can/Config.in
+++ b/package/python-can/Config.in
@@ -11,3 +11,10 @@  config BR2_PACKAGE_PYTHON_CAN
 	  Python.
 
 	  https://github.com/hardbyte/python-can
+
+config BR2_PACKAGE_PYTHON_CAN_VIEWER
+	bool "python-can-viewer"
+	depends on BR2_PACKAGE_PYTHON_CAN
+	select BR2_PACKAGE_PYTHON3_CURSES # runtime
+	help
+	  Also install the viewer tool (requires ncurses).
diff --git a/package/python-can/python-can.mk b/package/python-can/python-can.mk
index b6547a4d3f..bc67be4f8c 100644
--- a/package/python-can/python-can.mk
+++ b/package/python-can/python-can.mk
@@ -11,4 +11,11 @@  PYTHON_CAN_SETUP_TYPE = setuptools
 PYTHON_CAN_LICENSE = LGPL-3.0
 PYTHON_CAN_LICENSE_FILES = LICENSE.txt
 
+ifneq ($(BR2_PACKAGE_PYTHON_CAN_VIEWER),y)
+define PYTHON_CAN_REMOVE_VIEWER
+	rm -f $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/site-packages/can/viewer.py
+endef
+PYTHON_CAN_POST_INSTALL_TARGET_HOOKS += PYTHON_CAN_REMOVE_VIEWER
+endif
+
 $(eval $(python-package))