"git@developer.sourcefind.cn:Wenxuan/LightX2V.git" did not exist on "d8558a0cf5f614b6af535bbc42261266e40501a4"
Unverified Commit 0e3dfd9e authored by Chenlei Hu's avatar Chenlei Hu Committed by GitHub
Browse files

Use relative path for custom/extra node module name (#3944)

* Fix module name for comfy extra nodes

* Use module name relative to root dir
parent 739b7663
...@@ -1887,11 +1887,33 @@ NODE_DISPLAY_NAME_MAPPINGS = { ...@@ -1887,11 +1887,33 @@ NODE_DISPLAY_NAME_MAPPINGS = {
EXTENSION_WEB_DIRS = {} EXTENSION_WEB_DIRS = {}
def load_custom_node(module_path, ignore=set()):
module_name = os.path.basename(module_path) def get_module_name(module_path: str) -> str:
"""
Returns the module name based on the given module path.
Examples:
get_module_name("C:/Users/username/ComfyUI/custom_nodes/my_custom_node.py") -> "custom_nodes.my_custom_node"
get_module_name("C:/Users/username/ComfyUI/custom_nodes/my_custom_node") -> "custom_nodes.my_custom_node"
get_module_name("C:/Users/username/ComfyUI/custom_nodes/my_custom_node/") -> "custom_nodes.my_custom_node"
get_module_name("C:/Users/username/ComfyUI/custom_nodes/my_custom_node/__init__.py") -> "custom_nodes.my_custom_node"
get_module_name("C:/Users/username/ComfyUI/custom_nodes/my_custom_node/__init__") -> "custom_nodes.my_custom_node"
get_module_name("C:/Users/username/ComfyUI/custom_nodes/my_custom_node/__init__/") -> "custom_nodes.my_custom_node"
get_module_name("C:/Users/username/ComfyUI/custom_nodes/my_custom_node.disabled") -> "custom_nodes.my
Args:
module_path (str): The path of the module.
Returns:
str: The module name.
"""
relative_path = os.path.relpath(module_path, folder_paths.base_path)
if os.path.isfile(module_path): if os.path.isfile(module_path):
sp = os.path.splitext(module_path) relative_path = os.path.splitext(relative_path)[0]
module_name = sp[0] return relative_path.replace(os.sep, '.')
def load_custom_node(module_path, ignore=set()):
module_name = get_module_name(module_path)
try: try:
logging.debug("Trying to load custom node {}".format(module_path)) logging.debug("Trying to load custom node {}".format(module_path))
if os.path.isfile(module_path): if os.path.isfile(module_path):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment