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 FRONTEND_EXPORT_DIR = frontend/out
PYTHON_PACKAGE_DIR = $(PWD)/python/bbgo
all: bbgo-linux bbgo-darwin all: bbgo-linux bbgo-darwin
$(BIN_DIR): $(BIN_DIR):
@ -257,11 +255,9 @@ install-grpc-tools:
# replace `import bbgo_pb2` by `from . import bbgo_pb2` to use relative import # replace `import bbgo_pb2` by `from . import bbgo_pb2` to use relative import
grpc-py: grpc-py:
python -m grpc_tools.protoc -I$(PWD)/pkg/pb \ python -m grpc_tools.protoc -I$(PWD)/pkg/pb \
--python_out=$(PYTHON_PACKAGE_DIR) \ --python_out=$(PWD)/python \
--grpc_python_out=$(PYTHON_PACKAGE_DIR) \ --grpc_python_out=$(PWD)/python \
$(PWD)/pkg/pb/bbgo.proto $(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: clean:
rm -rf $(BUILD_DIR) $(DIST_DIR) $(FRONTEND_EXPORT_DIR) $(GRPC_GO_DEPS) pkg/pb/*.pb.go 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 typing import List
from . import bbgo_pb2 import bbgo_pb2
from . import bbgo_pb2_grpc import bbgo_pb2_grpc
class UserDataService(object): class UserDataService(object):

View File

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

View File

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

View File

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

View File

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

View File

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