2013-09-07 01:40:48 +00:00
|
|
|
#!/usr/bin/env python3
|
2011-07-09 14:51:06 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2013-07-18 19:28:35 +00:00
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
2011-07-09 14:51:06 +00:00
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# --------------------------------------------------------------------------- #
|
2017-12-29 09:15:48 +00:00
|
|
|
# Copyright (c) 2008-2018 OpenLP Developers #
|
2011-07-09 14:51:06 +00:00
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
# This program is free software; you can redistribute it and/or modify it #
|
|
|
|
# under the terms of the GNU General Public License as published by the Free #
|
|
|
|
# Software Foundation; version 2 of the License. #
|
|
|
|
# #
|
|
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
|
|
|
# more details. #
|
|
|
|
# #
|
|
|
|
# You should have received a copy of the GNU General Public License along #
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
|
|
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
"""
|
|
|
|
This script is used to check dependencies of OpenLP. It checks availability
|
|
|
|
of required python modules and their version. To verify availability of Python
|
|
|
|
modules, simply run this script::
|
|
|
|
|
2017-09-13 06:08:38 +00:00
|
|
|
$ ./check_dependencies.py
|
2011-07-09 14:51:06 +00:00
|
|
|
|
|
|
|
"""
|
|
|
|
import os
|
|
|
|
import sys
|
2013-01-07 09:18:29 +00:00
|
|
|
from distutils.version import LooseVersion
|
2011-07-09 14:51:06 +00:00
|
|
|
|
2013-02-06 20:37:30 +00:00
|
|
|
IS_WIN = sys.platform.startswith('win')
|
2015-01-15 17:09:04 +00:00
|
|
|
IS_LIN = sys.platform.startswith('lin')
|
2015-12-24 19:41:47 +00:00
|
|
|
IS_MAC = sys.platform.startswith('dar')
|
2011-07-09 14:51:06 +00:00
|
|
|
|
2013-09-14 19:16:14 +00:00
|
|
|
|
2011-07-09 14:51:06 +00:00
|
|
|
VERS = {
|
2018-10-05 07:24:47 +00:00
|
|
|
'Python': '3.6',
|
2018-10-27 10:50:15 +00:00
|
|
|
'PyQt5': '5.5',
|
|
|
|
'Qt5': '5.5',
|
2018-10-08 08:10:02 +00:00
|
|
|
'pymediainfo': '2.2',
|
2011-07-09 14:51:06 +00:00
|
|
|
'sqlalchemy': '0.5',
|
2018-10-08 08:10:02 +00:00
|
|
|
'enchant': '1.6'
|
2011-08-25 20:14:02 +00:00
|
|
|
}
|
2011-07-09 14:51:06 +00:00
|
|
|
|
|
|
|
# pywin32
|
|
|
|
WIN32_MODULES = [
|
|
|
|
'win32com',
|
|
|
|
'win32ui',
|
|
|
|
'pywintypes',
|
2011-08-25 20:14:02 +00:00
|
|
|
]
|
2011-07-09 14:51:06 +00:00
|
|
|
|
2015-01-15 17:09:04 +00:00
|
|
|
LINUX_MODULES = [
|
|
|
|
# Optical drive detection.
|
|
|
|
'dbus',
|
|
|
|
]
|
|
|
|
|
2015-12-24 19:41:47 +00:00
|
|
|
MACOSX_MODULES = [
|
|
|
|
'objc',
|
|
|
|
'AppKit'
|
|
|
|
]
|
|
|
|
|
2015-01-15 17:09:04 +00:00
|
|
|
|
2011-07-09 14:51:06 +00:00
|
|
|
MODULES = [
|
2015-11-07 00:49:40 +00:00
|
|
|
'PyQt5',
|
|
|
|
'PyQt5.QtCore',
|
|
|
|
'PyQt5.QtGui',
|
|
|
|
'PyQt5.QtWidgets',
|
|
|
|
'PyQt5.QtNetwork',
|
|
|
|
'PyQt5.QtOpenGL',
|
|
|
|
'PyQt5.QtSvg',
|
|
|
|
'PyQt5.QtTest',
|
|
|
|
'PyQt5.QtWebKit',
|
|
|
|
'PyQt5.QtMultimedia',
|
2018-10-07 00:24:29 +00:00
|
|
|
'pymediainfo',
|
2018-10-07 23:34:00 +00:00
|
|
|
'appdirs',
|
2011-07-09 14:51:06 +00:00
|
|
|
'sqlalchemy',
|
2013-09-07 01:40:48 +00:00
|
|
|
'alembic',
|
2011-07-09 14:51:06 +00:00
|
|
|
'lxml',
|
|
|
|
'chardet',
|
2013-04-05 19:58:13 +00:00
|
|
|
'bs4',
|
2011-07-09 14:51:06 +00:00
|
|
|
'mako',
|
2016-06-04 10:50:43 +00:00
|
|
|
'websockets',
|
2016-06-06 16:44:14 +00:00
|
|
|
'waitress',
|
2017-09-13 06:08:38 +00:00
|
|
|
'webob',
|
2018-04-22 06:59:35 +00:00
|
|
|
'requests',
|
|
|
|
'qtawesome'
|
2011-08-25 20:14:02 +00:00
|
|
|
]
|
2011-07-09 14:51:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
OPTIONAL_MODULES = [
|
2018-10-08 08:10:02 +00:00
|
|
|
('mysql.connector', '(MySQL support)'),
|
|
|
|
('pyodbc', '(ODBC support)'),
|
|
|
|
('psycopg2', '(PostgreSQL support)'),
|
|
|
|
('enchant', '(spell checker)'),
|
|
|
|
('pysword', '(import SWORD bibles)'),
|
|
|
|
('uno', '(LibreOffice/OpenOffice support)'),
|
|
|
|
# development/testing modules
|
2018-10-12 22:11:04 +00:00
|
|
|
('jenkins', '(access jenkins api)'),
|
|
|
|
('launchpadlib', '(launchpad script support)'),
|
2018-10-08 08:10:02 +00:00
|
|
|
('nose2', '(testing framework)'),
|
|
|
|
('pylint', '(linter)')
|
2011-07-13 13:41:32 +00:00
|
|
|
]
|
2011-07-09 14:51:06 +00:00
|
|
|
|
|
|
|
w = sys.stdout.write
|
|
|
|
|
2013-09-14 19:16:14 +00:00
|
|
|
|
2011-07-09 14:51:06 +00:00
|
|
|
def check_vers(version, required, text):
|
2013-10-03 19:56:12 +00:00
|
|
|
"""
|
|
|
|
Check the version of a dependency. Returns ``True`` if the version is greater than or equal, or False if less than.
|
|
|
|
|
|
|
|
``version``
|
|
|
|
The actual version of the dependency
|
|
|
|
|
|
|
|
``required``
|
|
|
|
The required version of the dependency
|
|
|
|
|
|
|
|
``text``
|
|
|
|
The dependency's name
|
|
|
|
"""
|
|
|
|
space = (27 - len(required) - len(text)) * ' '
|
2013-06-16 19:42:50 +00:00
|
|
|
if not isinstance(version, str):
|
2013-01-07 09:18:29 +00:00
|
|
|
version = '.'.join(map(str, version))
|
2013-06-16 19:42:50 +00:00
|
|
|
if not isinstance(required, str):
|
2013-01-07 09:18:29 +00:00
|
|
|
required = '.'.join(map(str, required))
|
2013-10-03 19:56:12 +00:00
|
|
|
w(' %s >= %s ... ' % (text, required) + space)
|
2013-01-07 09:18:29 +00:00
|
|
|
if LooseVersion(version) >= LooseVersion(required):
|
|
|
|
w(version + os.linesep)
|
2011-07-09 14:51:06 +00:00
|
|
|
return True
|
|
|
|
else:
|
|
|
|
w('FAIL' + os.linesep)
|
|
|
|
return False
|
|
|
|
|
2013-09-14 19:16:14 +00:00
|
|
|
|
2013-10-03 19:56:12 +00:00
|
|
|
def check_module(mod, text='', indent=' '):
|
|
|
|
"""
|
|
|
|
Check that a module is installed.
|
|
|
|
|
|
|
|
``mod``
|
|
|
|
The module to check for.
|
|
|
|
|
|
|
|
``text``
|
|
|
|
The text to display.
|
|
|
|
|
|
|
|
``indent``
|
|
|
|
How much to indent the text by.
|
|
|
|
"""
|
|
|
|
space = (31 - len(mod) - len(text)) * ' '
|
|
|
|
w(indent + '%s %s... ' % (mod, text) + space)
|
|
|
|
try:
|
|
|
|
__import__(mod)
|
|
|
|
w('OK')
|
|
|
|
except ImportError:
|
|
|
|
w('FAIL')
|
|
|
|
w(os.linesep)
|
|
|
|
|
|
|
|
|
2011-07-10 12:00:58 +00:00
|
|
|
def print_vers_fail(required, text):
|
|
|
|
print(' %s >= %s ... FAIL' % (text, required))
|
|
|
|
|
2013-09-14 19:16:14 +00:00
|
|
|
|
2011-07-09 14:51:06 +00:00
|
|
|
def verify_python():
|
|
|
|
if not check_vers(list(sys.version_info), VERS['Python'], text='Python'):
|
|
|
|
exit(1)
|
|
|
|
|
2013-09-14 19:16:14 +00:00
|
|
|
|
2011-07-09 14:51:06 +00:00
|
|
|
def verify_versions():
|
|
|
|
print('Verifying version of modules...')
|
2011-07-10 12:00:58 +00:00
|
|
|
try:
|
2015-11-07 00:49:40 +00:00
|
|
|
from PyQt5 import QtCore
|
|
|
|
check_vers(QtCore.PYQT_VERSION_STR, VERS['PyQt5'], 'PyQt5')
|
|
|
|
check_vers(QtCore.qVersion(), VERS['Qt5'], 'Qt5')
|
2011-07-10 12:00:58 +00:00
|
|
|
except ImportError:
|
2015-11-07 00:49:40 +00:00
|
|
|
print_vers_fail(VERS['PyQt5'], 'PyQt5')
|
|
|
|
print_vers_fail(VERS['Qt5'], 'Qt5')
|
2011-07-10 12:00:58 +00:00
|
|
|
try:
|
|
|
|
import sqlalchemy
|
|
|
|
check_vers(sqlalchemy.__version__, VERS['sqlalchemy'], 'sqlalchemy')
|
|
|
|
except ImportError:
|
|
|
|
print_vers_fail(VERS['sqlalchemy'], 'sqlalchemy')
|
|
|
|
try:
|
|
|
|
import enchant
|
|
|
|
check_vers(enchant.__version__, VERS['enchant'], 'enchant')
|
|
|
|
except ImportError:
|
|
|
|
print_vers_fail(VERS['enchant'], 'enchant')
|
2011-07-09 14:51:06 +00:00
|
|
|
|
2013-09-14 19:16:14 +00:00
|
|
|
|
2013-10-03 19:56:12 +00:00
|
|
|
def print_enchant_backends_and_languages():
|
|
|
|
"""
|
|
|
|
Check if PyEnchant is installed.
|
|
|
|
"""
|
2011-07-10 12:00:58 +00:00
|
|
|
w('Enchant (spell checker)... ')
|
|
|
|
try:
|
|
|
|
import enchant
|
|
|
|
w(os.linesep)
|
|
|
|
backends = ', '.join([x.name for x in enchant.Broker().describe()])
|
|
|
|
print(' available backends: %s' % backends)
|
|
|
|
langs = ', '.join(enchant.list_languages())
|
|
|
|
print(' available languages: %s' % langs)
|
|
|
|
except ImportError:
|
|
|
|
w('FAIL' + os.linesep)
|
2011-07-09 20:13:33 +00:00
|
|
|
|
2013-09-14 19:16:14 +00:00
|
|
|
|
2013-10-03 19:56:12 +00:00
|
|
|
def print_qt_image_formats():
|
|
|
|
"""
|
2015-11-07 00:49:40 +00:00
|
|
|
Print out the image formats that Qt5 supports.
|
2013-10-03 19:56:12 +00:00
|
|
|
"""
|
2015-11-07 00:49:40 +00:00
|
|
|
w('Qt5 image formats... ')
|
2011-07-10 12:00:58 +00:00
|
|
|
try:
|
2015-11-07 00:49:40 +00:00
|
|
|
from PyQt5 import QtGui
|
2013-10-03 19:56:12 +00:00
|
|
|
read_f = ', '.join([bytes(fmt).decode().lower() for fmt in QtGui.QImageReader.supportedImageFormats()])
|
|
|
|
write_f = ', '.join([bytes(fmt).decode().lower() for fmt in QtGui.QImageWriter.supportedImageFormats()])
|
2011-07-10 12:00:58 +00:00
|
|
|
w(os.linesep)
|
|
|
|
print(' read: %s' % read_f)
|
|
|
|
print(' write: %s' % write_f)
|
|
|
|
except ImportError:
|
|
|
|
w('FAIL' + os.linesep)
|
2011-07-09 20:13:33 +00:00
|
|
|
|
2013-09-14 19:16:14 +00:00
|
|
|
|
2011-07-09 14:51:06 +00:00
|
|
|
def main():
|
2013-10-03 19:56:12 +00:00
|
|
|
"""
|
|
|
|
Run the dependency checker.
|
|
|
|
"""
|
|
|
|
print('Checking Python version...')
|
2011-07-09 14:51:06 +00:00
|
|
|
verify_python()
|
|
|
|
print('Checking for modules...')
|
|
|
|
for m in MODULES:
|
|
|
|
check_module(m)
|
|
|
|
print('Checking for optional modules...')
|
|
|
|
for m in OPTIONAL_MODULES:
|
2018-10-08 08:10:02 +00:00
|
|
|
check_module(m[0], text=m[1])
|
2013-02-06 20:37:30 +00:00
|
|
|
if IS_WIN:
|
2011-07-09 14:51:06 +00:00
|
|
|
print('Checking for Windows specific modules...')
|
|
|
|
for m in WIN32_MODULES:
|
|
|
|
check_module(m)
|
2015-01-15 17:09:04 +00:00
|
|
|
elif IS_LIN:
|
|
|
|
print('Checking for Linux specific modules...')
|
|
|
|
for m in LINUX_MODULES:
|
|
|
|
check_module(m)
|
2015-12-24 19:41:47 +00:00
|
|
|
elif IS_MAC:
|
|
|
|
print('Checking for Mac OS X specific modules...')
|
|
|
|
for m in MACOSX_MODULES:
|
|
|
|
check_module(m)
|
2011-07-09 14:51:06 +00:00
|
|
|
verify_versions()
|
2013-10-03 19:56:12 +00:00
|
|
|
print_qt_image_formats()
|
|
|
|
print_enchant_backends_and_languages()
|
2011-07-09 14:51:06 +00:00
|
|
|
|
2016-11-15 21:13:52 +00:00
|
|
|
|
2013-08-31 18:17:38 +00:00
|
|
|
if __name__ == '__main__':
|
2011-07-09 14:51:06 +00:00
|
|
|
main()
|