From 5697d98862efa81a8ad3651e9ef68d754a58ea90 Mon Sep 17 00:00:00 2001 From: K900 Date: Thu, 27 Jun 2024 11:46:47 +0300 Subject: [PATCH] treewide: fix package structure The static files need to be inside the module to be installed correctly as part of the module. --- .gitignore | 2 +- backend/decky_loader/loader.py | 4 ++-- backend/{ => decky_loader}/locales/ar-AA.json | 0 backend/{ => decky_loader}/locales/bg-BG.json | 0 backend/{ => decky_loader}/locales/cs-CZ.json | 0 backend/{ => decky_loader}/locales/de-DE.json | 0 backend/{ => decky_loader}/locales/el-GR.json | 0 backend/{ => decky_loader}/locales/en-US.json | 0 backend/{ => decky_loader}/locales/es-ES.json | 0 backend/{ => decky_loader}/locales/fi-FI.json | 0 backend/{ => decky_loader}/locales/fr-FR.json | 0 backend/{ => decky_loader}/locales/it-IT.json | 0 backend/{ => decky_loader}/locales/ja-JP.json | 0 backend/{ => decky_loader}/locales/ko-KR.json | 0 backend/{ => decky_loader}/locales/nl-NL.json | 0 backend/{ => decky_loader}/locales/pl-PL.json | 0 backend/{ => decky_loader}/locales/pt-BR.json | 0 backend/{ => decky_loader}/locales/pt-PT.json | 0 backend/{ => decky_loader}/locales/ru-RU.json | 0 backend/{ => decky_loader}/locales/sq-AL.json | 0 backend/{ => decky_loader}/locales/sv-SE.json | 0 backend/{ => decky_loader}/locales/tr-TR.json | 0 backend/{ => decky_loader}/locales/uk-UA.json | 0 backend/{ => decky_loader}/locales/zh-CN.json | 0 backend/{ => decky_loader}/locales/zh-TW.json | 0 backend/decky_loader/main.py | 2 +- backend/pyinstaller.spec | 4 ++-- backend/pyproject.toml | 5 ++++- frontend/i18next-parser.config.mjs | 2 +- frontend/rollup.config.js | 4 ++-- 30 files changed, 13 insertions(+), 10 deletions(-) rename backend/{ => decky_loader}/locales/ar-AA.json (100%) rename backend/{ => decky_loader}/locales/bg-BG.json (100%) rename backend/{ => decky_loader}/locales/cs-CZ.json (100%) rename backend/{ => decky_loader}/locales/de-DE.json (100%) rename backend/{ => decky_loader}/locales/el-GR.json (100%) rename backend/{ => decky_loader}/locales/en-US.json (100%) rename backend/{ => decky_loader}/locales/es-ES.json (100%) rename backend/{ => decky_loader}/locales/fi-FI.json (100%) rename backend/{ => decky_loader}/locales/fr-FR.json (100%) rename backend/{ => decky_loader}/locales/it-IT.json (100%) rename backend/{ => decky_loader}/locales/ja-JP.json (100%) rename backend/{ => decky_loader}/locales/ko-KR.json (100%) rename backend/{ => decky_loader}/locales/nl-NL.json (100%) rename backend/{ => decky_loader}/locales/pl-PL.json (100%) rename backend/{ => decky_loader}/locales/pt-BR.json (100%) rename backend/{ => decky_loader}/locales/pt-PT.json (100%) rename backend/{ => decky_loader}/locales/ru-RU.json (100%) rename backend/{ => decky_loader}/locales/sq-AL.json (100%) rename backend/{ => decky_loader}/locales/sv-SE.json (100%) rename backend/{ => decky_loader}/locales/tr-TR.json (100%) rename backend/{ => decky_loader}/locales/uk-UA.json (100%) rename backend/{ => decky_loader}/locales/zh-CN.json (100%) rename backend/{ => decky_loader}/locales/zh-TW.json (100%) diff --git a/.gitignore b/.gitignore index 2b0cc95e..f9a954e0 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/backend/decky_loader/loader.py b/backend/decky_loader/loader.py index 4fc03237..e8a073a9 100644 --- a/backend/decky_loader/loader.py +++ b/backend/decky_loader/loader.py @@ -106,12 +106,12 @@ class Loader: 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: diff --git a/backend/locales/ar-AA.json b/backend/decky_loader/locales/ar-AA.json similarity index 100% rename from backend/locales/ar-AA.json rename to backend/decky_loader/locales/ar-AA.json diff --git a/backend/locales/bg-BG.json b/backend/decky_loader/locales/bg-BG.json similarity index 100% rename from backend/locales/bg-BG.json rename to backend/decky_loader/locales/bg-BG.json diff --git a/backend/locales/cs-CZ.json b/backend/decky_loader/locales/cs-CZ.json similarity index 100% rename from backend/locales/cs-CZ.json rename to backend/decky_loader/locales/cs-CZ.json diff --git a/backend/locales/de-DE.json b/backend/decky_loader/locales/de-DE.json similarity index 100% rename from backend/locales/de-DE.json rename to backend/decky_loader/locales/de-DE.json diff --git a/backend/locales/el-GR.json b/backend/decky_loader/locales/el-GR.json similarity index 100% rename from backend/locales/el-GR.json rename to backend/decky_loader/locales/el-GR.json diff --git a/backend/locales/en-US.json b/backend/decky_loader/locales/en-US.json similarity index 100% rename from backend/locales/en-US.json rename to backend/decky_loader/locales/en-US.json diff --git a/backend/locales/es-ES.json b/backend/decky_loader/locales/es-ES.json similarity index 100% rename from backend/locales/es-ES.json rename to backend/decky_loader/locales/es-ES.json diff --git a/backend/locales/fi-FI.json b/backend/decky_loader/locales/fi-FI.json similarity index 100% rename from backend/locales/fi-FI.json rename to backend/decky_loader/locales/fi-FI.json diff --git a/backend/locales/fr-FR.json b/backend/decky_loader/locales/fr-FR.json similarity index 100% rename from backend/locales/fr-FR.json rename to backend/decky_loader/locales/fr-FR.json diff --git a/backend/locales/it-IT.json b/backend/decky_loader/locales/it-IT.json similarity index 100% rename from backend/locales/it-IT.json rename to backend/decky_loader/locales/it-IT.json diff --git a/backend/locales/ja-JP.json b/backend/decky_loader/locales/ja-JP.json similarity index 100% rename from backend/locales/ja-JP.json rename to backend/decky_loader/locales/ja-JP.json diff --git a/backend/locales/ko-KR.json b/backend/decky_loader/locales/ko-KR.json similarity index 100% rename from backend/locales/ko-KR.json rename to backend/decky_loader/locales/ko-KR.json diff --git a/backend/locales/nl-NL.json b/backend/decky_loader/locales/nl-NL.json similarity index 100% rename from backend/locales/nl-NL.json rename to backend/decky_loader/locales/nl-NL.json diff --git a/backend/locales/pl-PL.json b/backend/decky_loader/locales/pl-PL.json similarity index 100% rename from backend/locales/pl-PL.json rename to backend/decky_loader/locales/pl-PL.json diff --git a/backend/locales/pt-BR.json b/backend/decky_loader/locales/pt-BR.json similarity index 100% rename from backend/locales/pt-BR.json rename to backend/decky_loader/locales/pt-BR.json diff --git a/backend/locales/pt-PT.json b/backend/decky_loader/locales/pt-PT.json similarity index 100% rename from backend/locales/pt-PT.json rename to backend/decky_loader/locales/pt-PT.json diff --git a/backend/locales/ru-RU.json b/backend/decky_loader/locales/ru-RU.json similarity index 100% rename from backend/locales/ru-RU.json rename to backend/decky_loader/locales/ru-RU.json diff --git a/backend/locales/sq-AL.json b/backend/decky_loader/locales/sq-AL.json similarity index 100% rename from backend/locales/sq-AL.json rename to backend/decky_loader/locales/sq-AL.json diff --git a/backend/locales/sv-SE.json b/backend/decky_loader/locales/sv-SE.json similarity index 100% rename from backend/locales/sv-SE.json rename to backend/decky_loader/locales/sv-SE.json diff --git a/backend/locales/tr-TR.json b/backend/decky_loader/locales/tr-TR.json similarity index 100% rename from backend/locales/tr-TR.json rename to backend/decky_loader/locales/tr-TR.json diff --git a/backend/locales/uk-UA.json b/backend/decky_loader/locales/uk-UA.json similarity index 100% rename from backend/locales/uk-UA.json rename to backend/decky_loader/locales/uk-UA.json diff --git a/backend/locales/zh-CN.json b/backend/decky_loader/locales/zh-CN.json similarity index 100% rename from backend/locales/zh-CN.json rename to backend/decky_loader/locales/zh-CN.json diff --git a/backend/locales/zh-TW.json b/backend/decky_loader/locales/zh-TW.json similarity index 100% rename from backend/locales/zh-TW.json rename to backend/decky_loader/locales/zh-TW.json diff --git a/backend/decky_loader/main.py b/backend/decky_loader/main.py index a1e683da..fe93c11b 100644 --- a/backend/decky_loader/main.py +++ b/backend/decky_loader/main.py @@ -88,7 +88,7 @@ class PluginManager: 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": diff --git a/backend/pyinstaller.spec b/backend/pyinstaller.spec index a9eba6a4..91ff4e5b 100644 --- a/backend/pyinstaller.spec +++ b/backend/pyinstaller.spec @@ -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'], ) diff --git a/backend/pyproject.toml b/backend/pyproject.toml index 0d5b65b0..a5474e6a 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -8,7 +8,10 @@ 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" diff --git a/frontend/i18next-parser.config.mjs b/frontend/i18next-parser.config.mjs index 8de58cfc..0e36964d 100644 --- a/frontend/i18next-parser.config.mjs +++ b/frontend/i18next-parser.config.mjs @@ -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() diff --git a/frontend/rollup.config.js b/frontend/rollup.config.js index e86fbf07..911cf06d 100644 --- a/frontend/rollup.config.js +++ b/frontend/rollup.config.js @@ -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, @@ -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';