Spaces:
Running
Running
Siyuan Hu
commited on
Commit
·
f3dfa83
1
Parent(s):
25f36c7
feat(tectonic): robust detection of binary in common paths + keep python -m fallback; simplify postBuild; avoid pip tectonic
Browse files- app.py +30 -4
- install_tectonic.sh +15 -5
- postBuild +1 -6
- requirements.txt +0 -1
app.py
CHANGED
|
@@ -380,9 +380,22 @@ def _compile_poster_pdf(OUTPUT_DIR: Path, logs):
|
|
| 380 |
|
| 381 |
def _has(bin_name):
|
| 382 |
return _sh.which(bin_name) is not None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 383 |
|
| 384 |
-
|
| 385 |
-
|
|
|
|
| 386 |
logs.append("▶ Compiling with tectonic …")
|
| 387 |
elif _has("lualatex"):
|
| 388 |
cmd = ["lualatex", "-interaction=nonstopmode", tex_path.name]
|
|
@@ -444,8 +457,21 @@ def _compile_tex_to_pdf(tex_path: Path, logs):
|
|
| 444 |
import shutil as _sh, subprocess as _sp
|
| 445 |
def _has(bin_name):
|
| 446 |
return _sh.which(bin_name) is not None
|
| 447 |
-
|
| 448 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 449 |
logs.append("▶ Compiling with tectonic …")
|
| 450 |
elif _has("lualatex"):
|
| 451 |
cmd = ["lualatex", "-interaction=nonstopmode", tex_path.name]
|
|
|
|
| 380 |
|
| 381 |
def _has(bin_name):
|
| 382 |
return _sh.which(bin_name) is not None
|
| 383 |
+
def _candidate_tectonic():
|
| 384 |
+
import os
|
| 385 |
+
cands = [
|
| 386 |
+
"tectonic",
|
| 387 |
+
str(Path("/usr/local/bin/tectonic")),
|
| 388 |
+
str(Path("/usr/bin/tectonic")),
|
| 389 |
+
os.path.expanduser("~/.local/bin/tectonic"),
|
| 390 |
+
]
|
| 391 |
+
for c in cands:
|
| 392 |
+
if _sh.which(c) or Path(c).exists():
|
| 393 |
+
return c
|
| 394 |
+
return None
|
| 395 |
|
| 396 |
+
tbin = _candidate_tectonic()
|
| 397 |
+
if tbin:
|
| 398 |
+
cmd = [tbin, tex_path.name]
|
| 399 |
logs.append("▶ Compiling with tectonic …")
|
| 400 |
elif _has("lualatex"):
|
| 401 |
cmd = ["lualatex", "-interaction=nonstopmode", tex_path.name]
|
|
|
|
| 457 |
import shutil as _sh, subprocess as _sp
|
| 458 |
def _has(bin_name):
|
| 459 |
return _sh.which(bin_name) is not None
|
| 460 |
+
def _candidate_tectonic():
|
| 461 |
+
import os
|
| 462 |
+
cands = [
|
| 463 |
+
"tectonic",
|
| 464 |
+
str(Path("/usr/local/bin/tectonic")),
|
| 465 |
+
str(Path("/usr/bin/tectonic")),
|
| 466 |
+
os.path.expanduser("~/.local/bin/tectonic"),
|
| 467 |
+
]
|
| 468 |
+
for c in cands:
|
| 469 |
+
if _sh.which(c) or Path(c).exists():
|
| 470 |
+
return c
|
| 471 |
+
return None
|
| 472 |
+
tbin = _candidate_tectonic()
|
| 473 |
+
if tbin:
|
| 474 |
+
cmd = [tbin, tex_path.name]
|
| 475 |
logs.append("▶ Compiling with tectonic …")
|
| 476 |
elif _has("lualatex"):
|
| 477 |
cmd = ["lualatex", "-interaction=nonstopmode", tex_path.name]
|
install_tectonic.sh
CHANGED
|
@@ -4,8 +4,21 @@ set -e
|
|
| 4 |
echo "📦 Installing tectonic..."
|
| 5 |
|
| 6 |
if ! command -v tectonic &> /dev/null; then
|
| 7 |
-
|
| 8 |
mkdir -p /tmp/tectonic
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
tar -xzf /tmp/tectonic.tar.gz -C /tmp/tectonic
|
| 10 |
|
| 11 |
# 找到可执行文件路径
|
|
@@ -13,8 +26,6 @@ if ! command -v tectonic &> /dev/null; then
|
|
| 13 |
|
| 14 |
# 默认安装路径
|
| 15 |
INSTALL_DIR="/usr/local/bin"
|
| 16 |
-
|
| 17 |
-
# 如果没有写入权限,就改到用户目录
|
| 18 |
if [ ! -w "$INSTALL_DIR" ]; then
|
| 19 |
INSTALL_DIR="$HOME/.local/bin"
|
| 20 |
mkdir -p "$INSTALL_DIR"
|
|
@@ -26,8 +37,7 @@ if ! command -v tectonic &> /dev/null; then
|
|
| 26 |
|
| 27 |
# 自动提示 PATH 设置
|
| 28 |
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
|
| 29 |
-
echo "⚙️ You may need to add this to your
|
| 30 |
-
echo "export PATH=\$PATH:$INSTALL_DIR"
|
| 31 |
fi
|
| 32 |
|
| 33 |
echo "✅ Tectonic installed successfully at $INSTALL_DIR/tectonic"
|
|
|
|
| 4 |
echo "📦 Installing tectonic..."
|
| 5 |
|
| 6 |
if ! command -v tectonic &> /dev/null; then
|
| 7 |
+
URL="https://github.com/tectonic-typesetting/tectonic/releases/download/tectonic%400.15.0/tectonic-0.15.0-x86_64-unknown-linux-gnu.tar.gz"
|
| 8 |
mkdir -p /tmp/tectonic
|
| 9 |
+
if command -v curl >/dev/null 2>&1; then
|
| 10 |
+
curl -L "$URL" -o /tmp/tectonic.tar.gz
|
| 11 |
+
elif command -v wget >/dev/null 2>&1; then
|
| 12 |
+
wget -O /tmp/tectonic.tar.gz "$URL"
|
| 13 |
+
else
|
| 14 |
+
if command -v apt-get >/dev/null 2>&1; then
|
| 15 |
+
apt-get update && apt-get install -y wget
|
| 16 |
+
wget -O /tmp/tectonic.tar.gz "$URL"
|
| 17 |
+
else
|
| 18 |
+
echo "❌ Neither curl nor wget available, and apt-get not present." >&2
|
| 19 |
+
exit 1
|
| 20 |
+
fi
|
| 21 |
+
fi
|
| 22 |
tar -xzf /tmp/tectonic.tar.gz -C /tmp/tectonic
|
| 23 |
|
| 24 |
# 找到可执行文件路径
|
|
|
|
| 26 |
|
| 27 |
# 默认安装路径
|
| 28 |
INSTALL_DIR="/usr/local/bin"
|
|
|
|
|
|
|
| 29 |
if [ ! -w "$INSTALL_DIR" ]; then
|
| 30 |
INSTALL_DIR="$HOME/.local/bin"
|
| 31 |
mkdir -p "$INSTALL_DIR"
|
|
|
|
| 37 |
|
| 38 |
# 自动提示 PATH 设置
|
| 39 |
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
|
| 40 |
+
echo "⚙️ You may need to add this to your PATH: $INSTALL_DIR"
|
|
|
|
| 41 |
fi
|
| 42 |
|
| 43 |
echo "✅ Tectonic installed successfully at $INSTALL_DIR/tectonic"
|
postBuild
CHANGED
|
@@ -1,12 +1,7 @@
|
|
| 1 |
#!/usr/bin/env bash
|
| 2 |
set -euo pipefail
|
| 3 |
|
| 4 |
-
echo "[postBuild]
|
| 5 |
-
if ! command -v wget >/dev/null 2>&1; then
|
| 6 |
-
apt-get update
|
| 7 |
-
apt-get install -y wget
|
| 8 |
-
fi
|
| 9 |
-
|
| 10 |
bash install_tectonic.sh || echo "[postBuild] Tectonic install script returned non-zero; continuing."
|
| 11 |
|
| 12 |
echo "[postBuild] Done"
|
|
|
|
| 1 |
#!/usr/bin/env bash
|
| 2 |
set -euo pipefail
|
| 3 |
|
| 4 |
+
echo "[postBuild] Installing Tectonic"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
bash install_tectonic.sh || echo "[postBuild] Tectonic install script returned non-zero; continuing."
|
| 6 |
|
| 7 |
echo "[postBuild] Done"
|
requirements.txt
CHANGED
|
@@ -18,7 +18,6 @@ scikit-learn==1.6.1
|
|
| 18 |
scipy==1.15.1
|
| 19 |
sentence-transformers==3.3.1
|
| 20 |
transformers==4.48.0
|
| 21 |
-
tectonic==0.15.0
|
| 22 |
|
| 23 |
# ========= ML / LLM Frameworks =========
|
| 24 |
accelerate
|
|
|
|
| 18 |
scipy==1.15.1
|
| 19 |
sentence-transformers==3.3.1
|
| 20 |
transformers==4.48.0
|
|
|
|
| 21 |
|
| 22 |
# ========= ML / LLM Frameworks =========
|
| 23 |
accelerate
|