Find imports in executables
This commit is contained in:
parent
7317084a4e
commit
295888c654
@ -81,6 +81,7 @@ else:
|
||||
calibre_web_version = (constants.STABLE_VERSION['version'] + ' - '
|
||||
+ constants.NIGHTLY_VERSION[0].replace('%', '%%') + ' - '
|
||||
+ constants.NIGHTLY_VERSION[1].replace('%', '%%'))
|
||||
|
||||
if getattr(sys, 'frozen', False):
|
||||
calibre_web_version += " - Exe-Version"
|
||||
elif constants.HOME_CONFIG:
|
||||
|
@ -1,5 +1,7 @@
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import json
|
||||
|
||||
from .constants import BASE_DIR
|
||||
try:
|
||||
@ -8,7 +10,7 @@ try:
|
||||
ImportNotFound = BaseException
|
||||
except ImportError:
|
||||
importlib = False
|
||||
|
||||
version = None
|
||||
|
||||
if not importlib:
|
||||
try:
|
||||
@ -20,6 +22,9 @@ 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())
|
||||
if importlib or pkgresources:
|
||||
if optional:
|
||||
req_path = os.path.join(BASE_DIR, "optional-requirements.txt")
|
||||
@ -31,10 +36,13 @@ def load_dependencys(optional=False):
|
||||
if not line.startswith('#') and not line == '\n' and not line.startswith('git'):
|
||||
res = re.match(r'(.*?)([<=>\s]+)([\d\.]+),?\s?([<=>\s]+)?([\d\.]+)?', line.strip())
|
||||
try:
|
||||
if importlib:
|
||||
dep_version = version(res.group(1))
|
||||
if getattr(sys, 'frozen', False):
|
||||
dep_version = exe_deps[res.group(1).lower()]
|
||||
else:
|
||||
dep_version = pkg_resources.get_distribution(res.group(1)).version
|
||||
if importlib:
|
||||
dep_version = version(res.group(1))
|
||||
else:
|
||||
dep_version = pkg_resources.get_distribution(res.group(1)).version
|
||||
except ImportNotFound:
|
||||
if optional:
|
||||
continue
|
||||
|
Loading…
Reference in New Issue
Block a user