Spaces:
Sleeping
Sleeping
File size: 1,271 Bytes
5ad8a1f 8040594 f35bbe0 cd4b870 8040594 f35bbe0 1cff389 8040594 6f69491 f35bbe0 8040594 f35bbe0 8040594 f35bbe0 8040594 f35bbe0 8040594 b17cf13 f35bbe0 8040594 3a9839d 1476674 b517a19 f35bbe0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
import os
from pathlib import Path
from git import Repo
import sys
# ---- 1. pick a writable base dir (we'll stop using /app)
BASE_DIR = Path("/tmp/huniu_runtime")
STREAMLIT_DIR = BASE_DIR / ".streamlit"
REPO_TARGET = BASE_DIR / "huniu"
# ensure the base dir exists
BASE_DIR.mkdir(parents=True, exist_ok=True)
STREAMLIT_DIR.mkdir(parents=True, exist_ok=True)
# ---- 2. tell Streamlit to treat /tmp/... as "home"
os.environ.setdefault("HOME", str(BASE_DIR))
os.environ.setdefault("XDG_CONFIG_HOME", str(BASE_DIR))
os.environ.setdefault("STREAMLIT_CONFIG_DIR", str(STREAMLIT_DIR))
os.environ.setdefault("STREAMLIT_HOME", str(BASE_DIR))
os.environ.setdefault("STREAMLIT_BROWSER_GATHERUSAGESTATS", "false")
# ---- 3. clone private repo into /tmp/huniu_runtime/huniu if not already there
if not REPO_TARGET.exists():
git_url = os.environ.get("GIT_URL")
if not git_url:
raise RuntimeError("GIT_URL env var is not set")
Repo.clone_from(git_url, REPO_TARGET)
# make that repo importable
sys.path.append(str(REPO_TARGET))
# ---- 4. now safe to import streamlit and run the app
import streamlit as st
import huniu
#st.write("repo loaded from", str(REPO_TARGET))
#st.image("huniutoo.png")
#st.image("gwecon.png")
huniu.huniu()
# ...rest of your UI...
|