@@ -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')" ,
@@ -469,6 +481,12 @@ def _cached_model_scan_script(model_dirs: list[str] | None = None, add_hf_cache:
469481 " # Docker images mount ./data/huggingface at /app/.cache/huggingface." ,
470482 " # When HOME is /root, expanduser() misses that persisted cache." ,
471483 " add('/app/.cache/huggingface/hub')" ,
484+ " for p in model_dirs:" ,
485+ " try:" ,
486+ " ep = os.path.expanduser(p)" ,
487+ " if os.path.isdir(ep) and any(d.startswith('models--') for d in os.listdir(ep)):" ,
488+ " add(p)" ,
489+ " except Exception: pass" ,
472490 f" add({ add_hf_cache !r} )" if add_hf_cache else "" ,
473491 " return candidates" ,
474492 "def scan_dir(p):" ,
@@ -537,12 +555,11 @@ def _cached_model_scan_script(model_dirs: list[str] | None = None, add_hf_cache:
537555 " models.append({'repo_id':name,'size_bytes':size_bytes,'nb_files':1,'has_incomplete':False,'path':'ollama','backend':'ollama','is_ollama':True})" ,
538556 " return" ,
539557 "for _hf_cache in hf_cache_paths(): scan_hf(_hf_cache)" ,
558+ "for _md in model_dirs: scan_dir(os.path.expanduser(_md))" ,
540559 "scan_ollama_api()" ,
541560 "scan_ollama()" ,
561+ "print(json.dumps(models))" ,
542562 ]
543- for model_dir in model_dirs or []:
544- lines .append (f"scan_dir(os.path.expanduser({ model_dir !r} ))" )
545- lines .append ("print(json.dumps(models))" )
546563 return "\n " .join (lines ) + "\n "
547564
548565
0 commit comments