Add package structure and resource path utilities

- Created langbot/ package with __init__.py and __main__.py entry point
- Added paths utility to find frontend and resource files from package installation
- Updated config loading to use resource paths
- Updated frontend serving to use resource paths
- Added MANIFEST.in for package data inclusion
- Updated pyproject.toml with build system and entry points

Co-authored-by: RockChinQ <45992437+RockChinQ@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-11-07 13:58:18 +00:00
parent 8fe59da302
commit cab573f3e2
11 changed files with 272 additions and 12 deletions

View File

@@ -18,12 +18,22 @@ class JSONConfigFile(file_model.ConfigFile):
self.template_file_name = template_file_name
self.template_data = template_data
def _get_template_path(self) -> str:
"""Get the actual path to the template file, handling package installation"""
if self.template_file_name is None:
return None
from ...utils import paths as path_utils
return path_utils.get_resource_path(self.template_file_name)
def exists(self) -> bool:
return os.path.exists(self.config_file_name)
async def create(self):
if self.template_file_name is not None:
shutil.copyfile(self.template_file_name, self.config_file_name)
template_path = self._get_template_path()
if template_path is not None:
shutil.copyfile(template_path, self.config_file_name)
elif self.template_data is not None:
with open(self.config_file_name, 'w', encoding='utf-8') as f:
json.dump(self.template_data, f, indent=4, ensure_ascii=False)
@@ -34,8 +44,10 @@ class JSONConfigFile(file_model.ConfigFile):
if not self.exists():
await self.create()
if self.template_file_name is not None:
with open(self.template_file_name, 'r', encoding='utf-8') as f:
template_path = self._get_template_path()
if template_path is not None:
with open(template_path, 'r', encoding='utf-8') as f:
self.template_data = json.load(f)
with open(self.config_file_name, 'r', encoding='utf-8') as f: