YFanwang commited on
Commit
692db7e
·
verified ·
1 Parent(s): 913cd27

Upload VideoX-Fun/install.py

Browse files
Files changed (1) hide show
  1. VideoX-Fun/install.py +45 -0
VideoX-Fun/install.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ import subprocess
3
+ import locale
4
+ import threading
5
+ import os
6
+
7
+ def handle_stream(stream, prefix):
8
+ stream.reconfigure(encoding=locale.getpreferredencoding(), errors='replace')
9
+ for msg in stream:
10
+ if prefix == '[!]' and ('it/s]' in msg or 's/it]' in msg) and ('%|' in msg or 'it [' in msg):
11
+ if msg.startswith('100%'):
12
+ print('\r' + msg, end="", file=sys.stderr),
13
+ else:
14
+ print('\r' + msg[:-1], end="", file=sys.stderr),
15
+ else:
16
+ if prefix == '[!]':
17
+ print(prefix, msg, end="", file=sys.stderr)
18
+ else:
19
+ print(prefix, msg, end="")
20
+
21
+ def process_wrap(cmd_str, cwd_path, handler=None):
22
+ process = subprocess.Popen(cmd_str, cwd=cwd_path, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, bufsize=1)
23
+
24
+ if handler is None:
25
+ handler = handle_stream
26
+
27
+ stdout_thread = threading.Thread(target=handler, args=(process.stdout, ""))
28
+ stderr_thread = threading.Thread(target=handler, args=(process.stderr, "[!]"))
29
+
30
+ stdout_thread.start()
31
+ stderr_thread.start()
32
+
33
+ stdout_thread.join()
34
+ stderr_thread.join()
35
+
36
+ return process.wait()
37
+
38
+ assert process_wrap([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"], cwd_path=os.path.dirname(os.path.realpath(__file__))) == 0, "ERROR: Failed to install requirements.txt. Please install them manually, and restart ComfyUI."
39
+
40
+ nodep_packages = [
41
+ "kornia>=0.6.9",
42
+ "xformers>=0.0.20",
43
+ ]
44
+
45
+ assert process_wrap([sys.executable, "-m", "pip", "install", "--no-deps", *nodep_packages], cwd_path=os.path.dirname(os.path.realpath(__file__))) == 0, "ERROR: Failed to install last set of packages. Please install them manually, and restart ComfyUI."