Files
sd-webui-prompt-all-in-one/install.py
Physton fa091e3dc1 Created
Former-commit-id: e255ced1c91ef6a7722dce7268872be9ee326168
2023-05-08 20:35:02 +08:00

20 lines
956 B
Python

import launch
import os
import pkg_resources
req_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), "requirements.txt")
with open(req_file) as file:
for package in file:
try:
package = package.strip()
if '==' in package:
package_name, package_version = package.split('==')
installed_version = pkg_resources.get_distribution(package_name).version
if installed_version != package_version:
launch.run_pip(f"install {package}", f"sd-webui-prompt-all-in-one requirement: changing {package_name} version from {installed_version} to {package_version}")
elif not launch.is_installed(package):
launch.run_pip(f"install {package}", f"sd-webui-prompt-all-in-one: {package}")
except Exception as e:
print(e)
print(f'Warning: Failed to install {package}, some preprocessors may not work.')