Files
sd-webui-prompt-all-in-one/scripts/packages.py
Physton 97eb4e5687 Checking installation status of Python packages, optimizing translation interface text
Former-commit-id: 6fbe746b8675c175220ddd80335d9127ab42883f
2023-05-29 01:58:04 +08:00

30 lines
897 B
Python

from install import packages
import launch
def get_packages_state():
states = []
for package_name in packages:
package = packages[package_name]
item = {
'name': package_name,
'package': package,
'state': False
}
if launch.is_installed(package_name):
item['state'] = True
states.append(item)
return states
def install_package(name, package):
result = {'state': False, 'message': ''}
try:
launch.run_pip(f"install {package}", f"sd-webui-prompt-all-in-one: {name}")
result['state'] = True
result['message'] = f'install {package} success!'
except Exception as e:
print(e)
print(f'Warning: Failed to install {package}, some preprocessors may not work.')
result['message'] = f'Error: install {package} failed!\n' + str(e)
return result