Commit 20d336fc authored by Sli's avatar Sli
Browse files

Reorganize repo with poetry

parent 13639c90
......@@ -23,3 +23,4 @@ swagger-client
*_pb2*
.DS_Store
.envrc
poetry.lock
\ No newline at end of file
......@@ -13,7 +13,7 @@ def default_group():
@default_group.command(name="runserver", help="Run the server")
@click.option(
"--host", "-h", default="", type=str, help='Host to listen from (default "")'
"--host", "-h", default="127.0.0.1", type=str, help='Host to listen from (default "")'
)
@click.option(
"--port", "-p", default=50051, type=int, help="Port to listen from (default 50051)"
......@@ -26,7 +26,7 @@ def default_group():
help="Enable server reflection for debug (default False)",
)
def runserver(host, port, reflect):
from server import server
from . import server
server.serve(host, port, reflect)
......@@ -52,15 +52,15 @@ def protoc():
p = Popen(
"python -m grpc_tools.protoc -I%s --python_out=%s --grpc_python_out=%s %s"
% ("../protos", "./server/", "./server/", "../protos/com.proto"),
% ("../protos", "./cashless_server/", "./cashless_server/", "../protos/com.proto"),
shell=True,
)
p.wait()
# Fix import path issues
with fileinput.FileInput("server/com_pb2_grpc.py", inplace=True) as file:
with fileinput.FileInput("cashless_server/com_pb2_grpc.py", inplace=True) as file:
for line in file:
print(
line.replace("import com_pb2", "import server.com_pb2"), end="",
line.replace("import com_pb2", "import cashless_server.com_pb2"), end="",
)
......@@ -80,7 +80,7 @@ def setup(**kwargs):
from slugify import slugify
import jsonschema
from server import settings, db, Model, engine, com_pb2, models
from . import settings, db, Model, engine, com_pb2, models
def datetime_helper(event_date, hour, minute):
# Does not handle midnight and after
......@@ -212,6 +212,8 @@ def setup(**kwargs):
db.commit()
print("--- Database successfully created ---")
def main():
click.CommandCollection(sources=[default_group])()
if __name__ == "__main__":
click.CommandCollection(sources=[default_group])()
main()
......@@ -13,7 +13,7 @@ from sqlalchemy import (
from sqlalchemy.orm import relationship, backref
import sqlalchemy.types as types
from server import Model
from . import Model
class Money(types.TypeDecorator):
......
......@@ -3,7 +3,7 @@
from google.protobuf.timestamp_pb2 import Timestamp
import decimal
from server import models, com_pb2
from . import models, com_pb2
def pb_now() -> Timestamp:
......
......@@ -8,8 +8,8 @@ import decimal
from concurrent import futures
from google.protobuf.timestamp_pb2 import Timestamp
from server import db, models, com_pb2, com_pb2_grpc
from server.pbutils import (
from . import db, models, com_pb2, com_pb2_grpc
from .pbutils import (
pb_now,
date_to_pb,
decimal_to_pb_money,
......
......@@ -8,9 +8,9 @@ import grpc
from google.protobuf.timestamp_pb2 import Timestamp
from grpc_testing import server_from_dictionary, strict_real_time
from server import db, models, com_pb2, com_pb2_grpc
from . import db, models, com_pb2, com_pb2_grpc
from server.pbutils import (
from .pbutils import (
pb_now,
date_to_pb,
decimal_to_pb_money,
......
[tool.poetry]
name = "cashless_server"
version = "0.1.0"
description = "Server for centralizing cashless system"
authors = ["Sli <antoine@bartuccio.fr>"]
license = "GPL-3.0-only"
[tool.poetry.scripts]
manage = 'cashless_server.manage:main'
[tool.poetry.dependencies]
python = "^3.8"
grpcio = "^1.41.0"
grpcio-tools = "^1.41.0"
grpcio-reflection = "^1.41.0"
click = "^8.0.3"
jsonschema = "^4.1.2"
python-slugify = "^5.0.2"
SQLAlchemy = "^1.4.26"
[tool.poetry.dev-dependencies]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment