cazyundee commited on
Commit
a6debd5
·
verified ·
1 Parent(s): 6e19d95

Fix: try pre-built wheel first, fall back to source build

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -426,10 +426,18 @@ def _run_benchmark():
426
  except ImportError:
427
  _log("Benchmark: installing llama-cpp-python...")
428
  import subprocess
429
- subprocess.check_call(
430
- [sys.executable, "-m", "pip", "install", "llama-cpp-python>=0.4.0", "--only-binary=:all:"],
431
- stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
432
- )
 
 
 
 
 
 
 
 
433
  from llama_cpp import Llama
434
 
435
  os.makedirs(_BENCHMARK_CACHE, exist_ok=True)
 
426
  except ImportError:
427
  _log("Benchmark: installing llama-cpp-python...")
428
  import subprocess
429
+ # Try pre-built wheels first, fall back to source build
430
+ try:
431
+ subprocess.check_call(
432
+ [sys.executable, "-m", "pip", "install", "llama-cpp-python>=0.4.0", "--only-binary=:all:"],
433
+ stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
434
+ )
435
+ except subprocess.CalledProcessError:
436
+ _log("Benchmark: no pre-built wheel, building from source...")
437
+ subprocess.check_call(
438
+ [sys.executable, "-m", "pip", "install", "llama-cpp-python>=0.4.0"],
439
+ stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
440
+ )
441
  from llama_cpp import Llama
442
 
443
  os.makedirs(_BENCHMARK_CACHE, exist_ok=True)