Skip to content

Commit ad1b4a9

Browse files
committed
1 parent e0e3ec0 commit ad1b4a9

File tree

5 files changed

+80
-62
lines changed

5 files changed

+80
-62
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,29 @@ The following settings are applied based on the section marked as `is_default`.
313313
* This option can be used if performance issues occur in a Colab+GDrive environment.
314314
315315
316+
## Environment Variables
317+
318+
The following features can be configured using environment variables:
319+
320+
* **COMFYUI_PATH**: The installation path of ComfyUI
321+
* **GITHUB_ENDPOINT**: Reverse proxy configuration for environments with limited access to GitHub
322+
* **HF_ENDPOINT**: Reverse proxy configuration for environments with limited access to Hugging Face
323+
324+
325+
### Example 1:
326+
Redirecting `https://github.com/ltdrdata/ComfyUI-Impact-Pack` to `https://mirror.ghproxy.com/https://github.com/ltdrdata/ComfyUI-Impact-Pack`
327+
328+
```
329+
GITHUB_ENDPOINT=https://mirror.ghproxy.com/https://github.com
330+
```
331+
332+
#### Example 2:
333+
Changing `https://huggingface.co/path/to/somewhere` to `https://some-hf-mirror.com/path/to/somewhere`
334+
335+
```
336+
HF_ENDPOINT=https://some-hf-mirror.com
337+
```
338+
316339
## Scanner
317340
When you run the `scan.sh` script:
318341

glob/git_utils.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
import configparser
33

44

5+
GITHUB_ENDPOINT = os.getenv('GITHUB_ENDPOINT')
6+
7+
58
def is_git_repo(path: str) -> bool:
69
""" Check if the path is a git repository. """
710
# NOTE: Checking it through `git.Repo` must be avoided.
@@ -46,16 +49,21 @@ def git_url(fullpath):
4649

4750
return None
4851

52+
4953
def normalize_url(url) -> str:
50-
url = url.replace("[email protected]:", "https://github.com/")
51-
if url.endswith('.git'):
52-
url = url[:-4]
54+
if 'github' in url or (GITHUB_ENDPOINT is not None and GITHUB_ENDPOINT in url):
55+
author = os.path.basename(os.path.dirname(url))
56+
repo_name = os.path.basename(url)
57+
url = f"https://github.com/{author}/{repo_name}"
5358

5459
return url
5560

56-
def normalize_url_http(url) -> str:
57-
url = url.replace("https://github.com/", "[email protected]:")
58-
if url.endswith('.git'):
59-
url = url[:-4]
6061

61-
return url
62+
def get_url_for_clone(url):
63+
url = normalize_url(url)
64+
65+
if GITHUB_ENDPOINT is not None and url.startswith('https://github.com/'):
66+
url = GITHUB_ENDPOINT + url[18:] # url[18:] -> remove `https://github.com`
67+
68+
return url
69+

glob/manager_core.py

Lines changed: 39 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
from node_package import InstalledNodePackage
4343

4444

45-
version_code = [3, 23]
45+
version_code = [3, 24]
4646
version_str = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '')
4747

4848

@@ -505,6 +505,8 @@ def resolve_node_spec(self, node_name, guess_mode=None):
505505
def resolve_from_path(self, fullpath):
506506
url = git_utils.git_url(fullpath)
507507
if url:
508+
url = git_utils.normalize_url(url)
509+
508510
cnr = self.get_cnr_by_repo(url)
509511
commit_hash = git_utils.get_commit_hash(fullpath)
510512
if cnr:
@@ -1239,15 +1241,16 @@ def repo_install(self, url, repo_path, instant_execution=False, no_deps=False, r
12391241
if url.endswith("/"):
12401242
url = url[:-1]
12411243
try:
1242-
print(f"Download: git clone '{url}'")
1243-
12441244
# Clone the repository from the remote URL
1245+
clone_url = git_utils.get_url_for_clone(url)
1246+
print(f"Download: git clone '{clone_url}'")
1247+
12451248
if not instant_execution and platform.system() == 'Windows':
1246-
res = manager_funcs.run_script([sys.executable, git_script_path, "--clone", get_default_custom_nodes_path(), url, repo_path], cwd=get_default_custom_nodes_path())
1249+
res = manager_funcs.run_script([sys.executable, git_script_path, "--clone", get_default_custom_nodes_path(), clone_url, repo_path], cwd=get_default_custom_nodes_path())
12471250
if res != 0:
1248-
return result.fail(f"Failed to clone repo: {url}")
1251+
return result.fail(f"Failed to clone repo: {clone_url}")
12491252
else:
1250-
repo = git.Repo.clone_from(url, repo_path, recursive=True, progress=GitProgress())
1253+
repo = git.Repo.clone_from(clone_url, repo_path, recursive=True, progress=GitProgress())
12511254
repo.git.clear_cache()
12521255
repo.close()
12531256

@@ -2043,12 +2046,14 @@ async def gitclone_install(url, instant_execution=False, msg_prefix='', no_deps=
20432046
print(f"CLONE into '{repo_path}'")
20442047

20452048
# Clone the repository from the remote URL
2049+
clone_url = git_utils.get_url_for_clone(url)
2050+
20462051
if not instant_execution and platform.system() == 'Windows':
2047-
res = manager_funcs.run_script([sys.executable, git_script_path, "--clone", get_default_custom_nodes_path(), url, repo_path], cwd=get_default_custom_nodes_path())
2052+
res = manager_funcs.run_script([sys.executable, git_script_path, "--clone", get_default_custom_nodes_path(), clone_url, repo_path], cwd=get_default_custom_nodes_path())
20482053
if res != 0:
2049-
return result.fail(f"Failed to clone '{url}' into '{repo_path}'")
2054+
return result.fail(f"Failed to clone '{clone_url}' into '{repo_path}'")
20502055
else:
2051-
repo = git.Repo.clone_from(url, repo_path, recursive=True, progress=GitProgress())
2056+
repo = git.Repo.clone_from(clone_url, repo_path, recursive=True, progress=GitProgress())
20522057
repo.git.clear_cache()
20532058
repo.close()
20542059

@@ -2973,7 +2978,14 @@ async def restore_snapshot(snapshot_path, git_helper_extras=None):
29732978
print("cm-cli: unexpected [0001]")
29742979

29752980
# for nightly restore
2976-
git_info = info.get('git_custom_nodes')
2981+
_git_info = info.get('git_custom_nodes')
2982+
git_info = {}
2983+
2984+
# normalize github repo
2985+
for k, v in _git_info.items():
2986+
norm_k = git_utils.normalize_url(k)
2987+
git_info[norm_k] = v
2988+
29772989
if git_info is not None:
29782990
todo_disable = []
29792991
todo_enable = []
@@ -2986,39 +2998,26 @@ async def restore_snapshot(snapshot_path, git_helper_extras=None):
29862998

29872999
if v[0] == 'nightly' and cnr_repo_map.get(k):
29883000
repo_url = cnr_repo_map.get(k)
3001+
normalized_url = git_utils.normalize_url(repo_url)
29893002

2990-
normalized_url1 = git_utils.normalize_url(repo_url)
2991-
normalized_url2 = git_utils.normalize_url_http(repo_url)
2992-
2993-
if normalized_url1 not in git_info and normalized_url2 not in git_info:
3003+
if normalized_url not in git_info:
29943004
todo_disable.append(k)
29953005
else:
2996-
if normalized_url1 in git_info:
2997-
commit_hash = git_info[normalized_url1]['hash']
2998-
todo_checkout.append((v[1], commit_hash))
2999-
3000-
if normalized_url2 in git_info:
3001-
commit_hash = git_info[normalized_url2]['hash']
3002-
todo_checkout.append((v[1], commit_hash))
3006+
commit_hash = git_info[normalized_url]['hash']
3007+
todo_checkout.append((v[1], commit_hash))
30033008

30043009
for k, v in unified_manager.nightly_inactive_nodes.items():
30053010
if 'comfyui-manager' in k:
30063011
continue
30073012

30083013
if cnr_repo_map.get(k):
30093014
repo_url = cnr_repo_map.get(k)
3010-
normalized_url1 = git_utils.normalize_url(repo_url)
3011-
normalized_url2 = git_utils.normalize_url_http(repo_url)
3012-
3013-
if normalized_url1 in git_info:
3014-
commit_hash = git_info[normalized_url1]['hash']
3015-
todo_enable.append((k, commit_hash))
3016-
processed_urls.append(normalized_url1)
3015+
normalized_url = git_utils.normalize_url(repo_url)
30173016

3018-
if normalized_url2 in git_info:
3019-
commit_hash = git_info[normalized_url2]['hash']
3017+
if normalized_url in git_info:
3018+
commit_hash = git_info[normalized_url]['hash']
30203019
todo_enable.append((k, commit_hash))
3021-
processed_urls.append(normalized_url2)
3020+
processed_urls.append(normalized_url)
30223021

30233022
for x in todo_disable:
30243023
unified_manager.unified_disable(x, False)
@@ -3071,40 +3070,27 @@ async def restore_snapshot(snapshot_path, git_helper_extras=None):
30713070
if repo_url is None:
30723071
continue
30733072

3074-
normalized_url1 = git_utils.normalize_url(repo_url)
3075-
normalized_url2 = git_utils.normalize_url_http(repo_url)
3073+
normalized_url = git_utils.normalize_url(repo_url)
30763074

3077-
if normalized_url1 not in git_info and normalized_url2 not in git_info:
3075+
if normalized_url not in git_info:
30783076
todo_disable.append(k2)
30793077
else:
3080-
if normalized_url1 in git_info:
3081-
commit_hash = git_info[normalized_url1]['hash']
3082-
todo_checkout.append((k2, commit_hash))
3083-
processed_urls.append(normalized_url1)
3084-
3085-
if normalized_url2 in git_info:
3086-
commit_hash = git_info[normalized_url2]['hash']
3087-
todo_checkout.append((k2, commit_hash))
3088-
processed_urls.append(normalized_url2)
3078+
commit_hash = git_info[normalized_url]['hash']
3079+
todo_checkout.append((k2, commit_hash))
3080+
processed_urls.append(normalized_url)
30893081

30903082
for k2, v2 in unified_manager.unknown_inactive_nodes.items():
30913083
repo_url = resolve_giturl_from_path(v2[1])
30923084

30933085
if repo_url is None:
30943086
continue
30953087

3096-
normalized_url1 = git_utils.normalize_url(repo_url)
3097-
normalized_url2 = git_utils.normalize_url_http(repo_url)
3098-
3099-
if normalized_url1 in git_info:
3100-
commit_hash = git_info[normalized_url1]['hash']
3101-
todo_enable.append((k2, commit_hash))
3102-
processed_urls.append(normalized_url1)
3088+
normalized_url = git_utils.normalize_url(repo_url)
31033089

3104-
if normalized_url2 in git_info:
3105-
commit_hash = git_info[normalized_url2]['hash']
3090+
if normalized_url in git_info:
3091+
commit_hash = git_info[normalized_url]['hash']
31063092
todo_enable.append((k2, commit_hash))
3107-
processed_urls.append(normalized_url2)
3093+
processed_urls.append(normalized_url)
31083094

31093095
for x in todo_disable:
31103096
unified_manager.unified_disable(x, True)

glob/manager_downloader.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
aria2 = os.getenv('COMFYUI_MANAGER_ARIA2_SERVER')
1212
HF_ENDPOINT = os.getenv('HF_ENDPOINT')
1313

14+
1415
if aria2 is not None:
1516
secret = os.getenv('COMFYUI_MANAGER_ARIA2_SECRET')
1617
url = urlparse(aria2)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "comfyui-manager"
33
description = "ComfyUI-Manager provides features to install and manage custom nodes for ComfyUI, as well as various functionalities to assist with ComfyUI."
4-
version = "3.23"
4+
version = "3.24"
55
license = { file = "LICENSE.txt" }
66
dependencies = ["GitPython", "PyGithub", "matrix-client==0.4.0", "transformers", "huggingface-hub>0.20", "typer", "rich", "typing-extensions"]
77

0 commit comments

Comments
 (0)