|
|
|
|
|
import os |
|
import glob |
|
|
|
def generate_requirements(): |
|
""" |
|
Generate a comprehensive requirements.txt file by combining: |
|
1. The main requirements.txt from the root directory |
|
2. All requirements.txt files found in custom_nodes subfolders |
|
3. Adding the 'black' package |
|
|
|
Returns: |
|
str: The combined requirements as a string |
|
""" |
|
requirements = set() |
|
|
|
|
|
current_dir = os.path.dirname(os.path.abspath(__file__)) |
|
comfy_root = os.path.dirname(os.path.dirname(current_dir)) |
|
|
|
|
|
main_req_path = os.path.join(comfy_root, "requirements.txt") |
|
if os.path.exists(main_req_path): |
|
with open(main_req_path, 'r') as f: |
|
for line in f: |
|
line = line.strip() |
|
if line and not line.startswith('#'): |
|
requirements.add(line) |
|
|
|
|
|
custom_nodes_dir = os.path.join(comfy_root, "custom_nodes") |
|
if os.path.exists(custom_nodes_dir): |
|
|
|
req_files = glob.glob(os.path.join(custom_nodes_dir, "**/requirements.txt"), recursive=True) |
|
|
|
for req_file in req_files: |
|
with open(req_file, 'r') as f: |
|
for line in f: |
|
line = line.strip() |
|
if line and not line.startswith('#'): |
|
requirements.add(line) |
|
|
|
|
|
requirements.add('black') |
|
|
|
|
|
sorted_requirements = sorted(list(requirements)) |
|
|
|
|
|
return '\n'.join(sorted_requirements) |
|
|
|
if __name__ == "__main__": |
|
|
|
print(generate_requirements()) |
|
|