update install (risky but cleaner). Add auto_det_size param and try to emulate old behavior
This commit is contained in:
+21
-14
@@ -1,8 +1,9 @@
|
||||
import launch
|
||||
import os
|
||||
import pkg_resources
|
||||
import sys
|
||||
import pkg_resources
|
||||
from modules import shared
|
||||
from packaging.version import parse
|
||||
|
||||
use_gpu = getattr(shared.cmd_opts, "faceswaplab_gpu", False)
|
||||
|
||||
@@ -15,29 +16,35 @@ else:
|
||||
os.path.dirname(os.path.realpath(__file__)), "requirements.txt"
|
||||
)
|
||||
|
||||
|
||||
def is_installed(package: str) -> bool:
|
||||
package_name = package.split("==")[0].split(">=")[0].strip()
|
||||
try:
|
||||
installed_version = parse(pkg_resources.get_distribution(package_name).version)
|
||||
except pkg_resources.DistributionNotFound:
|
||||
return False
|
||||
|
||||
if "==" in package:
|
||||
required_version = parse(package.split("==")[1])
|
||||
return installed_version == required_version
|
||||
elif ">=" in package:
|
||||
required_version = parse(package.split(">=")[1])
|
||||
return installed_version >= required_version
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
print("Checking faceswaplab requirements")
|
||||
with open(req_file) as file:
|
||||
for package in file:
|
||||
try:
|
||||
python = sys.executable
|
||||
package = package.strip()
|
||||
|
||||
if not launch.is_installed(package.split("==")[0]):
|
||||
if not is_installed(package):
|
||||
print(f"Install {package}")
|
||||
launch.run_pip(
|
||||
f"install {package}", f"sd-webui-faceswaplab requirement: {package}"
|
||||
)
|
||||
elif "==" in package:
|
||||
package_name, package_version = package.split("==")
|
||||
installed_version = pkg_resources.get_distribution(package_name).version
|
||||
if installed_version != package_version:
|
||||
print(
|
||||
f"Install {package}, {installed_version} vs {package_version}"
|
||||
)
|
||||
launch.run_pip(
|
||||
f"install {package}",
|
||||
f"sd-webui-faceswaplab requirement: changing {package_name} version from {installed_version} to {package_version}",
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
Reference in New Issue
Block a user