Improved dependency check for executables
This commit is contained in:
@@ -23,8 +23,12 @@ if not importlib:
|
||||
def load_dependencys(optional=False):
|
||||
deps = list()
|
||||
if getattr(sys, 'frozen', False):
|
||||
with open(os.path.join(BASE_DIR, ".pip_installed")) as f:
|
||||
exe_deps = json.loads(f.readlines())
|
||||
pip_installed = os.path.join(BASE_DIR, ".pip_installed")
|
||||
if os.path.exists(pip_installed):
|
||||
with open(pip_installed) as f:
|
||||
exe_deps = json.loads("".join(f.readlines()))
|
||||
else:
|
||||
return deps
|
||||
if importlib or pkgresources:
|
||||
if optional:
|
||||
req_path = os.path.join(BASE_DIR, "optional-requirements.txt")
|
||||
@@ -37,13 +41,13 @@ def load_dependencys(optional=False):
|
||||
res = re.match(r'(.*?)([<=>\s]+)([\d\.]+),?\s?([<=>\s]+)?([\d\.]+)?', line.strip())
|
||||
try:
|
||||
if getattr(sys, 'frozen', False):
|
||||
dep_version = exe_deps[res.group(1).lower()]
|
||||
dep_version = exe_deps[res.group(1).lower().replace('_','-')]
|
||||
else:
|
||||
if importlib:
|
||||
dep_version = version(res.group(1))
|
||||
else:
|
||||
dep_version = pkg_resources.get_distribution(res.group(1)).version
|
||||
except ImportNotFound:
|
||||
except (ImportNotFound, KeyError):
|
||||
if optional:
|
||||
continue
|
||||
dep_version = "not installed"
|
||||
|
||||
Reference in New Issue
Block a user