Move bbgo_pb2 files and add them to packages

This commit is contained in:
なるみ 2022-04-10 02:00:01 +08:00
parent 8e601a5cde
commit 12758aaeb2
8 changed files with 18 additions and 17 deletions

View File

@ -17,8 +17,6 @@ OSX_APP_GUI ?= webview
FRONTEND_EXPORT_DIR = frontend/out
PYTHON_PACKAGE_DIR = $(PWD)/python/bbgo
all: bbgo-linux bbgo-darwin
$(BIN_DIR):
@ -257,11 +255,9 @@ install-grpc-tools:
# replace `import bbgo_pb2` by `from . import bbgo_pb2` to use relative import
grpc-py:
python -m grpc_tools.protoc -I$(PWD)/pkg/pb \
--python_out=$(PYTHON_PACKAGE_DIR) \
--grpc_python_out=$(PYTHON_PACKAGE_DIR) \
--python_out=$(PWD)/python \
--grpc_python_out=$(PWD)/python \
$(PWD)/pkg/pb/bbgo.proto
cat $(PYTHON_PACKAGE_DIR)/bbgo_pb2_grpc.py | sed -e 's/import\ bbgo_pb2/from\ .\ import\ bbgo_pb2/g' > tmp.py
mv tmp.py $(PYTHON_PACKAGE_DIR)/bbgo_pb2_grpc.py
clean:
rm -rf $(BUILD_DIR) $(DIST_DIR) $(FRONTEND_EXPORT_DIR) $(GRPC_GO_DEPS) pkg/pb/*.pb.go

View File

@ -1,7 +1,7 @@
from typing import List
from . import bbgo_pb2
from . import bbgo_pb2_grpc
import bbgo_pb2
import bbgo_pb2_grpc
class UserDataService(object):

View File

@ -2,11 +2,10 @@ import asyncio
from typing import Callable
from typing import List
import bbgo_pb2
import bbgo_pb2_grpc
import grpc
from . import bbgo_pb2
from . import bbgo_pb2_grpc
class Stream(object):

View File

@ -2,7 +2,7 @@
"""Client and server classes corresponding to protobuf-defined services."""
import grpc
from . import bbgo_pb2 as bbgo__pb2
import bbgo_pb2 as bbgo__pb2
class MarketDataServiceStub(object):

View File

@ -3,6 +3,11 @@ name = "bbgo"
version = "0.1.0"
description = ""
authors = ["なるみ <weaper@gmail.com>"]
packages = [
{ include = "bbgo" },
{ include = "bbgo_pb2.py" },
{ include = "bbgo_pb2_grpc.py" },
]
[tool.poetry.dependencies]
python = "^3.8"

View File

@ -1,5 +1,5 @@
from bbgo import bbgo_pb2
from bbgo import bbgo_pb2_grpc
import bbgo_pb2
import bbgo_pb2_grpc
class TestTradingServicer(bbgo_pb2_grpc.TradingServiceServicer):

View File

@ -1,11 +1,12 @@
from concurrent import futures
import bbgo_pb2
import bbgo_pb2_grpc
import grpc
import pytest
from bbgo import MarketService, TradingService
from bbgo import bbgo_pb2
from bbgo import bbgo_pb2_grpc
from bbgo import MarketService
from bbgo import TradingService
from tests.servicer import TestTradingServicer