Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
fzumstein committed Nov 20, 2024
1 parent 5d32372 commit f8b0924
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions app/routers/xlwings.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,19 @@ async def custom_scripts_sheet_buttons():

@router.get("/pyscript.json")
async def get_pyscript_config():
# requirements.txt
packages = (
Path(settings.base_dir / "lite" / "requirements.txt")
.read_text()
.splitlines()
)
packages = [pkg.strip() for pkg in packages if pkg.strip()]
packages = [
pkg.replace("/static", settings.static_url_path).strip()
for pkg in packages
if pkg.strip()
]

# files
lite_dir = Path(settings.base_dir / "lite")
files = {}
for file_path in lite_dir.rglob("*"):
Expand All @@ -153,8 +160,12 @@ async def get_pyscript_config():
and file_path.name != "requirements.txt"
):
relative_path = file_path.relative_to(lite_dir)
files[f"/lite/{relative_path}"] = f"./{relative_path}"
files[
f"{settings.static_url_path.replace("static", "lite")}/{relative_path}"
] = f"./{relative_path}"
response = {"packages": packages, "files": files}

# Interpreter
if settings.lite_local_pyodide:
response["interpreter"] = (
f"{settings.static_url_path}/vendor/pyodide/pyodide.mjs"
Expand Down

0 comments on commit f8b0924

Please sign in to comment.