Siyuan Hu commited on
Commit
25f36c7
·
1 Parent(s): 727f90e

fix: correct conditional chain and add python -m tectonic fallback for both compile functions

Browse files
Files changed (1) hide show
  1. app.py +17 -4
app.py CHANGED
@@ -394,8 +394,15 @@ def _compile_poster_pdf(OUTPUT_DIR: Path, logs):
394
  cmd = ["latexmk", "-pdf", "-interaction=nonstopmode", tex_path.name]
395
  logs.append("▶ Compiling with latexmk …")
396
  else:
397
- logs.append("⚠️ No TeX engine found (tectonic/lualatex/xelatex/latexmk). Skipping PDF compile.")
398
- return None
 
 
 
 
 
 
 
399
 
400
  proc = _sp.run(cmd, cwd=str(proj_dir), stdout=_sp.PIPE, stderr=_sp.STDOUT, text=True)
401
  if proc.stdout:
@@ -450,8 +457,14 @@ def _compile_tex_to_pdf(tex_path: Path, logs):
450
  cmd = ["latexmk", "-pdf", "-interaction=nonstopmode", tex_path.name]
451
  logs.append("▶ Compiling with latexmk …")
452
  else:
453
- logs.append("⚠️ No TeX engine found.")
454
- return None
 
 
 
 
 
 
455
  proc = _sp.run(cmd, cwd=str(proj_dir), stdout=_sp.PIPE, stderr=_sp.STDOUT, text=True)
456
  if proc.stdout:
457
  logs.append(proc.stdout[-4000:])
 
394
  cmd = ["latexmk", "-pdf", "-interaction=nonstopmode", tex_path.name]
395
  logs.append("▶ Compiling with latexmk …")
396
  else:
397
+ # try python -m tectonic if module is installed
398
+ try:
399
+ import importlib
400
+ importlib.import_module("tectonic")
401
+ cmd = [sys.executable, "-m", "tectonic", tex_path.name]
402
+ logs.append("▶ Compiling with python -m tectonic …")
403
+ except Exception:
404
+ logs.append("⚠️ No TeX engine found (tectonic/lualatex/xelatex/latexmk) and 'tectonic' module missing. Skipping PDF compile.")
405
+ return None
406
 
407
  proc = _sp.run(cmd, cwd=str(proj_dir), stdout=_sp.PIPE, stderr=_sp.STDOUT, text=True)
408
  if proc.stdout:
 
457
  cmd = ["latexmk", "-pdf", "-interaction=nonstopmode", tex_path.name]
458
  logs.append("▶ Compiling with latexmk …")
459
  else:
460
+ try:
461
+ import importlib
462
+ importlib.import_module("tectonic")
463
+ cmd = [sys.executable, "-m", "tectonic", tex_path.name]
464
+ logs.append("▶ Compiling with python -m tectonic …")
465
+ except Exception:
466
+ logs.append("⚠️ No TeX engine found.")
467
+ return None
468
  proc = _sp.run(cmd, cwd=str(proj_dir), stdout=_sp.PIPE, stderr=_sp.STDOUT, text=True)
469
  if proc.stdout:
470
  logs.append(proc.stdout[-4000:])