Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packaging fixes, attempt #2 #642

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ dmypy.json
cython_debug/

# static files are built
backend/static
backend/decky_loader/static

# ignore settings.json
# prevents leaking login details
Expand Down
10 changes: 5 additions & 5 deletions backend/decky_loader/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from aiohttp import web
from os.path import exists
from watchdog.events import RegexMatchingEventHandler, DirCreatedEvent, DirModifiedEvent, FileCreatedEvent, FileModifiedEvent
from watchdog.events import RegexMatchingEventHandler, FileSystemEvent
from watchdog.observers import Observer

from typing import TYPE_CHECKING, List
Expand Down Expand Up @@ -37,7 +37,7 @@ def maybe_reload(self, src_path: str):
if exists(path.join(self.plugin_path, plugin_dir, "plugin.json")):
self.queue.put_nowait((path.join(self.plugin_path, plugin_dir, "main.py"), plugin_dir, True))

def on_created(self, event: DirCreatedEvent | FileCreatedEvent):
def on_created(self, event: FileSystemEvent):
src_path = cast(str, event.src_path) #type: ignore # this is the correct type for this is in later versions of watchdog
if "__pycache__" in src_path:
return
Expand All @@ -51,7 +51,7 @@ def on_created(self, event: DirCreatedEvent | FileCreatedEvent):
self.logger.debug(f"file created: {src_path}")
self.maybe_reload(src_path)

def on_modified(self, event: DirModifiedEvent | FileModifiedEvent):
def on_modified(self, event: FileSystemEvent):
src_path = cast(str, event.src_path) # type: ignore
if "__pycache__" in src_path:
return
Expand Down Expand Up @@ -106,12 +106,12 @@ async def enable_reload_wait(self):
self.watcher.disabled = False

async def handle_frontend_assets(self, request: web.Request):
file = Path(__file__).parents[1].joinpath("static").joinpath(request.match_info["path"])
file = Path(__file__).parent.joinpath("static").joinpath(request.match_info["path"])
return web.FileResponse(file, headers={"Cache-Control": "no-cache"})

async def handle_frontend_locales(self, request: web.Request):
req_lang = request.match_info["path"]
file = Path(__file__).parents[1].joinpath("locales").joinpath(req_lang)
file = Path(__file__).parent.joinpath("locales").joinpath(req_lang)
if exists(file):
return web.FileResponse(file, headers={"Cache-Control": "no-cache", "Content-Type": "application/json"})
else:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion backend/decky_loader/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async def startup(_: Application):

for route in list(self.web_app.router.routes()):
self.cors.add(route) # pyright: ignore [reportUnknownMemberType]
self.web_app.add_routes([static("/static", path.join(path.dirname(__file__), '..', 'static'))])
self.web_app.add_routes([static("/static", path.join(path.dirname(__file__), 'static'))])

def exception_handler(self, loop: AbstractEventLoop, context: Dict[str, str]):
if context["message"] == "Unclosed connection":
Expand Down
155 changes: 78 additions & 77 deletions backend/poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions backend/pyinstaller.spec
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ from PyInstaller.utils.hooks import copy_metadata
a = Analysis(
['main.py'],
datas=[
('locales', 'locales'),
('static', 'static'),
('decky_loader/locales', 'decky_loader/locales'),
('decky_loader/static', 'decky_loader/static'),
] + copy_metadata('decky_loader'),
hiddenimports=['logging.handlers', 'sqlite3', 'decky_plugin', 'decky'],
)
Expand Down
11 changes: 7 additions & 4 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,24 @@ packages = [
{include = "decky_loader"},
{include = "decky_loader/main.py"}
]
include = ["decky_loader/static/*"]
include = [
"decky_loader/locales/*",
"decky_loader/static/*"
]

[tool.poetry.dependencies]
python = ">=3.10,<3.13"

aiohttp = "^3.9.5"
aiohttp-jinja2 = "^1.5.1"
aiohttp-cors = "^0.7.0"
watchdog = "^2.1.7"
watchdog = "^4"
certifi = "*"
packaging = "^23.2"
packaging = "^24"
multidict = "^6.0.5"

[tool.poetry.group.dev.dependencies]
pyinstaller = "^5.13.0"
pyinstaller = "^6.8.0"
pyright = "^1.1.335"

[tool.poetry.scripts]
Expand Down
18 changes: 9 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/i18next-parser.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default {
// Namespace separator used in your translation keys
// If you want to use plain english keys, separators such as `.` and `:` will conflict. You might want to set `keySeparator: false` and `namespaceSeparator: false`. That way, `t('Status: Loading...')` will not think that there are a namespace and three separator dots for instance.

output: '../backend/locales/$LOCALE.json',
output: '../backend/decky_loader/locales/$LOCALE.json',
// Supports $LOCALE and $NAMESPACE injection
// Supports JSON (.json) and YAML (.yml) file formats
// Where to write the locale files relative to process.cwd()
Expand Down
4 changes: 2 additions & 2 deletions frontend/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const hiddenWarnings = ['THIS_IS_UNDEFINED', 'EVAL'];
export default defineConfig({
input: 'src/index.ts',
plugins: [
del({ targets: '../backend/static/*', force: true }),
del({ targets: '../backend/decky_loader/static/*', force: true }),
commonjs(),
nodeResolve({
browser: true,
Expand All @@ -38,7 +38,7 @@ export default defineConfig({
],
preserveEntrySignatures: false,
output: {
dir: '../backend/static',
dir: '../backend/decky_loader/static',
format: 'esm',
chunkFileNames: (chunkInfo) => {
return 'chunk-[hash].js';
Expand Down
Loading