Spaces:
Running
Running
Commit ·
d6faa34
1
Parent(s): f85a714
feat(ui): labels/ordering/platform hints for Linux AppImage, Arch PKGBUILD, MCP; API tests; README
Browse files- README.md +11 -1
- README_HF.md +11 -1
- backend/app/converters/desktop/linux_appimage.py +3 -2
- backend/tests/test_api.py +32 -0
- frontend/src/App.tsx +4 -3
- frontend/src/components/TargetPicker.tsx +26 -3
- frontend/src/i18n/en.ts +3 -0
- frontend/src/styles.css +7 -0
- frontend/src/types/index.ts +2 -0
README.md
CHANGED
|
@@ -31,7 +31,17 @@ Paste a Hugging Face Space URL → analyze runtime → choose packaging targets
|
|
| 31 |
- Tauri project generator (zip) — Local **project** (no binary claimed on HF)
|
| 32 |
- **Android Capacitor** — **Hosted Wrapper** **debug APK** when SDK build succeeds (unsigned); project zip **fallback** if APK build fails
|
| 33 |
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
See `ANDROID.md` for Android install steps and labeling.
|
| 37 |
|
|
|
|
| 31 |
- Tauri project generator (zip) — Local **project** (no binary claimed on HF)
|
| 32 |
- **Android Capacitor** — **Hosted Wrapper** **debug APK** when SDK build succeeds (unsigned); project zip **fallback** if APK build fails
|
| 33 |
|
| 34 |
+
- **Linux AppImage** (x86_64 `.AppImage`) — **Hosted Wrapper**: pinned prebuilt Neutralinojs 6.10.0 window
|
| 35 |
+
loading the live Space; packed with pinned appimagetool 1.9.1 (no FUSE needed to build). Needs
|
| 36 |
+
`webkit2gtk-4.1` + `gtk3` on the host.
|
| 37 |
+
- **Arch Linux (PKGBUILD)** (`-pkgbuild.tar.gz`) — **Hosted Wrapper** for Arch/CachyOS/Manjaro:
|
| 38 |
+
`tar xf …; cd …; makepkg -si` installs `/opt/<pkg>`, `/usr/bin/<pkg>`, desktop entry + icon.
|
| 39 |
+
- **MCP Server / Config** (zip) — Gradio Spaces with `mcp_server=True` → Cursor / Claude Desktop / generic
|
| 40 |
+
configs for the Space's own `/gradio_api/mcp/sse`; otherwise a small Python MCP stdio server
|
| 41 |
+
(one tool per Gradio API endpoint via `gradio_client`, or a generic `call_space` HTTP tool for
|
| 42 |
+
Docker Spaces). Optional `HF_TOKEN` env.
|
| 43 |
+
|
| 44 |
+
Stub (clear message): Windows portable — not buildable inside HF CPU.
|
| 45 |
|
| 46 |
See `ANDROID.md` for Android install steps and labeling.
|
| 47 |
|
README_HF.md
CHANGED
|
@@ -31,7 +31,17 @@ Paste a Hugging Face Space URL → analyze runtime → choose packaging targets
|
|
| 31 |
- Tauri project generator (zip) — Local **project** (no binary claimed on HF)
|
| 32 |
- **Android Capacitor** — **Hosted Wrapper** **debug APK** when SDK build succeeds (unsigned); project zip **fallback** if APK build fails
|
| 33 |
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
See `ANDROID.md` for Android install steps and labeling.
|
| 37 |
|
|
|
|
| 31 |
- Tauri project generator (zip) — Local **project** (no binary claimed on HF)
|
| 32 |
- **Android Capacitor** — **Hosted Wrapper** **debug APK** when SDK build succeeds (unsigned); project zip **fallback** if APK build fails
|
| 33 |
|
| 34 |
+
- **Linux AppImage** (x86_64 `.AppImage`) — **Hosted Wrapper**: pinned prebuilt Neutralinojs 6.10.0 window
|
| 35 |
+
loading the live Space; packed with pinned appimagetool 1.9.1 (no FUSE needed to build). Needs
|
| 36 |
+
`webkit2gtk-4.1` + `gtk3` on the host.
|
| 37 |
+
- **Arch Linux (PKGBUILD)** (`-pkgbuild.tar.gz`) — **Hosted Wrapper** for Arch/CachyOS/Manjaro:
|
| 38 |
+
`tar xf …; cd …; makepkg -si` installs `/opt/<pkg>`, `/usr/bin/<pkg>`, desktop entry + icon.
|
| 39 |
+
- **MCP Server / Config** (zip) — Gradio Spaces with `mcp_server=True` → Cursor / Claude Desktop / generic
|
| 40 |
+
configs for the Space's own `/gradio_api/mcp/sse`; otherwise a small Python MCP stdio server
|
| 41 |
+
(one tool per Gradio API endpoint via `gradio_client`, or a generic `call_space` HTTP tool for
|
| 42 |
+
Docker Spaces). Optional `HF_TOKEN` env.
|
| 43 |
+
|
| 44 |
+
Stub (clear message): Windows portable — not buildable inside HF CPU.
|
| 45 |
|
| 46 |
See `ANDROID.md` for Android install steps and labeling.
|
| 47 |
|
backend/app/converters/desktop/linux_appimage.py
CHANGED
|
@@ -127,11 +127,12 @@ def pack_appimage(appdir: Path, out: Path, log) -> None:
|
|
| 127 |
env["ARCH"] = "x86_64"
|
| 128 |
env["APPIMAGE_EXTRACT_AND_RUN"] = "1"
|
| 129 |
env.pop("SOURCE_DATE_EPOCH", None)
|
| 130 |
-
log("$ " + " ".join(Path(a).name if
|
| 131 |
proc = subprocess.run(argv, env=env, capture_output=True, text=True, timeout=240)
|
| 132 |
tail = ((proc.stdout or "") + "\n" + (proc.stderr or "")).strip().splitlines()[-12:]
|
|
|
|
| 133 |
for line in tail:
|
| 134 |
-
if line.strip():
|
| 135 |
log(" " + line[:300])
|
| 136 |
if proc.returncode != 0 or not out.is_file():
|
| 137 |
raise RuntimeError(f"appimagetool failed (exit {proc.returncode})")
|
|
|
|
| 127 |
env["ARCH"] = "x86_64"
|
| 128 |
env["APPIMAGE_EXTRACT_AND_RUN"] = "1"
|
| 129 |
env.pop("SOURCE_DATE_EPOCH", None)
|
| 130 |
+
log("$ appimagetool " + " ".join(Path(a).name if a.startswith("/") else a for a in argv[len(cmd):]))
|
| 131 |
proc = subprocess.run(argv, env=env, capture_output=True, text=True, timeout=240)
|
| 132 |
tail = ((proc.stdout or "") + "\n" + (proc.stderr or "")).strip().splitlines()[-12:]
|
| 133 |
+
noise = ("Please consider", "central directory", "at https://github.com/AppImage/appimage.github.io")
|
| 134 |
for line in tail:
|
| 135 |
+
if line.strip() and not line.strip().startswith(noise):
|
| 136 |
log(" " + line[:300])
|
| 137 |
if proc.returncode != 0 or not out.is_file():
|
| 138 |
raise RuntimeError(f"appimagetool failed (exit {proc.returncode})")
|
backend/tests/test_api.py
CHANGED
|
@@ -165,3 +165,35 @@ async def test_large_download_rejected(client, tmp_path, monkeypatch):
|
|
| 165 |
monkeypatch.setattr("backend.app.api.routes.MAX_DOWNLOAD_BYTES", 100)
|
| 166 |
dl = await client.get(f"/api/build/{bid}/download", params={"target": "html_widget"})
|
| 167 |
assert dl.status_code == 413
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
monkeypatch.setattr("backend.app.api.routes.MAX_DOWNLOAD_BYTES", 100)
|
| 166 |
dl = await client.get(f"/api/build/{bid}/download", params={"target": "html_widget"})
|
| 167 |
assert dl.status_code == 413
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
@pytest.mark.asyncio
|
| 171 |
+
async def test_targets_include_new_desktop_and_mcp(client):
|
| 172 |
+
r = await client.get("/api/targets")
|
| 173 |
+
ids = [t["id"] for t in r.json()["targets"]]
|
| 174 |
+
for tid in ("linux_appimage", "arch_pkgbuild", "mcp", "windows_portable"):
|
| 175 |
+
assert tid in ids
|
| 176 |
+
by = {t["id"]: t for t in r.json()["targets"]}
|
| 177 |
+
assert by["windows_portable"]["stub"] is True and by["windows_portable"]["available"] is False
|
| 178 |
+
assert by["mcp"]["available"] is True and by["mcp"]["stub"] is False
|
| 179 |
+
assert by["arch_pkgbuild"]["label"] == "Arch Linux (PKGBUILD)"
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
@pytest.mark.asyncio
|
| 183 |
+
async def test_build_mcp_docker_space(client):
|
| 184 |
+
info = dict(SAMPLE_INFO, repo_id="2Btainment/repospace", owner="2Btainment", name="repospace",
|
| 185 |
+
sdk="docker", embed_url="https://2btainment-repospace.hf.space")
|
| 186 |
+
with patch("backend.app.api.routes.fetch_space_info", AsyncMock(return_value=info)):
|
| 187 |
+
r = await client.post("/api/build", json={"url": "2Btainment/repospace", "targets": ["mcp"]})
|
| 188 |
+
bid = r.json()["build_id"]
|
| 189 |
+
import asyncio
|
| 190 |
+
for _ in range(50):
|
| 191 |
+
body = (await client.get(f"/api/build/{bid}")).json()
|
| 192 |
+
if body["status"] in ("done", "error"):
|
| 193 |
+
break
|
| 194 |
+
await asyncio.sleep(0.1)
|
| 195 |
+
assert body["status"] == "done", body
|
| 196 |
+
art = body["artifacts"]["mcp"]
|
| 197 |
+
assert art["filename"] == "repospace-mcp.zip" and art["binary_included"] is False
|
| 198 |
+
dl = await client.get(f"/api/build/{bid}/download", params={"target": "mcp"})
|
| 199 |
+
assert zipfile.is_zipfile(io.BytesIO(dl.content))
|
frontend/src/App.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import { useCallback, useState } from "react";
|
| 2 |
import { analyzeSpace, downloadUrl, getBuild, getLogs, startBuild } from "./api/client";
|
| 3 |
-
import { TargetPicker } from "./components/TargetPicker";
|
| 4 |
import { ModeBadge } from "./components/ModeBadge";
|
| 5 |
import { t } from "./i18n";
|
| 6 |
import type { AnalyzeResponse, BuildStatus } from "./types";
|
|
@@ -190,9 +190,10 @@ export default function App() {
|
|
| 190 |
{Object.entries(build.artifacts).map(([tid, art]) => (
|
| 191 |
<div className="artifact" key={tid}>
|
| 192 |
<div>
|
| 193 |
-
<strong>{tid
|
|
|
|
| 194 |
<div className="hint">
|
| 195 |
-
{art.filename} · {(art.size / 1024).toFixed(1)} KB · {art.notes}
|
| 196 |
</div>
|
| 197 |
</div>
|
| 198 |
<a className="secondary" href={downloadUrl(build.id, tid)} download={art.filename} data-testid={`download-${tid}`} style={{
|
|
|
|
| 1 |
import { useCallback, useState } from "react";
|
| 2 |
import { analyzeSpace, downloadUrl, getBuild, getLogs, startBuild } from "./api/client";
|
| 3 |
+
import { TargetPicker, targetLabel } from "./components/TargetPicker";
|
| 4 |
import { ModeBadge } from "./components/ModeBadge";
|
| 5 |
import { t } from "./i18n";
|
| 6 |
import type { AnalyzeResponse, BuildStatus } from "./types";
|
|
|
|
| 190 |
{Object.entries(build.artifacts).map(([tid, art]) => (
|
| 191 |
<div className="artifact" key={tid}>
|
| 192 |
<div>
|
| 193 |
+
<strong>{targetLabel(tid, analysis?.compatibility.targets.find((x) => x.id === tid)?.label)}</strong>{" "}
|
| 194 |
+
<ModeBadge mode={art.mode} />
|
| 195 |
<div className="hint">
|
| 196 |
+
{art.filename} · {art.size >= 1024 * 1024 ? `${(art.size / 1048576).toFixed(2)} MB` : `${(art.size / 1024).toFixed(1)} KB`} · {art.notes}
|
| 197 |
</div>
|
| 198 |
</div>
|
| 199 |
<a className="secondary" href={downloadUrl(build.id, tid)} download={art.filename} data-testid={`download-${tid}`} style={{
|
frontend/src/components/TargetPicker.tsx
CHANGED
|
@@ -2,6 +2,23 @@ import type { CompatLevel, TargetInfo } from "../types";
|
|
| 2 |
import { ModeBadge } from "./ModeBadge";
|
| 3 |
import { t } from "../i18n";
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
function CompatChip({ level, label }: { level: CompatLevel; label: string }) {
|
| 6 |
const icon = level === "ok" ? "✓" : level === "warn" ? "⚠" : "✗";
|
| 7 |
return (
|
|
@@ -21,14 +38,19 @@ export function TargetPicker({
|
|
| 21 |
onChange: (next: Set<string>) => void;
|
| 22 |
}) {
|
| 23 |
const m = t();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
return (
|
| 25 |
<div className="targets">
|
| 26 |
-
{targets.map((tg) => {
|
| 27 |
const disabled = !tg.available;
|
| 28 |
const checked = selected.has(tg.id);
|
| 29 |
const c = tg.compat;
|
| 30 |
return (
|
| 31 |
-
<div key={tg.id} className={`target ${disabled ? "disabled" : ""}`}>
|
| 32 |
<input
|
| 33 |
type="checkbox"
|
| 34 |
disabled={disabled}
|
|
@@ -42,8 +64,9 @@ export function TargetPicker({
|
|
| 42 |
/>
|
| 43 |
<div>
|
| 44 |
<label>
|
| 45 |
-
{tg.label} <ModeBadge mode={tg.mode} />
|
| 46 |
</label>
|
|
|
|
| 47 |
<div className="reason">{tg.reason}</div>
|
| 48 |
{c ? (
|
| 49 |
<div className="compat-row">
|
|
|
|
| 2 |
import { ModeBadge } from "./ModeBadge";
|
| 3 |
import { t } from "../i18n";
|
| 4 |
|
| 5 |
+
/** Canonical labels for the newer targets (backend label wins when present). */
|
| 6 |
+
export const TARGET_LABELS: Record<string, string> = {
|
| 7 |
+
linux_appimage: "Linux AppImage",
|
| 8 |
+
arch_pkgbuild: "Arch Linux (PKGBUILD)",
|
| 9 |
+
mcp: "MCP Server / Config",
|
| 10 |
+
windows_portable: "Windows Portable",
|
| 11 |
+
};
|
| 12 |
+
|
| 13 |
+
export function targetLabel(id: string, label?: string): string {
|
| 14 |
+
return label || TARGET_LABELS[id] || id;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
/** Real targets first, disabled stubs last (stable within each group). */
|
| 18 |
+
export function orderTargets(targets: TargetInfo[]): TargetInfo[] {
|
| 19 |
+
return [...targets].sort((a, b) => Number(!!a.stub) - Number(!!b.stub));
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
function CompatChip({ level, label }: { level: CompatLevel; label: string }) {
|
| 23 |
const icon = level === "ok" ? "✓" : level === "warn" ? "⚠" : "✗";
|
| 24 |
return (
|
|
|
|
| 38 |
onChange: (next: Set<string>) => void;
|
| 39 |
}) {
|
| 40 |
const m = t();
|
| 41 |
+
const platform: Record<string, string> = {
|
| 42 |
+
linux_appimage: m.platformAppImage,
|
| 43 |
+
arch_pkgbuild: m.platformPkgbuild,
|
| 44 |
+
mcp: m.platformMcp,
|
| 45 |
+
};
|
| 46 |
return (
|
| 47 |
<div className="targets">
|
| 48 |
+
{orderTargets(targets).map((tg) => {
|
| 49 |
const disabled = !tg.available;
|
| 50 |
const checked = selected.has(tg.id);
|
| 51 |
const c = tg.compat;
|
| 52 |
return (
|
| 53 |
+
<div key={tg.id} className={`target ${disabled ? "disabled" : ""}`} data-testid={`target-${tg.id}`}>
|
| 54 |
<input
|
| 55 |
type="checkbox"
|
| 56 |
disabled={disabled}
|
|
|
|
| 64 |
/>
|
| 65 |
<div>
|
| 66 |
<label>
|
| 67 |
+
{targetLabel(tg.id, tg.label)} <ModeBadge mode={tg.mode} />
|
| 68 |
</label>
|
| 69 |
+
{platform[tg.id] ? <div className="platform">{platform[tg.id]}</div> : null}
|
| 70 |
<div className="reason">{tg.reason}</div>
|
| 71 |
{c ? (
|
| 72 |
<div className="compat-row">
|
frontend/src/i18n/en.ts
CHANGED
|
@@ -32,6 +32,9 @@ export const en = {
|
|
| 32 |
compatApkWarn: "APK fallback / build failed",
|
| 33 |
compatGpuNo: "GPU local impossible",
|
| 34 |
compatGpuWarn: "not Local offline APK",
|
|
|
|
|
|
|
|
|
|
| 35 |
} as const;
|
| 36 |
|
| 37 |
export type Messages = typeof en;
|
|
|
|
| 32 |
compatApkWarn: "APK fallback / build failed",
|
| 33 |
compatGpuNo: "GPU local impossible",
|
| 34 |
compatGpuWarn: "not Local offline APK",
|
| 35 |
+
platformAppImage: "🐧 Linux x86_64 · needs webkit2gtk-4.1",
|
| 36 |
+
platformPkgbuild: "Arch / CachyOS / Manjaro · makepkg -si",
|
| 37 |
+
platformMcp: "Cursor · Claude Desktop · any MCP client",
|
| 38 |
} as const;
|
| 39 |
|
| 40 |
export type Messages = typeof en;
|
frontend/src/styles.css
CHANGED
|
@@ -166,3 +166,10 @@ pre.logs {
|
|
| 166 |
filter: brightness(1.05);
|
| 167 |
text-decoration: none;
|
| 168 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
filter: brightness(1.05);
|
| 167 |
text-decoration: none;
|
| 168 |
}
|
| 169 |
+
|
| 170 |
+
/* Platform hint under new desktop / MCP targets */
|
| 171 |
+
.platform {
|
| 172 |
+
font-size: 0.78rem;
|
| 173 |
+
color: var(--muted, #8b93a7);
|
| 174 |
+
margin-top: 0.15rem;
|
| 175 |
+
}
|
frontend/src/types/index.ts
CHANGED
|
@@ -66,6 +66,8 @@ export interface BuildStatus {
|
|
| 66 |
notes: string;
|
| 67 |
size: number;
|
| 68 |
path_name: string;
|
|
|
|
|
|
|
| 69 |
}
|
| 70 |
>;
|
| 71 |
errors: Record<string, string>;
|
|
|
|
| 66 |
notes: string;
|
| 67 |
size: number;
|
| 68 |
path_name: string;
|
| 69 |
+
binary_included?: boolean;
|
| 70 |
+
artifact_kind?: string;
|
| 71 |
}
|
| 72 |
>;
|
| 73 |
errors: Record<string, string>;
|