My folder structure:
grpc/
server.py
client.py
...
src/
__init__.py
image_pb2.py
image_pb2_grpc.py
...
server.py
import image_pb2_grpc
import image_pb2
...
image_pb_grpc.py
import image_pb2
...
In summary, server
depends on both image_pb2
and image_pb2_grpc
, while image_pb2_grpc
also depends on image_pb2
.
Now, if I move my server.py
inside the src
folder, the code surely runs fine, as everything is in the path.
The problem is server.py
should be outside the src
folder.
Now, I can still solve the problem by changing server.py
and image_pb2_grpc.py
with:
server.py
from src import image_pb2_grpc
from src import image_pb2
...
image_pb_grpc.py
from src import image_pb2
...
The issue with this approach is, I need to change image_pb_grpc.py
manually, as they are generated code from grpc, and they are generated using a bash script, so it is not possible to change them manually.
How can I organize my project so that I can run server
outside src
, while not changing image_pb2
or image_pb2_grpc
?