Commit 208760f3 authored by AUTOMATIC1111's avatar AUTOMATIC1111 Committed by GitHub

Merge pull request #14192 from illtellyoulater/patch-1

Update launch_utils.py - fixes repetead package reinstalls
parents 334298d4 06725af4
...@@ -6,6 +6,7 @@ import os ...@@ -6,6 +6,7 @@ import os
import shutil import shutil
import sys import sys
import importlib.util import importlib.util
import importlib.metadata
import platform import platform
import json import json
from functools import lru_cache from functools import lru_cache
...@@ -118,6 +119,9 @@ def run(command, desc=None, errdesc=None, custom_env=None, live: bool = default_ ...@@ -118,6 +119,9 @@ def run(command, desc=None, errdesc=None, custom_env=None, live: bool = default_
def is_installed(package): def is_installed(package):
try:
dist = importlib.metadata.distribution(package)
except importlib.metadata.PackageNotFoundError:
try: try:
spec = importlib.util.find_spec(package) spec = importlib.util.find_spec(package)
except ModuleNotFoundError: except ModuleNotFoundError:
...@@ -125,6 +129,8 @@ def is_installed(package): ...@@ -125,6 +129,8 @@ def is_installed(package):
return spec is not None return spec is not None
return dist is not None
def repo_dir(name): def repo_dir(name):
return os.path.join(script_path, dir_repos, name) return os.path.join(script_path, dir_repos, name)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment