Skip to contentSkip to conversation

dbus-python: add host package

PATCH Superseded Brent Generous 2 participants 2 messages Oct 17, 2018 – Oct 18, 2018

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 dbus-python: add host package

This can be useful for Python scripts running on a host machine that need to connect to a bus on a remote device, e.g. test scripts.

The target dbus-python depends on dbus instead of selecting it because dbus has dependencies that check that it is supported. Using 'select' would override those dependencies. For host-dbus, there are no such checks -- it's assumed the host has the features neeeded to run dbus, so it is okay to just depend on host-dbus.

The pyexpat dependency is not needed, as it is forced on for host-python.

---
 package/dbus-python/dbus-python.mk | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
package/dbus-python/dbus-python.mk +15 -0
index da04b7404f..6021b63060 100644
@@ -12,6 +12,10 @@ DBUS_PYTHON_LICENSE_FILES = COPYING
 DBUS_PYTHON_DEPENDENCIES = dbus-glib
 DBUS_PYTHON_CONF_OPTS = --disable-html-docs --disable-api-docs
 
+HOST_DBUS_PYTHON_DEPENDENCIES = host-dbus host-dbus-glib \
+				$(if $(BR2_PACKAGE_PYTHON3),host-python3,host-python)
+HOST_DBUS_PYTHON_CONF_OPTS = $(DBUS_PYTHON_CONF_OPTS)
+
 ifeq ($(BR2_PACKAGE_PYTHON),y)
 DBUS_PYTHON_DEPENDENCIES += python host-python
 
@@ -19,6 +23,11 @@ DBUS_PYTHON_CONF_ENV += \
 	PYTHON=$(HOST_DIR)/bin/python2 \
 	PYTHON_INCLUDES="`$(STAGING_DIR)/usr/bin/python2-config --includes`" \
 	PYTHON_LIBS="`$(STAGING_DIR)/usr/bin/python2-config --ldflags`"
+
+HOST_DBUS_PYTHON_CONF_ENV += \
+	PYTHON=$(HOST_DIR)/bin/python2 \
+	PYTHON_INCLUDES="`$(HOST_DIR)/usr/bin/python2-config --includes`" \
+	PYTHON_LIBS="`$(HOST_DIR)/usr/bin/python2-config --ldflags`"
 else
 DBUS_PYTHON_DEPENDENCIES += python3 host-python3
 
@@ -26,6 +35,12 @@ DBUS_PYTHON_CONF_ENV += \
 	PYTHON=$(HOST_DIR)/bin/python3 \
 	PYTHON_INCLUDES="`$(STAGING_DIR)/usr/bin/python3-config --includes`" \
 	PYTHON_LIBS="`$(STAGING_DIR)/usr/bin/python3-config --ldflags`"
+
+HOST_DBUS_PYTHON_CONF_ENV += \
+	PYTHON=$(HOST_DIR)/bin/python3 \
+	PYTHON_INCLUDES="`$(HOST_DIR)/usr/bin/python3-config --includes`" \
+	PYTHON_LIBS="`$(HOST_DIR)/usr/bin/python3-config --ldflags`"
 endif
 
 $(eval $(autotools-package))
+$(eval $(host-autotools-package))
Signature · 1 line
2.14.4
#1 lore raw

PATCH v2 1/1 dbus-python: add host package

Hello Brent,

Thanks for this contribution.

Quoted 8 lines · Brent Generous

This can be useful for Python scripts running on a host machine that need to connect to a bus on a remote device, e.g. test scripts.

The target dbus-python depends on dbus instead of selecting it because dbus has dependencies that check that it is supported. Using 'select' would override those dependencies. For host-dbus, there are no such checks -- it's assumed the host has the features neeeded to run dbus, so it is okay to just depend on host-dbus.

Correct.

Quoted 4 lines

The pyexpat dependency is not needed, as it is forced on for host-python.

One thing that I'd like to see is this package added to package/Config.in.host, and a package/dbus-python/Config.in.host. Indeed, I continue to dislike "orphan" host packages, i.e host packages that are neither a build dependency of some package in Buildroot, and neither available through the menuconfig Host packages menu.

package/dbus-python/dbus-python.mk DBUS_PYTHON_LICENSE_FILES = COPYING · line 15

Quoted 9 lines
package/dbus-python/dbus-python.mk +1 -0
index da04b7404f..6021b63060 100644
@@ -12,6 +12,10 @@ DBUS_PYTHON_LICENSE_FILES = COPYING
 DBUS_PYTHON_DEPENDENCIES = dbus-glib
 DBUS_PYTHON_CONF_OPTS = --disable-html-docs --disable-api-docs
 
+HOST_DBUS_PYTHON_DEPENDENCIES = host-dbus host-dbus-glib \

Why do you need host-dbus here? We don't have a dependency on "dbus" for the target dbus-python package, so there's no reason to have a dependency on host-dbus in the host-dbus-python package.

Just like dbus-glib has a dependency on dbus, host-dbus-glib has a dependency on host-dbus. So it's not great to list host-dbus in host-dbus-python dependencies, as it makes the dependencies not very consistent between host and target.

package/dbus-python/dbus-python.mk DBUS_PYTHON_LICENSE_FILES = COPYING · line 16

Quoted 1 line
package/dbus-python/dbus-python.mk +1 -0
+				$(if $(BR2_PACKAGE_PYTHON3),host-python3,host-python)

Nit: just one tab for the indentation, don't try to align

package/dbus-python/dbus-python.mk DBUS_PYTHON_LICENSE_FILES = COPYING · line 17

Quoted 1 line
package/dbus-python/dbus-python.mk +1 -0
+HOST_DBUS_PYTHON_CONF_OPTS = $(DBUS_PYTHON_CONF_OPTS)

Please repeat --disable-html-docs --disable-api-docs here. It's pretty dangerous to set host config options equal to target config options. We can easily add more things to the target config options, without realizing it's going to affect the host build as well.

Quoted 18 lines
package/dbus-python/dbus-python.mk +5 -0
 ifeq ($(BR2_PACKAGE_PYTHON),y)
 DBUS_PYTHON_DEPENDENCIES += python host-python
 
@@ -19,6 +23,11 @@ DBUS_PYTHON_CONF_ENV += \
 	PYTHON=$(HOST_DIR)/bin/python2 \
 	PYTHON_INCLUDES="`$(STAGING_DIR)/usr/bin/python2-config --includes`" \
 	PYTHON_LIBS="`$(STAGING_DIR)/usr/bin/python2-config --ldflags`"
+
+HOST_DBUS_PYTHON_CONF_ENV += \
+	PYTHON=$(HOST_DIR)/bin/python2 \
+	PYTHON_INCLUDES="`$(HOST_DIR)/usr/bin/python2-config --includes`" \
+	PYTHON_LIBS="`$(HOST_DIR)/usr/bin/python2-config --ldflags`"
 else
 DBUS_PYTHON_DEPENDENCIES += python3 host-python3
 
@@ -26,6 +35,12 @@ DBUS_PYTHON_CONF_ENV += \
 	PYTHON=$(HOST_DIR)/bin/python3 \
 	PYTHON_INCLUDES="`$(STAGING_DIR)/usr/bin/python3-config --includes`" \

package/dbus-python/dbus-python.mk DBUS_PYTHON_CONF_ENV += \ · line 46

Quoted 10 lines
package/dbus-python/dbus-python.mk +6 -0
 	PYTHON_LIBS="`$(STAGING_DIR)/usr/bin/python3-config --ldflags`"
+
+HOST_DBUS_PYTHON_CONF_ENV += \
+	PYTHON=$(HOST_DIR)/bin/python3 \
+	PYTHON_INCLUDES="`$(HOST_DIR)/usr/bin/python3-config --includes`" \
+	PYTHON_LIBS="`$(HOST_DIR)/usr/bin/python3-config --ldflags`"
 endif
 
 $(eval $(autotools-package))
+$(eval $(host-autotools-package))

I think there is an issue here. If you have neither BR2_PACKAGE_PYTHON=y nor BR2_PACKAGE_PYTHON3=y, then:

	$(if $(BR2_PACKAGE_PYTHON3),host-python3,host-python)

will make you use host-python to build dbus-python.

But then the

ifeq ($(BR2_PACKAGE_PYTHON),y)
... use host python 2.x
else
... use host python 3.x
endif

will make you use python 3.x.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com