Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Feature/update fix Testclient and Python Package to spport GRPC #304

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions MANIFEST.in

This file was deleted.

10 changes: 6 additions & 4 deletions kuksa_viss_client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@
# Note: This dockerfile needs to be executed one level above in the root folder

FROM python:3.8-alpine as build
RUN apk update && apk add git
RUN apk update && apk add git alpine-sdk linux-headers
ADD . /kuksa.val
WORKDIR /kuksa.val
RUN pip install --upgrade pip build
WORKDIR /kuksa.val/kuksa_viss_client
RUN pip install --upgrade pip build grpcio grpcio-tools
RUN rm -rf dist
RUN python -m build
RUN python3 setup.py bdist_wheel
RUN mkdir /kuksa_viss_client
RUN pip install --target /kuksa_viss_client --no-cache-dir dist/*.whl

FROM python:3.8-alpine

RUN apk add --no-cache libstdc++
COPY --from=build /kuksa_viss_client /kuksa_viss_client
ENV PYTHONUNBUFFERED=yes
ENV GRPC_ENABLE_FORK_SUPPORT=false
WORKDIR /kuksa_viss_client
CMD ["/usr/local/bin/python", "-m", "kuksa_viss_client"]
4 changes: 2 additions & 2 deletions kuksa_viss_client/KuksaGrpcComm.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import jsonpath_ng
import uuid, time, threading

import kuksa_pb2
import kuksa_pb2_grpc
from . import kuksa_pb2
from . import kuksa_pb2_grpc

class KuksaGrpcComm:

Expand Down
4 changes: 4 additions & 0 deletions kuksa_viss_client/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
recursive-include ../kuksa_certificates *
include *.py
includo logo
global-exclude *.pyc
4 changes: 2 additions & 2 deletions kuksa_viss_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
scriptDir= os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(scriptDir, ".."))
from kuksa_viss_client._metadata import *
from KuksaWsComm import KuksaWsComm
from KuksaGrpcComm import KuksaGrpcComm
from .KuksaWsComm import KuksaWsComm
from .KuksaGrpcComm import KuksaGrpcComm

class KuksaClientThread(threading.Thread):

Expand Down
6 changes: 3 additions & 3 deletions kuksa_viss_client/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
DEFAULT_SERVER_PROTOCOL = "ws"

from grpc.tools import command
# Generate the NBI Stubs
command.build_package_protos("../kuksa-val-server/protos/")
# Generate the proto Stubs
scriptDir= os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(scriptDir, "../kuksa-val-server/protos/"))
command.build_package_protos(os.path.join(scriptDir, "kuksa.proto"))

sys.path.append(os.path.join(scriptDir, ".."))

from kuksa_viss_client import KuksaClientThread
from kuksa_viss_client._metadata import *
import kuksa_certificates
Expand Down
1 change: 1 addition & 0 deletions kuksa_viss_client/kuksa.proto
File renamed without changes.
6 changes: 3 additions & 3 deletions kuksa_viss_client/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ websockets~=10.1
cmd2~=1.4
pygments~=2.5
importlib_metadata >= 3.6
grpcio == 1.45.0
grpcio-tools
jsonpath-ng
grpcio ~= 1.46.0
grpcio-tools ~= 1.46.0
jsonpath-ng ~= 1.5.3
15 changes: 12 additions & 3 deletions setup.cfg → kuksa_viss_client/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,27 @@ classifiers =
Operating System :: OS Independent
Topic :: Software Development

license_file = LICENSE
license_file = ../LICENSE

[options]
python_requires = >=3.6
python_requires = >=3.8
install_requires=
websockets~=10.1
cmd2~=1.4
pygments~=2.5
importlib_metadata >= 3.6
packages = find:
grpcio ~= 1.46.0
grpcio-tools ~= 1.46.0
jsonpath-ng ~= 1.5.3
#packages = find:


include_package_data = True


[options.packages.find]
where = kuksa-val-server/protos

[options.entry_points]
console_scripts =
kuksa_viss_client = kuksa_viss_client.__main__:main
42 changes: 42 additions & 0 deletions kuksa_viss_client/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import setuptools
import distutils.command.build
from glob import glob
import os

class BuildCommand(distutils.command.build.build):

def run(self):
from grpc_tools import command
command.build_package_protos("./")
# protobuf for python is just hopelessly broken wrt. imports
# Read the whole story (and more elgant(?)/heavy-weight) solutions here
# https://github.com/protocolbuffers/protobuf/issues/1491

# we will just patch directly
os.system('sed -i "s/import kuksa_pb2 as kuksa__pb2/from . import kuksa_pb2 as kuksa__pb2/g" kuksa_pb2_grpc.py')
# Run the original build command
distutils.command.build.build.run(self)


setuptools.setup(
version_config={
"template": "{tag}",
"dev_template": "{tag}-{ccount}",
"dirty_template": "{tag}-{ccount}-dirty",
"starting_version": "0.1.6",
"version_callback": None,
"version_file": None,
"count_commits_from_version_file": False
},
package_dir={'kuksa_viss_client': '.' },
packages=['kuksa_viss_client'],
data_files=[
("kuksa_certificates", glob('../kuksa_certificates/C*')), #Cleint and CA.pem
("kuksa_certificates/jwt", glob('../kuksa_certificates/jwt/*')),
],
package_data={ "kuksa_viss_client": ["logo"] },
setup_requires=['setuptools-git-versioning', 'grpcio', 'grpcio-tools'],
cmdclass={
'build': BuildCommand,
}
)
14 changes: 0 additions & 14 deletions setup.py

This file was deleted.