[Buildroot] [PATCH v2 1/2] package/python-dbus-fast: new package

Yann E. MORIN yann.morin.1998 at free.fr
Mon Jan 2 21:37:45 UTC 2023


Narcin, All,

On 2022-11-03 11:21 +0100, Marcin Niestroj spake thusly:
> Signed-off-by: Marcin Niestroj <m.niestroj at grinn-global.com>
[--SNIP--]
> diff --git a/package/python-dbus-fast/python-dbus-fast.mk b/package/python-dbus-fast/python-dbus-fast.mk
> new file mode 100644
> index 0000000000..de7049ba22
> --- /dev/null
> +++ b/package/python-dbus-fast/python-dbus-fast.mk
> @@ -0,0 +1,16 @@
> +################################################################################
> +#
> +# python-dbus-fast
> +#
> +################################################################################
> +
> +PYTHON_DBUS_FAST_VERSION = 1.61.1
> +PYTHON_DBUS_FAST_SOURCE = dbus_fast-$(PYTHON_DBUS_FAST_VERSION).tar.gz
> +PYTHON_DBUS_FAST_SITE = https://files.pythonhosted.org/packages/dd/f4/a280d46b119d59f6a3d84abf474452ae76651558b0963ab8c48ae13b5a44
> +PYTHON_DBUS_FAST_SETUP_TYPE = setuptools
> +PYTHON_DBUS_FAST_LICENSE = MIT
> +PYTHON_DBUS_FAST_LICENSE_FILES = LICENSE
> +PYTHON_DBUS_FAST_ENV = REQUIRE_CYTHON=1
> +PYTHON_DBUS_FAST_DEPENDENCIES = host-python-cython

Since there is a Kconfig symbol for host-python-cython, I've added the
appropriate select in Config.in.

> +$(eval $(python-package))
> diff --git a/support/testing/tests/package/sample_python_dbus_fast.py b/support/testing/tests/package/sample_python_dbus_fast.py
> new file mode 100644
> index 0000000000..c2855464a1
> --- /dev/null
> +++ b/support/testing/tests/package/sample_python_dbus_fast.py
> @@ -0,0 +1,44 @@
> +import asyncio
> +from dbus_fast.aio import MessageBus
> +from dbus_fast.service import ServiceInterface, method
> +import dbus_fast.introspection as intr
> +from dbus_fast import BusType
> +
> +
> +class SampleInterface(ServiceInterface):
> +    def __init__(self):
> +        super().__init__('test.interface')
> +
> +    @method()
> +    def Ping(self):
> +        pass
> +
> +    @method()
> +    def ConcatStrings(self, what1: 's', what2: 's') -> 's':  # noqa: F821
> +        return what1 + what2
> +
> +
> +async def main():
> +    bus_name = 'dbus.fast.sample'

I've introduced obj_path = '/test/path', and...

> +
> +    bus = await MessageBus(bus_type=BusType.SYSTEM).connect()
> +    bus2 = await MessageBus(bus_type=BusType.SYSTEM).connect()
> +
> +    await bus.request_name(bus_name)
> +
> +    service_interface = SampleInterface()
> +    bus.export('/test/path', service_interface)

... used it here, and...

> +    introspection = await bus2.introspect(bus_name, '/test/path')

... here, and....

> +    assert type(introspection) is intr.Node
> +    obj = bus2.get_proxy_object(bus_name, '/test/path', introspection)

... here.

Applied to master, thanks.

Sorry for missing this patch when I got to apply python-bleak's bump a
few weeks ago; thanks for reminding me.

Regards,
Yann E. MORIN.

> +    interface = obj.get_interface(service_interface.name)
> +
> +    result = await interface.call_ping()
> +    assert result is None
> +
> +    result = await interface.call_concat_strings('hello ', 'world')
> +    assert result == 'hello world'
> +
> +
> +asyncio.run(main())
> diff --git a/support/testing/tests/package/test_python_dbus_fast.py b/support/testing/tests/package/test_python_dbus_fast.py
> new file mode 100644
> index 0000000000..5f67cfd8cc
> --- /dev/null
> +++ b/support/testing/tests/package/test_python_dbus_fast.py
> @@ -0,0 +1,40 @@
> +import textwrap
> +
> +
> +from tests.package.test_python import TestPythonPackageBase
> +
> +
> +class TestPythonPy3DBusFast(TestPythonPackageBase):
> +    __test__ = True
> +    config = TestPythonPackageBase.config + \
> +        """
> +        BR2_PACKAGE_DBUS=y
> +        BR2_PACKAGE_PYTHON3=y
> +        BR2_PACKAGE_PYTHON_DBUS_FAST=y
> +        """
> +    sample_scripts = ["tests/package/sample_python_dbus_fast.py"]
> +
> +    def run_sample_scripts(self):
> +        config = \
> +            """
> +            <!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
> +             "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
> +            <busconfig>
> +              <policy user="root">
> +                <allow own="dbus.fast.sample"/>
> +                <allow send_destination="dbus.fast.sample"/>
> +              </policy>
> +            </busconfig>
> +            """
> +        config = textwrap.dedent(config)
> +        config_dir = "/etc/dbus-1/system.d"
> +        config_fn = "dbus.fast.sample.conf"
> +
> +        # Setup and reload D-Bus configuration
> +        self.emulator.run("mkdir -p " + config_dir)
> +        self.emulator.run("cat > " + config_dir + "/" + config_fn +
> +                          " <<EOF" + config + "EOF")
> +        self.emulator.run("killall -SIGHUP dbus-daemon")
> +
> +        # Run test scripts
> +        super().run_sample_scripts()
> -- 
> 2.38.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot at buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'



More information about the buildroot mailing list