mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-08-01 21:23:51 -09:00
package/python-sysv-ipc: new package
python-sysv-ipc provides Python bindings for System V IPC primitives (semaphores, shared memory and message queues). https://github.com/osvenskan/sysv_ipc Signed-off-by: Vincent Jardin <vjardin@free.fr> Signed-off-by: Vincent Cruz <mooz@blockos.org> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
committed by
Thomas Petazzoni
parent
a295c5bb0c
commit
2d7cf86aaa
@@ -3369,6 +3369,7 @@ F: package/libecoli/
|
||||
F: package/libnss-ato/
|
||||
F: package/libyang-cpp/
|
||||
F: package/python-libyang/
|
||||
F: package/python-sysv-ipc/
|
||||
F: package/sysrepo-cpp/
|
||||
|
||||
N: Vincent Prince <vincent.prince.fr@gmail.com>
|
||||
|
||||
@@ -1444,6 +1444,7 @@ menu "External python modules"
|
||||
source "package/python-starlette/Config.in"
|
||||
source "package/python-sympy/Config.in"
|
||||
source "package/python-systemd/Config.in"
|
||||
source "package/python-sysv-ipc/Config.in"
|
||||
source "package/python-tabledata/Config.in"
|
||||
source "package/python-tcolorpy/Config.in"
|
||||
source "package/python-telnetlib3/Config.in"
|
||||
|
||||
7
package/python-sysv-ipc/Config.in
Normal file
7
package/python-sysv-ipc/Config.in
Normal file
@@ -0,0 +1,7 @@
|
||||
config BR2_PACKAGE_PYTHON_SYSV_IPC
|
||||
bool "python-sysv-ipc"
|
||||
help
|
||||
System V IPC primitives (semaphores, shared memory and
|
||||
message queues) for Python.
|
||||
|
||||
https://github.com/osvenskan/sysv_ipc
|
||||
4
package/python-sysv-ipc/python-sysv-ipc.hash
Normal file
4
package/python-sysv-ipc/python-sysv-ipc.hash
Normal file
@@ -0,0 +1,4 @@
|
||||
# From https://pypi.org/pypi/sysv-ipc/1.2.0/json
|
||||
sha256 ef96ab33bb62e4d14142f0be0524dcc0c3c70c96442df2fc773c67b7c7514199 sysv_ipc-1.2.0.tar.gz
|
||||
# Locally computed
|
||||
sha256 ca1c736814f4b73052ba877eaa9e09b40c7e22f1b5d025236246227cc1d87fdc LICENSE
|
||||
16
package/python-sysv-ipc/python-sysv-ipc.mk
Normal file
16
package/python-sysv-ipc/python-sysv-ipc.mk
Normal file
@@ -0,0 +1,16 @@
|
||||
################################################################################
|
||||
#
|
||||
# python-sysv-ipc
|
||||
#
|
||||
################################################################################
|
||||
|
||||
PYTHON_SYSV_IPC_VERSION = 1.2.0
|
||||
PYTHON_SYSV_IPC_SOURCE = sysv_ipc-$(PYTHON_SYSV_IPC_VERSION).tar.gz
|
||||
PYTHON_SYSV_IPC_SITE = https://files.pythonhosted.org/packages/f2/5e/59208c6dd05ebc6f46ce2023c4fc01ffe814a1967d21b35d312c7e6ffeae
|
||||
|
||||
PYTHON_SYSV_IPC_LICENSE = BSD-3-Clause
|
||||
PYTHON_SYSV_IPC_LICENSE_FILES = LICENSE
|
||||
|
||||
PYTHON_SYSV_IPC_SETUP_TYPE = setuptools
|
||||
|
||||
$(eval $(python-package))
|
||||
26
support/testing/tests/package/sample_python_sysv_ipc.py
Normal file
26
support/testing/tests/package/sample_python_sysv_ipc.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import subprocess
|
||||
import sys
|
||||
import sysv_ipc
|
||||
|
||||
key = [303, 808]
|
||||
iterations = 6
|
||||
|
||||
queue = [
|
||||
sysv_ipc.MessageQueue(key[0], sysv_ipc.IPC_CREX),
|
||||
sysv_ipc.MessageQueue(key[1], sysv_ipc.IPC_CREX)
|
||||
]
|
||||
|
||||
procs = [None] * 2
|
||||
|
||||
procs[0] = subprocess.Popen([sys.executable, "/root/ping.py", str(key[0]), str(key[1]), str(iterations)])
|
||||
procs[1] = subprocess.Popen([sys.executable, "/root/pong.py", str(key[1]), str(key[0]), str(iterations)])
|
||||
|
||||
for p in procs:
|
||||
try:
|
||||
errs = p.wait(timeout=15)
|
||||
except subprocess.TimeoutExpired:
|
||||
p.kill()
|
||||
errs = p.wait()
|
||||
|
||||
for q in queue:
|
||||
q.remove()
|
||||
37
support/testing/tests/package/test_python_sysv_ipc.py
Normal file
37
support/testing/tests/package/test_python_sysv_ipc.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import os
|
||||
from tests.package.test_python import TestPythonPackageBase
|
||||
|
||||
|
||||
class TestPythonSysVIPC(TestPythonPackageBase):
|
||||
__test__ = True
|
||||
config = TestPythonPackageBase.config + \
|
||||
"""
|
||||
BR2_PACKAGE_PYTHON3=y
|
||||
BR2_PACKAGE_PYTHON_SYSV_IPC=y
|
||||
"""
|
||||
sample_scripts = ["tests/package/sample_python_sysv_ipc.py",
|
||||
"tests/package/test_python_sysv_ipc/ping.py",
|
||||
"tests/package/test_python_sysv_ipc/pong.py"]
|
||||
|
||||
def test_run(self):
|
||||
self.login()
|
||||
self.check_sample_scripts_exist()
|
||||
|
||||
cmd = self.interpreter + " " + os.path.basename(self.sample_scripts[0])
|
||||
output, ret = self.emulator.run(cmd, timeout=self.timeout)
|
||||
|
||||
self.assertEqual(ret, 0)
|
||||
self.assertEqual(output, [
|
||||
'ping 0',
|
||||
'pong 0',
|
||||
'ping 1',
|
||||
'pong 1',
|
||||
'ping 2',
|
||||
'pong 2',
|
||||
'ping 3',
|
||||
'pong 3',
|
||||
'ping 4',
|
||||
'pong 4',
|
||||
'ping 5',
|
||||
'pong 5',
|
||||
])
|
||||
17
support/testing/tests/package/test_python_sysv_ipc/ping.py
Normal file
17
support/testing/tests/package/test_python_sysv_ipc/ping.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import argparse
|
||||
import sysv_ipc
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("input", help="input message queue key", type=int)
|
||||
parser.add_argument("output", help="output message queue key", type=int)
|
||||
parser.add_argument("count", help="iterations count", type=int)
|
||||
args = parser.parse_args()
|
||||
|
||||
incoming = sysv_ipc.MessageQueue(args.input)
|
||||
outgoing = sysv_ipc.MessageQueue(args.output)
|
||||
|
||||
for i in range(0, args.count):
|
||||
outgoing.send(f"ping {i}")
|
||||
|
||||
s, _ = incoming.receive()
|
||||
print(s.decode())
|
||||
17
support/testing/tests/package/test_python_sysv_ipc/pong.py
Normal file
17
support/testing/tests/package/test_python_sysv_ipc/pong.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import argparse
|
||||
import sysv_ipc
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("input", help="input message queue key", type=int)
|
||||
parser.add_argument("output", help="output message queue key", type=int)
|
||||
parser.add_argument("count", help="iterations count", type=int)
|
||||
args = parser.parse_args()
|
||||
|
||||
incoming = sysv_ipc.MessageQueue(args.input)
|
||||
outgoing = sysv_ipc.MessageQueue(args.output)
|
||||
|
||||
for i in range(0, args.count):
|
||||
s, _ = incoming.receive()
|
||||
print(s.decode())
|
||||
|
||||
outgoing.send(f"pong {i}")
|
||||
Reference in New Issue
Block a user