libnfb-ext-grpc 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ graft nfb/ext/protobuf
@@ -0,0 +1,9 @@
1
+ Metadata-Version: 2.4
2
+ Name: libnfb_ext_grpc
3
+ Version: 0.1.0
4
+ Summary: Python wrapper for libnfb gRPC extension
5
+ Author-email: Martin Spinler <spinler@cesnet.cz>
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Operating System :: OS Independent
8
+ Requires-Dist: protobuf
9
+ Requires-Dist: grpcio
@@ -0,0 +1,9 @@
1
+ Metadata-Version: 2.4
2
+ Name: libnfb_ext_grpc
3
+ Version: 0.1.0
4
+ Summary: Python wrapper for libnfb gRPC extension
5
+ Author-email: Martin Spinler <spinler@cesnet.cz>
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Operating System :: OS Independent
8
+ Requires-Dist: protobuf
9
+ Requires-Dist: grpcio
@@ -0,0 +1,12 @@
1
+ MANIFEST.in
2
+ pyproject.toml
3
+ setup.cfg
4
+ setup.py
5
+ libnfb_ext_grpc.egg-info/PKG-INFO
6
+ libnfb_ext_grpc.egg-info/SOURCES.txt
7
+ libnfb_ext_grpc.egg-info/dependency_links.txt
8
+ libnfb_ext_grpc.egg-info/entry_points.txt
9
+ libnfb_ext_grpc.egg-info/requires.txt
10
+ libnfb_ext_grpc.egg-info/top_level.txt
11
+ nfb/ext/grpc/__init__.py
12
+ nfb/ext/grpc/server.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ nfb-python-grpc-server = nfb.ext.grpc.server:main
@@ -0,0 +1,2 @@
1
+ protobuf
2
+ grpcio
File without changes
@@ -0,0 +1,46 @@
1
+ import grpc
2
+ from concurrent import futures
3
+
4
+ import nfb
5
+ from nfb.libnfb import Nfb
6
+ from nfb.ext.protobuf.v1 import nfb_pb2_grpc
7
+ from nfb.ext.protobuf.v1 import nfb_pb2
8
+
9
+
10
+ class Servicer(nfb_pb2_grpc.NfbServicer):
11
+ def __init__(self, dev: Nfb):
12
+ self._dev = dev
13
+
14
+ def GetFdt(self, request, context):
15
+ return nfb_pb2.FdtResponse(fdt=self._dev.fdt.to_dtb())
16
+
17
+ def ReadComp(self, request, context):
18
+ comp = self._dev.comp_open(self._dev.fdt.get_node(request.path))
19
+ data = comp.read(request.offset, request.nbyte)
20
+ return nfb_pb2.ReadCompResponse(data=bytes(data), status=0)
21
+
22
+ def WriteComp(self, request, context):
23
+ comp = self._dev.comp_open(self._dev.fdt.get_node(request.path))
24
+ comp.write(request.offset, bytes(request.data))
25
+ return nfb_pb2.WriteCompResponse(status=0)
26
+
27
+
28
+ def Server(servicer, addr='127.0.0.1', port=50051):
29
+ server = grpc.server(futures.ThreadPoolExecutor(max_workers=4))
30
+ nfb_pb2_grpc.add_NfbServicer_to_server(servicer, server)
31
+ server.add_insecure_port(f'{addr}:{port}')
32
+ server.start()
33
+
34
+ server.__path = f'libnfb-ext-grpc.so:grpc:{addr}:{port}'
35
+ server.path = lambda: server.__path
36
+ return server
37
+
38
+
39
+ def run_server(servicer=None, **kwargs):
40
+ if servicer is None:
41
+ servicer = Servicer
42
+ svc = servicer(nfb.open())
43
+ server = Server(svc, **kwargs)
44
+ # server.shutdown()
45
+ # server.close()
46
+ return server
@@ -0,0 +1,23 @@
1
+ [build-system]
2
+ requires = ["setuptools", "setuptools-grpc"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "libnfb_ext_grpc"
7
+ version = "0.1.0"
8
+ authors = [{name = "Martin Spinler", email="spinler@cesnet.cz"}]
9
+ description = "Python wrapper for libnfb gRPC extension"
10
+ classifiers=[
11
+ "Programming Language :: Python :: 3",
12
+ "Operating System :: OS Independent",
13
+ ]
14
+ dependencies = [
15
+ "protobuf",
16
+ "grpcio",
17
+ ]
18
+
19
+ [project.scripts]
20
+ nfb-python-grpc-server = "nfb.ext.grpc.server:main"
21
+
22
+ [tool.setuptools.packages.find]
23
+ include = ["nfb*"]
@@ -0,0 +1,13 @@
1
+ [build_grpc]
2
+ proto_files =
3
+ nfb/ext/protobuf/v1/nfb.proto
4
+ nfb/ext/protobuf/v1/dma.proto
5
+ grpc_files =
6
+ nfb/ext/protobuf/v1/nfb.proto
7
+ nfb/ext/protobuf/v1/dma.proto
8
+ proto_path = ..
9
+
10
+ [egg_info]
11
+ tag_build =
12
+ tag_date = 0
13
+
@@ -0,0 +1,11 @@
1
+ from setuptools import setup
2
+ from setuptools.command.build import build
3
+
4
+
5
+ class custom_build(build):
6
+ sub_commands = [
7
+ ('build_grpc', None),
8
+ ] + build.sub_commands
9
+
10
+
11
+ setup(cmdclass={'build': custom_build})