Improved dependency check for executables
This commit is contained in:
commit
5f70406b30
73
cps/about.py
73
cps/about.py
|
@ -25,47 +25,15 @@ import platform
|
||||||
import sqlite3
|
import sqlite3
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
import babel
|
|
||||||
import pytz
|
|
||||||
import requests
|
|
||||||
import sqlalchemy
|
|
||||||
import werkzeug
|
import werkzeug
|
||||||
import flask
|
import flask
|
||||||
import flask_login
|
import flask_login
|
||||||
import flask_principal
|
|
||||||
import jinja2
|
import jinja2
|
||||||
from flask_babel import gettext as _
|
from flask_babel import gettext as _
|
||||||
try:
|
|
||||||
from flask_wtf import __version__ as flaskwtf_version
|
|
||||||
except ImportError:
|
|
||||||
flaskwtf_version = _(u'not installed')
|
|
||||||
|
|
||||||
from . import db, calibre_db, converter, uploader, server, isoLanguages, constants, gdriveutils, dep_check
|
from . import db, calibre_db, converter, uploader, constants, dep_check
|
||||||
from .render_template import render_title_template
|
from .render_template import render_title_template
|
||||||
|
|
||||||
try:
|
|
||||||
from flask_login import __version__ as flask_loginVersion
|
|
||||||
except ImportError:
|
|
||||||
from flask_login.__about__ import __version__ as flask_loginVersion
|
|
||||||
try:
|
|
||||||
# pylint: disable=unused-import
|
|
||||||
import unidecode
|
|
||||||
# _() necessary to make babel aware of string for translation
|
|
||||||
unidecode_version = _(u'installed')
|
|
||||||
except ImportError:
|
|
||||||
unidecode_version = _(u'not installed')
|
|
||||||
|
|
||||||
try:
|
|
||||||
from flask_dance import __version__ as flask_danceVersion
|
|
||||||
except ImportError:
|
|
||||||
flask_danceVersion = None
|
|
||||||
|
|
||||||
try:
|
|
||||||
from greenlet import __version__ as greenlet_Version
|
|
||||||
except ImportError:
|
|
||||||
greenlet_Version = None
|
|
||||||
|
|
||||||
from . import services
|
|
||||||
|
|
||||||
about = flask.Blueprint('about', __name__)
|
about = flask.Blueprint('about', __name__)
|
||||||
|
|
||||||
|
@ -81,42 +49,13 @@ else:
|
||||||
calibre_web_version = (constants.STABLE_VERSION['version'] + ' - '
|
calibre_web_version = (constants.STABLE_VERSION['version'] + ' - '
|
||||||
+ constants.NIGHTLY_VERSION[0].replace('%', '%%') + ' - '
|
+ constants.NIGHTLY_VERSION[0].replace('%', '%%') + ' - '
|
||||||
+ constants.NIGHTLY_VERSION[1].replace('%', '%%'))
|
+ constants.NIGHTLY_VERSION[1].replace('%', '%%'))
|
||||||
|
|
||||||
if getattr(sys, 'frozen', False):
|
if getattr(sys, 'frozen', False):
|
||||||
calibre_web_version += " - Exe-Version"
|
calibre_web_version += " - Exe-Version"
|
||||||
elif constants.HOME_CONFIG:
|
elif constants.HOME_CONFIG:
|
||||||
calibre_web_version += " - pyPi"
|
calibre_web_version += " - pyPi"
|
||||||
|
|
||||||
if not ret:
|
_VERSIONS = OrderedDict(
|
||||||
_VERSIONS = OrderedDict(
|
|
||||||
Platform='{0[0]} {0[2]} {0[3]} {0[4]} {0[5]}'.format(platform.uname()),
|
|
||||||
Python=sys.version,
|
|
||||||
Calibre_Web=calibre_web_version,
|
|
||||||
WebServer=server.VERSION,
|
|
||||||
Flask=flask.__version__,
|
|
||||||
Flask_Login=flask_loginVersion,
|
|
||||||
Flask_Principal=flask_principal.__version__,
|
|
||||||
Flask_WTF=flaskwtf_version,
|
|
||||||
Werkzeug=werkzeug.__version__,
|
|
||||||
Babel=babel.__version__,
|
|
||||||
Jinja2=jinja2.__version__,
|
|
||||||
Requests=requests.__version__,
|
|
||||||
SqlAlchemy=sqlalchemy.__version__,
|
|
||||||
pySqlite=sqlite3.version,
|
|
||||||
SQLite=sqlite3.sqlite_version,
|
|
||||||
iso639=isoLanguages.__version__,
|
|
||||||
pytz=pytz.__version__,
|
|
||||||
Unidecode=unidecode_version,
|
|
||||||
Flask_SimpleLDAP=u'installed' if bool(services.ldap) else None,
|
|
||||||
python_LDAP=services.ldapVersion if bool(services.ldapVersion) else None,
|
|
||||||
Goodreads=u'installed' if bool(services.goodreads_support) else None,
|
|
||||||
jsonschema=services.SyncToken.__version__ if bool(services.SyncToken) else None,
|
|
||||||
flask_dance=flask_danceVersion,
|
|
||||||
greenlet=greenlet_Version
|
|
||||||
)
|
|
||||||
_VERSIONS.update(gdriveutils.get_versions())
|
|
||||||
_VERSIONS.update(uploader.get_versions(True))
|
|
||||||
else:
|
|
||||||
_VERSIONS = OrderedDict(
|
|
||||||
Platform='{0[0]} {0[2]} {0[3]} {0[4]} {0[5]}'.format(platform.uname()),
|
Platform='{0[0]} {0[2]} {0[3]} {0[4]} {0[5]}'.format(platform.uname()),
|
||||||
Python=sys.version,
|
Python=sys.version,
|
||||||
Calibre_Web=calibre_web_version,
|
Calibre_Web=calibre_web_version,
|
||||||
|
@ -124,9 +63,9 @@ else:
|
||||||
Jinja2=jinja2.__version__,
|
Jinja2=jinja2.__version__,
|
||||||
pySqlite=sqlite3.version,
|
pySqlite=sqlite3.version,
|
||||||
SQLite=sqlite3.sqlite_version,
|
SQLite=sqlite3.sqlite_version,
|
||||||
)
|
)
|
||||||
_VERSIONS.update(ret)
|
_VERSIONS.update(ret)
|
||||||
_VERSIONS.update(uploader.get_versions(False))
|
_VERSIONS.update(uploader.get_versions(False))
|
||||||
|
|
||||||
|
|
||||||
def collect_stats():
|
def collect_stats():
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
|
import json
|
||||||
|
|
||||||
from .constants import BASE_DIR
|
from .constants import BASE_DIR
|
||||||
try:
|
try:
|
||||||
|
@ -8,7 +10,7 @@ try:
|
||||||
ImportNotFound = BaseException
|
ImportNotFound = BaseException
|
||||||
except ImportError:
|
except ImportError:
|
||||||
importlib = False
|
importlib = False
|
||||||
|
version = None
|
||||||
|
|
||||||
if not importlib:
|
if not importlib:
|
||||||
try:
|
try:
|
||||||
|
@ -20,6 +22,13 @@ if not importlib:
|
||||||
|
|
||||||
def load_dependencys(optional=False):
|
def load_dependencys(optional=False):
|
||||||
deps = list()
|
deps = list()
|
||||||
|
if getattr(sys, 'frozen', False):
|
||||||
|
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 importlib or pkgresources:
|
||||||
if optional:
|
if optional:
|
||||||
req_path = os.path.join(BASE_DIR, "optional-requirements.txt")
|
req_path = os.path.join(BASE_DIR, "optional-requirements.txt")
|
||||||
|
@ -31,11 +40,14 @@ def load_dependencys(optional=False):
|
||||||
if not line.startswith('#') and not line == '\n' and not line.startswith('git'):
|
if not line.startswith('#') and not line == '\n' and not line.startswith('git'):
|
||||||
res = re.match(r'(.*?)([<=>\s]+)([\d\.]+),?\s?([<=>\s]+)?([\d\.]+)?', line.strip())
|
res = re.match(r'(.*?)([<=>\s]+)([\d\.]+),?\s?([<=>\s]+)?([\d\.]+)?', line.strip())
|
||||||
try:
|
try:
|
||||||
|
if getattr(sys, 'frozen', False):
|
||||||
|
dep_version = exe_deps[res.group(1).lower().replace('_','-')]
|
||||||
|
else:
|
||||||
if importlib:
|
if importlib:
|
||||||
dep_version = version(res.group(1))
|
dep_version = version(res.group(1))
|
||||||
else:
|
else:
|
||||||
dep_version = pkg_resources.get_distribution(res.group(1)).version
|
dep_version = pkg_resources.get_distribution(res.group(1)).version
|
||||||
except ImportNotFound:
|
except (ImportNotFound, KeyError):
|
||||||
if optional:
|
if optional:
|
||||||
continue
|
continue
|
||||||
dep_version = "not installed"
|
dep_version = "not installed"
|
||||||
|
|
|
@ -6,7 +6,7 @@ Flask-Principal>=0.3.2,<0.5.1
|
||||||
backports_abc>=0.4
|
backports_abc>=0.4
|
||||||
Flask>=1.0.2,<2.1.0
|
Flask>=1.0.2,<2.1.0
|
||||||
iso-639>=0.4.5,<0.5.0
|
iso-639>=0.4.5,<0.5.0
|
||||||
PyPDF3>=1.0.0,<1.0.6
|
PyPDF3>=1.0.0,<1.0.7
|
||||||
pytz>=2016.10
|
pytz>=2016.10
|
||||||
requests>=2.11.1,<2.28.0
|
requests>=2.11.1,<2.28.0
|
||||||
SQLAlchemy>=1.3.0,<1.5.0
|
SQLAlchemy>=1.3.0,<1.5.0
|
||||||
|
|
|
@ -46,7 +46,7 @@ install_requires =
|
||||||
backports_abc>=0.4
|
backports_abc>=0.4
|
||||||
Flask>=1.0.2,<2.1.0
|
Flask>=1.0.2,<2.1.0
|
||||||
iso-639>=0.4.5,<0.5.0
|
iso-639>=0.4.5,<0.5.0
|
||||||
PyPDF3>=1.0.0,<1.0.6
|
PyPDF3>=1.0.0,<1.0.7
|
||||||
pytz>=2016.10
|
pytz>=2016.10
|
||||||
requests>=2.11.1,<2.28.0
|
requests>=2.11.1,<2.28.0
|
||||||
SQLAlchemy>=1.3.0,<1.5.0
|
SQLAlchemy>=1.3.0,<1.5.0
|
||||||
|
|
Loading…
Reference in New Issue
Block a user