Start developing publish to static
This commit is contained in:
@@ -1,2 +1,5 @@
|
||||
*/**/__pycache__
|
||||
*.pyc
|
||||
*.sqlite3
|
||||
dist/
|
||||
soul_diary/ui/requirements.txt
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,5 @@
|
||||
*.pyc
|
||||
*.sqlite3
|
||||
__pycache__
|
||||
dist/
|
||||
soul_diary/ui/requirements.txt
|
||||
|
||||
26
poetry.lock
generated
26
poetry.lock
generated
@@ -57,6 +57,7 @@ files = [
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
exceptiongroup = {version = ">=1.0.2", markers = "python_version < \"3.11\""}
|
||||
idna = ">=2.8"
|
||||
sniffio = ">=1.1"
|
||||
|
||||
@@ -348,6 +349,20 @@ pyyaml = ">=5.3.1"
|
||||
requests = ">=2.23.0"
|
||||
rich = "*"
|
||||
|
||||
[[package]]
|
||||
name = "exceptiongroup"
|
||||
version = "1.2.0"
|
||||
description = "Backport of PEP 654 (exception groups)"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "exceptiongroup-1.2.0-py3-none-any.whl", hash = "sha256:4bfd3996ac73b41e9b9628b04e079f193850720ea5945fc96a08633c66912f14"},
|
||||
{file = "exceptiongroup-1.2.0.tar.gz", hash = "sha256:91f5c769735f051a4290d52edd0858999b57e5876e9f85937691bd4c9fa3ed68"},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
test = ["pytest (>=6)"]
|
||||
|
||||
[[package]]
|
||||
name = "facet"
|
||||
version = "0.9.1"
|
||||
@@ -848,13 +863,13 @@ signedtoken = ["cryptography (>=3.0.0)", "pyjwt (>=2.0.0,<3)"]
|
||||
|
||||
[[package]]
|
||||
name = "packaging"
|
||||
version = "23.2"
|
||||
version = "23.1"
|
||||
description = "Core utilities for Python packages"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "packaging-23.2-py3-none-any.whl", hash = "sha256:8c491190033a9af7e1d931d0b5dacc2ef47509b34dd0de67ed209b5203fc88c7"},
|
||||
{file = "packaging-23.2.tar.gz", hash = "sha256:048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5"},
|
||||
{file = "packaging-23.1-py3-none-any.whl", hash = "sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61"},
|
||||
{file = "packaging-23.1.tar.gz", hash = "sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1465,6 +1480,7 @@ files = [
|
||||
[package.dependencies]
|
||||
click = ">=7.0"
|
||||
h11 = ">=0.8"
|
||||
typing-extensions = {version = ">=4.0", markers = "python_version < \"3.11\""}
|
||||
|
||||
[package.extras]
|
||||
standard = ["colorama (>=0.4)", "httptools (>=0.5.0)", "python-dotenv (>=0.13)", "pyyaml (>=5.1)", "uvloop (>=0.14.0,!=0.15.0,!=0.15.1)", "watchfiles (>=0.13)", "websockets (>=10.4)"]
|
||||
@@ -1712,5 +1728,5 @@ sqlite = ["aiosqlite"]
|
||||
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.11"
|
||||
content-hash = "2edc77f8a1e7fc20a3330be55ee660506982acfa0ace143d3b5fc41c3b813e5d"
|
||||
python-versions = "^3.10"
|
||||
content-hash = "3073f58d2f86f70870251b6c879a5417de6d4767cf3560daad0f3416e007642e"
|
||||
|
||||
@@ -14,7 +14,7 @@ aiosqlite = { version = "^0.19.0", optional = true }
|
||||
asyncpg = { version = "^0.28.0", optional = true }
|
||||
|
||||
# main
|
||||
python = "^3.11"
|
||||
python = "^3.10"
|
||||
uvicorn = "^0.24.0.post1"
|
||||
facet = "^0.9.1"
|
||||
pydantic = "^2.5.2"
|
||||
@@ -38,6 +38,7 @@ flet-fastapi = "^0.14.0"
|
||||
pycryptodomex = "^3.19.0"
|
||||
yarl = "^1.9.4"
|
||||
httpx = "0.24.1"
|
||||
packaging = "23.1"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
|
||||
@@ -28,6 +28,7 @@ class SenseListPage(BasePage):
|
||||
)
|
||||
settings_button = flet.IconButton(
|
||||
icon=flet.icons.SETTINGS,
|
||||
visible=False,
|
||||
)
|
||||
logout_button = flet.IconButton(
|
||||
icon=flet.icons.LOGOUT,
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import asyncio
|
||||
import pathlib
|
||||
import subprocess
|
||||
|
||||
import typer
|
||||
|
||||
@@ -6,6 +8,19 @@ from . import web
|
||||
from .service import get_service
|
||||
|
||||
|
||||
def publish():
|
||||
current_path = pathlib.Path(__file__).parent
|
||||
root_path = current_path.parent.parent
|
||||
requirements_path = current_path / "requirements.txt"
|
||||
entrypoint_path = current_path / "entrypoint.py"
|
||||
dist_path = root_path / "dist"
|
||||
|
||||
subprocess.call(["poetry", "export", "-f", "requirements.txt", "--with", "ui", "--with", "main",
|
||||
"--without-hashes", "--output", str(requirements_path)])
|
||||
subprocess.call(["flet", "publish", "--pre", "--distpath", str(dist_path),
|
||||
str(entrypoint_path)])
|
||||
|
||||
|
||||
def run():
|
||||
ui_service = get_service()
|
||||
|
||||
@@ -16,6 +31,7 @@ def get_cli() -> typer.Typer:
|
||||
cli = typer.Typer()
|
||||
|
||||
cli.command(name="run")(run)
|
||||
cli.command(name="publish")(publish)
|
||||
cli.add_typer(web.get_cli(), name="web")
|
||||
|
||||
return cli
|
||||
|
||||
14
soul_diary/ui/entrypoint.py
Normal file
14
soul_diary/ui/entrypoint.py
Normal file
@@ -0,0 +1,14 @@
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
current_path = str(pathlib.Path(__file__).parent.absolute())
|
||||
if current_path not in sys.path:
|
||||
sys.path.append(current_path)
|
||||
|
||||
import flet
|
||||
|
||||
from app.app import SoulDiaryApp
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
flet.app(target=SoulDiaryApp().run)
|
||||
@@ -1,6 +1,6 @@
|
||||
from facet import ServiceMixin
|
||||
|
||||
from .web import WebService, WebSettings, get_service as get_web_service
|
||||
from .web import WebService, get_service as get_web_service
|
||||
|
||||
|
||||
class UIService(ServiceMixin):
|
||||
@@ -15,6 +15,5 @@ class UIService(ServiceMixin):
|
||||
|
||||
|
||||
def get_service() -> UIService:
|
||||
settings = WebSettings()
|
||||
web = get_web_service(settings=settings)
|
||||
web = get_web_service()
|
||||
return UIService(web=web)
|
||||
|
||||
@@ -2,27 +2,17 @@ import asyncio
|
||||
import typer
|
||||
|
||||
from .service import get_service
|
||||
from .settings import WebSettings, get_settings
|
||||
|
||||
|
||||
def run(ctx: typer.Context):
|
||||
settings: WebSettings = ctx.obj["settings"]
|
||||
def run():
|
||||
web_service = get_service()
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
frontend_service = get_service(settings=settings)
|
||||
|
||||
loop.run_until_complete(frontend_service.run())
|
||||
|
||||
|
||||
def settings_callback(ctx: typer.Context):
|
||||
ctx.obj = ctx.obj or {}
|
||||
ctx.obj["settings"] = get_settings()
|
||||
asyncio.run(web_service.run())
|
||||
|
||||
|
||||
def get_cli() -> typer.Typer:
|
||||
cli = typer.Typer()
|
||||
|
||||
cli.callback()(settings_callback)
|
||||
cli.command(name="run")(run)
|
||||
|
||||
return cli
|
||||
|
||||
@@ -34,5 +34,6 @@ class WebService(ServiceMixin):
|
||||
self.add_task(server.serve())
|
||||
|
||||
|
||||
def get_service(settings: WebSettings) -> WebService:
|
||||
def get_service() -> WebService:
|
||||
settings = WebSettings()
|
||||
return WebService(port=settings.port, backend_data=settings.backend_data)
|
||||
|
||||
@@ -11,7 +11,3 @@ class WebSettings(BaseSettings):
|
||||
backend_data: dict[str, Any] = {
|
||||
"url": "http://localhost:8001",
|
||||
}
|
||||
|
||||
|
||||
def get_settings() -> WebSettings:
|
||||
return WebSettings()
|
||||
|
||||
Reference in New Issue
Block a user