diff options
author | illtellyoulater <3078931+illtellyoulater@users.noreply.github.com> | 2023-12-04 02:35:35 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-04 02:35:35 +0000 |
commit | 639ccf254bd4d072f33333abb1ada3d08aaab470 (patch) | |
tree | 0f7b8f2382eda790ba652fb1aa8f21894c32bb50 /modules/launch_utils.py | |
parent | 4afaaf8a020c1df457bcf7250cb1c7f609699fa7 (diff) | |
download | stable-diffusion-webui-gfx803-639ccf254bd4d072f33333abb1ada3d08aaab470.tar.gz stable-diffusion-webui-gfx803-639ccf254bd4d072f33333abb1ada3d08aaab470.tar.bz2 stable-diffusion-webui-gfx803-639ccf254bd4d072f33333abb1ada3d08aaab470.zip |
Update launch_utils.py to fix wrong dep. checks and reinstalls
Fixes failing dependency checks for extensions having a different package name and import name (for example ffmpeg-python / ffmpeg), which currently is causing the unneeded reinstall of packages at runtime.
In fact with current code, the same string is used when installing a package and when checking for its presence, as you can see in the following example:
> launch_utils.run_pip("install ffmpeg-python", "required package")
[ Installing required package: "ffmpeg-python" ... ]
[ Installed ]
> launch_utils.is_installed("ffmpeg-python")
False
... which would actually return true with:
> launch_utils.is_installed("ffmpeg")
True
Diffstat (limited to 'modules/launch_utils.py')
-rw-r--r-- | modules/launch_utils.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/modules/launch_utils.py b/modules/launch_utils.py index 6e54d063..6664c5e0 100644 --- a/modules/launch_utils.py +++ b/modules/launch_utils.py @@ -6,6 +6,7 @@ import os import shutil
import sys
import importlib.util
+import importlib.metadata
import platform
import json
from functools import lru_cache
@@ -119,11 +120,16 @@ def run(command, desc=None, errdesc=None, custom_env=None, live: bool = default_ def is_installed(package):
try:
- spec = importlib.util.find_spec(package)
- except ModuleNotFoundError:
- return False
+ dist = importlib.metadata.distribution(package)
+ except importlib.metadata.PackageNotFoundError:
+ try:
+ spec = importlib.util.find_spec(package)
+ except ModuleNotFoundError:
+ return False
- return spec is not None
+ return spec is not None
+
+ return dist is not None
def repo_dir(name):
|