From 04d05dbb45b860f1562af10f66c6f29a6af4f563 Mon Sep 17 00:00:00 2001 From: jian Date: Mon, 4 Nov 2024 15:09:13 +0000 Subject: [PATCH] fix grpc deploy --- antgo/pipeline/__init__.py | 7 +++---- antgo/pipeline/functional/mixins/deploy.py | 10 ++++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/antgo/pipeline/__init__.py b/antgo/pipeline/__init__.py index 04add32..ce070cb 100644 --- a/antgo/pipeline/__init__.py +++ b/antgo/pipeline/__init__.py @@ -48,9 +48,6 @@ def pipeline_cplusplus_package(project, folder='./deploy', **kwargs): project_plugin_folder = os.path.join(plugin_folder, project) os.makedirs(project_plugin_folder, exist_ok=True) - # depedent_folder = os.path.join(package_folder, 'dependents') - # os.makedirs(depedent_folder, exist_ok=True) - os.makedirs(os.path.join(package_folder, 'config'), exist_ok=True) os.makedirs(os.path.join(package_folder, 'models'), exist_ok=True) @@ -95,7 +92,7 @@ def pipeline_cplusplus_package(project, folder='./deploy', **kwargs): # 检查是否需要ffmpeg依赖 if 'ffmpeg' in project_info['eagleeye']: # 仅对android/windows处理(linux平台下,镜像中默认已经安装) - os.system(f'cp -r {project_info["eagleeye"]["ffmpeg"]}/install/lib/*.so {depedent_folder}') + os.system(f'cp -r {project_info["eagleeye"]["ffmpeg"]}/install/lib/*.so {package_folder}/') # 检查是否需要rk依赖 if 'rk' in project_info['eagleeye']: @@ -109,8 +106,10 @@ def pipeline_cplusplus_package(project, folder='./deploy', **kwargs): os.system(f'cp -r {project_info["eagleeye"]["rk"]}/rknpu2/runtime/RK3588/Android/librknn_api/arm64-v8a/librknnrt.so {package_folder}/') # 检查是否需要minio依赖 + # 默认minio安装到系统 # 检查是否需要grpc依赖 + # 默认grpc安装到系统 # 检查是否需要opencv依赖 if 'opencv' in project_info['eagleeye']: diff --git a/antgo/pipeline/functional/mixins/deploy.py b/antgo/pipeline/functional/mixins/deploy.py index 647b4c4..1c9b751 100644 --- a/antgo/pipeline/functional/mixins/deploy.py +++ b/antgo/pipeline/functional/mixins/deploy.py @@ -2626,15 +2626,22 @@ def build(self, platform='android/arm64-v8a', output_folder='./deploy', project_ if proto_tool_dir.endswith('/'): proto_tool_dir = proto_tool_dir[:-1] proto_out_dir = os.path.join(output_folder, 'proto') + if proto_tool_dir is None: + # 检查系统目录下是否存在protoc工具,如果不存在需要下载并编译 + status = os.system('which protoc') + if status != 0: + print('Dont install grpc in system, please set proto tool.') + return - print(f'proto_tool_dir {proto_tool_dir}') # C++ proto if proto_tool_dir is not None: # 非系统目录,用户指定目录 + print(f'use proto_tool_dir {proto_tool_dir}') proto_compile_cmd = f'cd {proto_out_dir}; {proto_tool_dir}/bin/protoc --grpc_out=./ --cpp_out=./ --plugin=protoc-gen-grpc={proto_tool_dir}/bin/grpc_cpp_plugin {project_name.lower()}.proto' os.system(proto_compile_cmd) else: # 系统目录 + print(f'use system protoc') proto_compile_cmd = f'cd {proto_out_dir}; protoc --grpc_out=./ --cpp_out=./ --plugin=protoc-gen-grpc=/usr/local/bin/grpc_cpp_plugin {project_name.lower()}.proto' os.system(proto_compile_cmd) @@ -2764,4 +2771,3 @@ def build(self, platform='android/arm64-v8a', output_folder='./deploy', project_ with open(os.path.join(output_folder, '.project.json'), 'w') as fp: json.dump(project_info, fp) - return True