65 lines
2.5 KiB
Python
65 lines
2.5 KiB
Python
"""ComfyUI V3 entry point for ``comfyui-timeline-animation``.
|
|
|
|
The wrapper subpackage is named ``timelineanim_nodes`` (not the more
|
|
common ``custom_node``) to avoid a sys.modules collision with any
|
|
other ComfyUI custom-nodes pack that uses the same generic name.
|
|
Whichever pack loaded second would otherwise silently inherit the
|
|
first one's extension via Python's import cache.
|
|
"""
|
|
|
|
import logging
|
|
import os
|
|
import sys
|
|
from importlib.util import find_spec
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
# Use os.path.dirname (not Path.resolve) so symlinked custom_nodes/
|
|
# layouts don't get eagerly dereferenced.
|
|
_SRC = os.path.join(os.path.dirname(__file__), "src")
|
|
if _SRC not in sys.path:
|
|
sys.path.insert(0, _SRC)
|
|
|
|
# ``comfy_timeline`` (the public Python helper third-party packs import)
|
|
# is a generic top-level module name — the same sys.modules collision
|
|
# class the ``timelineanim_nodes`` rename above dodges for the node
|
|
# subpackage. If another pack already claimed the name, imports of
|
|
# ``comfy_timeline`` silently bind to THAT implementation, not ours;
|
|
# warn loudly so a mismatched API surfaces in the log instead of as
|
|
# quiet misbehaviour. (Real fix — a namespaced ``comfyui-timeline-core``
|
|
# pip package — is tracked but not shipped.)
|
|
_foreign = sys.modules.get("comfy_timeline")
|
|
if _foreign is not None:
|
|
_expected_dir = os.path.normcase(os.path.join(_SRC, "comfy_timeline"))
|
|
_actual_dir = os.path.normcase(
|
|
os.path.dirname(getattr(_foreign, "__file__", "") or ""),
|
|
)
|
|
if _actual_dir != _expected_dir:
|
|
logger.warning(
|
|
"comfyui-timeline-animation: a different 'comfy_timeline' "
|
|
"module is already imported from %r (ours lives at %r). "
|
|
"Consumers importing comfy_timeline will bind to that "
|
|
"implementation — API mismatches are possible.",
|
|
_actual_dir or "<unknown>", _expected_dir,
|
|
)
|
|
|
|
# A stripped unit-test environment may lack comfy_api. Only that
|
|
# specific absence gets a sentinel; real registration errors surface.
|
|
if find_spec("comfy_api") is not None:
|
|
from timelineanim_nodes import comfy_entrypoint
|
|
else:
|
|
logger.warning(
|
|
"comfyui-timeline-animation: could not import comfy_entrypoint "
|
|
"because comfy_api is unavailable. Node registration requires "
|
|
"a ComfyUI runtime.",
|
|
)
|
|
comfy_entrypoint = None # type: ignore[assignment]
|
|
|
|
# ComfyUI resolves WEB_DIRECTORY relative to the __init__.py defining it.
|
|
WEB_DIRECTORY = "./src/timelineanim_nodes/web"
|
|
|
|
__all__ = [
|
|
"comfy_entrypoint",
|
|
"WEB_DIRECTORY",
|
|
]
|