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

James Hilliard james.hilliard1 at gmail.com
Thu Nov 3 12:13:12 UTC 2022


On Thu, Nov 3, 2022 at 6:21 AM Marcin Niestroj
<m.niestroj at grinn-global.com> wrote:
>
> Signed-off-by: Marcin Niestroj <m.niestroj at grinn-global.com>
Reviewed-by: James Hilliard <james.hilliard1 at gmail.com>
> ---
> v1 -> v2:
> * added REQUIRE_CYTHON=1 env and host-python-cython dependencies (suggested by
>   James)
>
>  DEVELOPERS                                    |  2 +
>  package/Config.in                             |  1 +
>  package/python-dbus-fast/Config.in            |  9 ++++
>  .../python-dbus-fast/python-dbus-fast.hash    |  5 +++
>  package/python-dbus-fast/python-dbus-fast.mk  | 16 +++++++
>  .../tests/package/sample_python_dbus_fast.py  | 44 +++++++++++++++++++
>  .../tests/package/test_python_dbus_fast.py    | 40 +++++++++++++++++
>  7 files changed, 117 insertions(+)
>  create mode 100644 package/python-dbus-fast/Config.in
>  create mode 100644 package/python-dbus-fast/python-dbus-fast.hash
>  create mode 100644 package/python-dbus-fast/python-dbus-fast.mk
>  create mode 100644 support/testing/tests/package/sample_python_dbus_fast.py
>  create mode 100644 support/testing/tests/package/test_python_dbus_fast.py
>
> diff --git a/DEVELOPERS b/DEVELOPERS
> index 7d27936992..6d670ae21a 100644
> --- a/DEVELOPERS
> +++ b/DEVELOPERS
> @@ -1881,6 +1881,7 @@ F:        package/murata-cyw-fw/
>  F:     package/netdata/
>  F:     package/python-ansicolors/
>  F:     package/python-bleak/
> +F:     package/python-dbus-fast/
>  F:     package/python-dbus-next/
>  F:     package/python-iniconfig/
>  F:     package/python-intelhex/
> @@ -1892,6 +1893,7 @@ F:        package/python-typing-extensions/
>  F:     package/python-xmodem/
>  F:     package/rs485conf/
>  F:     package/turbolua/
> +F:     support/testing/tests/package/sample_python_dbus_fast.py
>  F:     support/testing/tests/package/sample_python_dbus_next.py
>  F:     support/testing/tests/package/sample_python_pytest.py
>  F:     support/testing/tests/package/sample_python_pytest_asyncio.py
> diff --git a/package/Config.in b/package/Config.in
> index 238d7813f0..db9e94f357 100644
> --- a/package/Config.in
> +++ b/package/Config.in
> @@ -1015,6 +1015,7 @@ menu "External python modules"
>         source "package/python-daphne/Config.in"
>         source "package/python-dataproperty/Config.in"
>         source "package/python-dateutil/Config.in"
> +       source "package/python-dbus-fast/Config.in"
>         source "package/python-dbus-next/Config.in"
>         source "package/python-decorator/Config.in"
>         source "package/python-defusedxml/Config.in"
> diff --git a/package/python-dbus-fast/Config.in b/package/python-dbus-fast/Config.in
> new file mode 100644
> index 0000000000..2665bd1964
> --- /dev/null
> +++ b/package/python-dbus-fast/Config.in
> @@ -0,0 +1,9 @@
> +config BR2_PACKAGE_PYTHON_DBUS_FAST
> +       bool "python-dbus-fast"
> +       select BR2_PACKAGE_PYTHON3_PYEXPAT # runtime
> +       select BR2_PACKAGE_PYTHON_ASYNC_TIMEOUT # runtime
> +       help
> +         A faster version of dbus-next, a DBus library for Python with
> +         asyncio support.
> +
> +         https://github.com/bluetooth-devices/dbus-fast
> diff --git a/package/python-dbus-fast/python-dbus-fast.hash b/package/python-dbus-fast/python-dbus-fast.hash
> new file mode 100644
> index 0000000000..f0dceeb43d
> --- /dev/null
> +++ b/package/python-dbus-fast/python-dbus-fast.hash
> @@ -0,0 +1,5 @@
> +# md5, sha256 from https://pypi.org/pypi/dbus-fast/json
> +md5  eebf2c558dd1af0f8f32b361e91f2fa3  dbus_fast-1.61.1.tar.gz
> +sha256  bda4a7d559047b74f409eda278f68f610a418e86ad3efa0368fa2ed240daa6b6  dbus_fast-1.61.1.tar.gz
> +# Locally computed sha256 checksums
> +sha256  c37e9c75110e01d1f0c5360dc7d7776a30ac5f70d2440db214423e4b7a77a6af  LICENSE
> 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
> +
> +$(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'
> +
> +    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)
> +
> +    introspection = await bus2.introspect(bus_name, '/test/path')
> +    assert type(introspection) is intr.Node
> +    obj = bus2.get_proxy_object(bus_name, '/test/path', introspection)
> +    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
>



More information about the buildroot mailing list