-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsitecustomize.py
More file actions
27 lines (24 loc) · 1.06 KB
/
sitecustomize.py
File metadata and controls
27 lines (24 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import sys
import types
from pathlib import Path
import os
import importlib.util
# During unit tests we provide lightweight stubs for ComfyUI and the main package
if os.environ.get('UNIT_TEST'):
# Stub comfy package
import tests.mock_comfy as mock_comfy
sys.modules.setdefault('comfy', mock_comfy)
repo_root = Path(__file__).resolve().parent
pkg = types.ModuleType('EternalKernelLiteGraphNodes')
pkg.__path__ = [str(repo_root)]
sys.modules.setdefault('EternalKernelLiteGraphNodes', pkg)
custom_nodes = types.ModuleType('custom_nodes')
custom_nodes.EternalKernelLiteGraphNodes = pkg
sys.modules.setdefault('custom_nodes', custom_nodes)
sys.modules.setdefault('custom_nodes.EternalKernelLiteGraphNodes', pkg)
# Provide a very small torchvision stub if torchvision is missing
if importlib.util.find_spec('torchvision') is None:
tv_stub = types.ModuleType('torchvision')
tv_stub.datasets = types.ModuleType('datasets')
tv_stub.models = types.ModuleType('models')
sys.modules['torchvision'] = tv_stub