package/python-dbus-fast: new package

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Reviewed-by: James Hilliard <james.hilliard1@gmail.com>
[yann.morin.1998@free.fr:
  - select host-cython in Config.in
  - introduce obj_path in test sample
]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
This commit is contained in:
Marcin Niestroj 2022-11-03 11:21:01 +01:00 committed by Yann E. MORIN
parent acaae6c39b
commit 82522d2547
7 changed files with 119 additions and 0 deletions

View File

@ -1877,6 +1877,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/
@ -1888,6 +1889,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

View File

@ -1022,6 +1022,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"

View File

@ -0,0 +1,10 @@
config BR2_PACKAGE_PYTHON_DBUS_FAST
bool "python-dbus-fast"
select BR2_PACKAGE_HOST_PYTHON_CYTHON
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

View File

@ -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

View File

@ -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))

View File

@ -0,0 +1,45 @@
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'
obj_path = '/test/path'
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(obj_path, service_interface)
introspection = await bus2.introspect(bus_name, obj_path)
assert type(introspection) is intr.Node
obj = bus2.get_proxy_object(bus_name, obj_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())

View File

@ -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()