PyInstaller

This commit is contained in:
doctorpangloss 2024-01-29 17:02:45 -08:00
parent 82edb2ff0e
commit 2400da51e5
8 changed files with 26 additions and 20 deletions

View File

@ -181,7 +181,7 @@ On macOS, install exactly Python 3.11 using `brew`, which you can download from
5. Then, run the following command to install `comfyui` into your current environment. This will correctly select the version of pytorch that matches the GPU on your machine (NVIDIA or CPU on Windows, NVIDIA AMD or CPU on Linux): 5. Then, run the following command to install `comfyui` into your current environment. This will correctly select the version of pytorch that matches the GPU on your machine (NVIDIA or CPU on Windows, NVIDIA AMD or CPU on Linux):
```shell ```shell
pip install -e .[test] pip install -e .[dev]
``` ```
6. To run the web server: 6. To run the web server:
```shell ```shell

View File

@ -1,4 +1,4 @@
import argparse import configargparse as argparse
import enum import enum
from . import options from . import options
@ -31,13 +31,14 @@ class EnumAction(argparse.Action):
setattr(namespace, self.dest, value) setattr(namespace, self.dest, value)
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser(default_config_files=['config.yaml', 'config.json'], auto_env_var_prefix='COMFYUI_')
parser.add_argument("--listen", type=str, default="127.0.0.1", metavar="IP", nargs="?", const="0.0.0.0", help="Specify the IP address to listen on (default: 127.0.0.1). If --listen is provided without an argument, it defaults to 0.0.0.0. (listens on all)") parser.add_argument('-c', '--config', required=False, default=None, is_config_file=True, help='Specify additional configuration files.')
parser.add_argument('-w', "--cwd", type=str, default=None, help="Specify the working directory. If not set, this is the current working directory. models/, input/, output/ and other directories will be located here by default.")
parser.add_argument('-H', "--listen", type=str, default="127.0.0.1", metavar="IP", nargs="?", const="0.0.0.0", help="Specify the IP address to listen on (default: 127.0.0.1). If --listen is provided without an argument, it defaults to 0.0.0.0. (listens on all)")
parser.add_argument("--port", type=int, default=8188, help="Set the listen port.") parser.add_argument("--port", type=int, default=8188, help="Set the listen port.")
parser.add_argument("--enable-cors-header", type=str, default=None, metavar="ORIGIN", nargs="?", const="*", help="Enable CORS (Cross-Origin Resource Sharing) with optional origin or allow all with default '*'.") parser.add_argument("--enable-cors-header", type=str, default=None, metavar="ORIGIN", nargs="?", const="*", help="Enable CORS (Cross-Origin Resource Sharing) with optional origin or allow all with default '*'.")
parser.add_argument("--max-upload-size", type=float, default=100, help="Set the maximum upload size in MB.") parser.add_argument("--max-upload-size", type=float, default=100, help="Set the maximum upload size in MB.")
parser.add_argument("--extra-model-paths-config", type=str, default=None, metavar="PATH", nargs='+', action='append', help="Load one or more extra_model_paths.yaml files.") parser.add_argument("--extra-model-paths-config", type=str, default=None, metavar="PATH", nargs='+', action='append', help="Load one or more extra_model_paths.yaml files.")
parser.add_argument("--output-directory", type=str, default=None, help="Set the ComfyUI output directory.") parser.add_argument("--output-directory", type=str, default=None, help="Set the ComfyUI output directory.")
parser.add_argument("--temp-directory", type=str, default=None, help="Set the ComfyUI temp directory (default is in the ComfyUI directory).") parser.add_argument("--temp-directory", type=str, default=None, help="Set the ComfyUI temp directory (default is in the ComfyUI directory).")

View File

@ -2,12 +2,21 @@ import os
import sys import sys
import time import time
from ..cli_args import args
supported_pt_extensions = set(['.ckpt', '.pt', '.bin', '.pth', '.safetensors']) supported_pt_extensions = set(['.ckpt', '.pt', '.bin', '.pth', '.safetensors'])
folder_names_and_paths = {} folder_names_and_paths = {}
if 'main.py' in sys.argv: if 'main.py' in sys.argv:
base_path = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../..")) base_path = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../.."))
elif args.cwd:
if not os.path.exists(args.cwd):
try:
os.makedirs(args.cwd)
except:
print("Failed to create custom working directory")
base_path = args.cwd
else: else:
base_path = os.getcwd() base_path = os.getcwd()
models_dir = os.path.join(base_path, "models") models_dir = os.path.join(base_path, "models")
@ -21,24 +30,18 @@ folder_names_and_paths["style_models"] = ([os.path.join(models_dir, "style_model
folder_names_and_paths["embeddings"] = ([os.path.join(models_dir, "embeddings")], supported_pt_extensions) folder_names_and_paths["embeddings"] = ([os.path.join(models_dir, "embeddings")], supported_pt_extensions)
folder_names_and_paths["diffusers"] = ([os.path.join(models_dir, "diffusers")], ["folder"]) folder_names_and_paths["diffusers"] = ([os.path.join(models_dir, "diffusers")], ["folder"])
folder_names_and_paths["vae_approx"] = ([os.path.join(models_dir, "vae_approx")], supported_pt_extensions) folder_names_and_paths["vae_approx"] = ([os.path.join(models_dir, "vae_approx")], supported_pt_extensions)
folder_names_and_paths["controlnet"] = ([os.path.join(models_dir, "controlnet"), os.path.join(models_dir, "t2i_adapter")], supported_pt_extensions) folder_names_and_paths["controlnet"] = ([os.path.join(models_dir, "controlnet"), os.path.join(models_dir, "t2i_adapter")], supported_pt_extensions)
folder_names_and_paths["gligen"] = ([os.path.join(models_dir, "gligen")], supported_pt_extensions) folder_names_and_paths["gligen"] = ([os.path.join(models_dir, "gligen")], supported_pt_extensions)
folder_names_and_paths["upscale_models"] = ([os.path.join(models_dir, "upscale_models")], supported_pt_extensions) folder_names_and_paths["upscale_models"] = ([os.path.join(models_dir, "upscale_models")], supported_pt_extensions)
folder_names_and_paths["custom_nodes"] = ([os.path.join(base_path, "custom_nodes")], []) folder_names_and_paths["custom_nodes"] = ([os.path.join(base_path, "custom_nodes")], [])
folder_names_and_paths["hypernetworks"] = ([os.path.join(models_dir, "hypernetworks")], supported_pt_extensions) folder_names_and_paths["hypernetworks"] = ([os.path.join(models_dir, "hypernetworks")], supported_pt_extensions)
folder_names_and_paths["photomaker"] = ([os.path.join(models_dir, "photomaker")], supported_pt_extensions) folder_names_and_paths["photomaker"] = ([os.path.join(models_dir, "photomaker")], supported_pt_extensions)
folder_names_and_paths["classifiers"] = ([os.path.join(models_dir, "classifiers")], {""}) folder_names_and_paths["classifiers"] = ([os.path.join(models_dir, "classifiers")], {""})
output_directory = os.path.join(base_path, "output") output_directory = os.path.join(base_path, "output")
temp_directory = os.path.join(base_path, "temp") temp_directory = os.path.join(base_path, "temp")
input_directory = os.path.join(base_path, "input") input_directory = os.path.join(base_path, "input")
user_directory = os.path.join(os.path.dirname(os.path.realpath(__file__)), "user") user_directory = os.path.join(base_path, "user")
filename_list_cache = {} filename_list_cache = {}
@ -250,7 +253,7 @@ def get_save_image_path(filename_prefix, output_dir, image_width=0, image_height
err = "**** ERROR: Saving image outside the output folder is not allowed." + \ err = "**** ERROR: Saving image outside the output folder is not allowed." + \
"\n full_output_folder: " + os.path.abspath(full_output_folder) + \ "\n full_output_folder: " + os.path.abspath(full_output_folder) + \
"\n output_dir: " + output_dir + \ "\n output_dir: " + output_dir + \
"\n commonpath: " + os.path.commonpath((output_dir, os.path.abspath(full_output_folder))) "\n commonpath: " + os.path.commonpath((output_dir, os.path.abspath(full_output_folder)))
print(err) print(err)
raise Exception(err) raise Exception(err)

3
requirements-dev.txt Normal file
View File

@ -0,0 +1,3 @@
pytest
websocket-client==1.6.1
PyInstaller

View File

@ -1,2 +0,0 @@
pytest
websocket-client==1.6.1

View File

@ -28,4 +28,5 @@ scipy
tqdm tqdm
protobuf==3.20.3 protobuf==3.20.3
psutil psutil
mypy>=1.6.0 mypy>=1.6.0
ConfigArgParse

View File

@ -151,7 +151,7 @@ def dependencies() -> List[str]:
package_data = ['sd1_tokenizer/*', '**/*.json', '**/*.yaml'] package_data = ['sd1_tokenizer/*', '**/*.json', '**/*.yaml']
if not is_editable: if not is_editable:
package_data.append('comfy/web/**/*') package_data.append('comfy/web/**/*')
test_dependencies = open(os.path.join(os.path.dirname(__file__), "requirements-tests.txt")).readlines() dev_dependencies = open(os.path.join(os.path.dirname(__file__), "requirements-dev.txt")).readlines()
setup( setup(
name=package_name, name=package_name,
description="", description="",
@ -173,8 +173,8 @@ setup(
package_data={ package_data={
'comfy': package_data 'comfy': package_data
}, },
tests_require=test_dependencies, tests_require=dev_dependencies,
extras_require={ extras_require={
'test': test_dependencies 'dev': dev_dependencies
}, },
) )

View File

@ -4,7 +4,7 @@
Additional requirements for running tests: Additional requirements for running tests:
``` ```
pip install .[test] pip install .[dev]
``` ```
Run inference tests: Run inference tests:
``` ```