@@ -359,9 +359,20 @@ def _user_shell_path_bootstrap() -> list[str]:
359359 return [
360360 'ODYSSEUS_USER_SHELL="${SHELL:-}"' ,
361361 'if [ -n "$ODYSSEUS_USER_SHELL" ] && [ -x "$ODYSSEUS_USER_SHELL" ]; then' ,
362- ' ODYSSEUS_USER_PATH="$("$ODYSSEUS_USER_SHELL" -ic \' printf "__ODYSSEUS_PATH__%s\\ n" "$PATH"\' 2>/dev/null | sed -n \' s/^__ODYSSEUS_PATH__//p\' | tail -n 1 || true)"' ,
362+ ' case "$ODYSSEUS_USER_SHELL" in' ,
363+ ' *fish*) ODYSSEUS_USER_PATH="$("$ODYSSEUS_USER_SHELL" -c \' printf "__ODYSSEUS_PATH__%s\\ n" "$PATH"\' 2>/dev/null | sed -n \' s/^__ODYSSEUS_PATH__//p\' | tail -n 1 || true)" ;;' ,
364+ ' *) ODYSSEUS_USER_PATH="$("$ODYSSEUS_USER_SHELL" -lc \' printf "__ODYSSEUS_PATH__%s\\ n" "$PATH"\' 2>/dev/null | sed -n \' s/^__ODYSSEUS_PATH__//p\' | tail -n 1 || true)" ;;' ,
365+ ' esac' ,
363366 ' if [ -n "$ODYSSEUS_USER_PATH" ]; then export PATH="$ODYSSEUS_USER_PATH:$PATH"; fi' ,
364367 'fi' ,
368+ 'if command -v nproc >/dev/null 2>&1; then' ,
369+ ' _n="$(nproc)"' ,
370+ ' export CMAKE_BUILD_PARALLEL_LEVEL="$(( _n > 2 ? _n - 2 : 1 ))"' ,
371+ ' export NPROC="$(( _n > 2 ? _n - 2 : 1 ))"' ,
372+ 'else' ,
373+ ' export CMAKE_BUILD_PARALLEL_LEVEL=2' ,
374+ ' export NPROC=2' ,
375+ 'fi' ,
365376 # Windows can expose python3 as a Microsoft Store App Execution Alias
366377 # under WindowsApps. Git Bash sees that stub as present, but it exits
367378 # before running Python. A Windows venv usually has python.exe, not
@@ -378,6 +389,7 @@ def _cached_model_scan_script(model_dirs: list[str] | None = None, add_hf_cache:
378389 """
379390 lines = [
380391 "import json, os, re, shutil, subprocess, urllib.request" ,
392+ f"model_dirs = { model_dirs or []!r} " ,
381393 "models = []" ,
382394 "seen = set()" ,
383395 "BLOCKED_ROOTS = ('/sys', '/proc', '/dev', '/run', '/var/run')" ,
@@ -484,6 +496,12 @@ def _cached_model_scan_script(model_dirs: list[str] | None = None, add_hf_cache:
484496 " # Docker images mount ./data/huggingface at /app/.cache/huggingface." ,
485497 " # When HOME is /root, expanduser() misses that persisted cache." ,
486498 " add('/app/.cache/huggingface/hub')" ,
499+ " for p in model_dirs:" ,
500+ " try:" ,
501+ " ep = os.path.expanduser(p)" ,
502+ " if os.path.isdir(ep) and any(d.startswith('models--') for d in os.listdir(ep)):" ,
503+ " add(p)" ,
504+ " except Exception: pass" ,
487505 f" add({ add_hf_cache !r} )" if add_hf_cache else "" ,
488506 " return candidates" ,
489507 "def normalize_model_dir(p):" ,
@@ -563,12 +581,11 @@ def _cached_model_scan_script(model_dirs: list[str] | None = None, add_hf_cache:
563581 " models.append({'repo_id':name,'size_bytes':size_bytes,'nb_files':1,'has_incomplete':False,'path':'ollama','backend':'ollama','is_ollama':True})" ,
564582 " return" ,
565583 "for _hf_cache in hf_cache_paths(): scan_hf(_hf_cache)" ,
584+ "for _md in model_dirs: scan_dir(os.path.expanduser(_md))" ,
566585 "scan_ollama_api()" ,
567586 "scan_ollama()" ,
587+ "print(json.dumps(models))" ,
568588 ]
569- for model_dir in model_dirs or []:
570- lines .append (f"scan_dir({ model_dir !r} )" )
571- lines .append ("print(json.dumps(models))" )
572589 return "\n " .join (lines ) + "\n "
573590
574591
0 commit comments