Improved stability when switching between Qwen3-VL GGUF models Fixed mmproj reuse issues in local vision models Refined internal GGUF model lifecycle management Documentation updates: - Clarified project scope as a prompt generator for QwenImageEdit and Wan2.2 - Reorganized Credits and Dependencies for clearer attribution - Updated llama-cpp-python installation notes to reference the JamePeng fork documentation Internal structure preparation for future backend refactoring No breaking changes to node interfaces
39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
"""import_utils.py
|
|
Small helpers to make local (same-folder) imports robust inside ComfyUI custom nodes.
|
|
|
|
This module is intentionally tiny and dependency-free.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import sys
|
|
from typing import Optional
|
|
|
|
|
|
def ensure_local_import(file_path: str, *, prepend: bool = True) -> str:
|
|
"""Ensure the directory containing *file_path* is present in sys.path.
|
|
|
|
ComfyUI sometimes loads custom nodes in a way that does not guarantee the node
|
|
folder is on sys.path. Several nodes in this repo import sibling modules
|
|
(e.g. vision_llm_node.py). This helper makes that import reliable.
|
|
|
|
Args:
|
|
file_path: Usually pass __file__ from the caller module.
|
|
prepend: If True, insert at sys.path[0]; else append.
|
|
|
|
Returns:
|
|
The normalized directory path that was inserted/ensured.
|
|
"""
|
|
node_dir = os.path.dirname(os.path.abspath(file_path))
|
|
# Normalize for stable comparisons across platforms
|
|
node_dir = os.path.normpath(node_dir)
|
|
|
|
if node_dir and node_dir not in sys.path:
|
|
if prepend:
|
|
sys.path.insert(0, node_dir)
|
|
else:
|
|
sys.path.append(node_dir)
|
|
|
|
return node_dir
|