From a71ea86e4d93bde6ecb7d4e48e4456fbfae3021c Mon Sep 17 00:00:00 2001 From: Martin Zibricky Date: Sat, 9 Jul 2011 16:51:06 +0200 Subject: [PATCH 1/3] add script to check openlp dependencies --- scripts/check_dependencies.py | 148 ++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100755 scripts/check_dependencies.py diff --git a/scripts/check_dependencies.py b/scripts/check_dependencies.py new file mode 100755 index 000000000..967ff2185 --- /dev/null +++ b/scripts/check_dependencies.py @@ -0,0 +1,148 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2011 Raoul Snyman # +# --------------------------------------------------------------------------- # +# 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:: + + @:~$ ./check_dependencies.py + +""" +import os +import sys + +is_win = sys.platform.startswith('win') + +VERS = { + 'Python': '2.6', + 'PyQt4': '4.6', + 'Qt4': '4.6', + 'sqlalchemy': '0.5', + # pyenchant 1.6 required on Windows + 'enchant': '1.6' if is_win else '1.3' + } + +# pywin32 +WIN32_MODULES = [ + 'win32com', + 'win32ui', + 'pywintypes', + ] + +MODULES = [ + 'PyQt4', + 'PyQt4.QtCore', + 'PyQt4.QtGui', + 'PyQt4.QtNetwork', + 'PyQt4.QtOpenGL', + 'PyQt4.QtSvg', + 'PyQt4.QtTest', + 'PyQt4.QtWebKit', + 'PyQt4.phonon', + 'sqlalchemy', + 'sqlite3', + 'lxml', + 'chardet', + 'enchant', + 'BeautifulSoup', + 'mako', + ] + + +OPTIONAL_MODULES = [ + ('sqlite', ' (SQLite 2 support)'), + ('MySQLdb', ' (MySQL support)'), + ('psycopg2', ' (PostgreSQL support)'), + ] + +w = sys.stdout.write + + +def check_vers(version, required, text): + if type(version) is str: + version = version.split('.') + version = [int(x) for x in version] + if type(required) is str: + required = required.split('.') + required = [int(x) for x in required] + w(' %s >= %s ... ' % (text, '.'.join([str(x) for x in required]))) + if version >= required: + w('.'.join([str(x) for x in version]) + os.linesep) + return True + else: + w('FAIL' + os.linesep) + return False + + +def verify_python(): + if not check_vers(list(sys.version_info), VERS['Python'], text='Python'): + exit(1) + + +def verify_versions(): + print('Verifying version of modules...') + from PyQt4 import QtCore + check_vers(QtCore.PYQT_VERSION_STR, VERS['PyQt4'], + 'PyQt4') + check_vers(QtCore.qVersion(), VERS['Qt4'], + 'Qt4') + check_vers(__import__('sqlalchemy').__version__, VERS['sqlalchemy'], + 'sqlalchemy') + check_vers(__import__('enchant').__version__, VERS['enchant'], + 'enchant') + + +def check_module(mod, text='', indent=' '): + space = (30 - len(mod) - len(text)) * ' ' + w(indent + '%s%s... ' % (mod, text) + space) + try: + __import__(mod) + w('OK') + except ImportError: + w('FAIL') + w(os.linesep) + + +def main(): + + verify_python() + + print('Checking for modules...') + for m in MODULES: + check_module(m) + + print('Checking for optional modules...') + for m in OPTIONAL_MODULES: + check_module(m[0], text=m[1]) + + if sys.platform.startswith('win'): + print('Checking for Windows specific modules...') + for m in WIN32_MODULES: + check_module(m) + + verify_versions() + + +if __name__ == u'__main__': + main() From 5951d2c2a32f90f611f4402dab60cc5919ad41c8 Mon Sep 17 00:00:00 2001 From: Martin Zibricky Date: Sat, 9 Jul 2011 22:13:33 +0200 Subject: [PATCH 2/3] Update script to check openlp dependecies by info about supported image formats, enchant backends and available languages --- scripts/check_dependencies.py | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/scripts/check_dependencies.py b/scripts/check_dependencies.py index 967ff2185..c60bf6842 100755 --- a/scripts/check_dependencies.py +++ b/scripts/check_dependencies.py @@ -107,10 +107,10 @@ def verify_versions(): 'PyQt4') check_vers(QtCore.qVersion(), VERS['Qt4'], 'Qt4') - check_vers(__import__('sqlalchemy').__version__, VERS['sqlalchemy'], - 'sqlalchemy') - check_vers(__import__('enchant').__version__, VERS['enchant'], - 'enchant') + import sqlalchemy + check_vers(sqlalchemy.__version__, VERS['sqlalchemy'], 'sqlalchemy') + import enchant + check_vers(enchant.__version__, VERS['enchant'], 'enchant') def check_module(mod, text='', indent=' '): @@ -124,6 +124,27 @@ def check_module(mod, text='', indent=' '): w(os.linesep) +def verify_pyenchant(): + print('Enchant...') + import enchant + 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) + + +def verify_pyqt(): + print('Qt4 image formats...') + from PyQt4 import QtGui + read_f = ', '.join([unicode(format).lower() \ + for format in QtGui.QImageReader.supportedImageFormats()]) + write_f= ', '.join([unicode(format).lower() \ + for format in QtGui.QImageWriter.supportedImageFormats()]) + print(' read: %s' % read_f) + print(' write: %s' % write_f) + from PyQt4 import phonon + + def main(): verify_python() @@ -142,6 +163,8 @@ def main(): check_module(m) verify_versions() + verify_pyqt() + verify_pyenchant() if __name__ == u'__main__': From cfb1a06bd3fc2398a1c1f94a1dd8b987aeb37794 Mon Sep 17 00:00:00 2001 From: Martin Zibricky Date: Sun, 10 Jul 2011 14:00:58 +0200 Subject: [PATCH 3/3] Update script to check openlp dependecies - catching all imports properly --- scripts/check_dependencies.py | 71 +++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 25 deletions(-) diff --git a/scripts/check_dependencies.py b/scripts/check_dependencies.py index c60bf6842..4abd1504d 100755 --- a/scripts/check_dependencies.py +++ b/scripts/check_dependencies.py @@ -95,6 +95,10 @@ def check_vers(version, required, text): return False +def print_vers_fail(required, text): + print(' %s >= %s ... FAIL' % (text, required)) + + def verify_python(): if not check_vers(list(sys.version_info), VERS['Python'], text='Python'): exit(1) @@ -102,15 +106,25 @@ def verify_python(): def verify_versions(): print('Verifying version of modules...') - from PyQt4 import QtCore - check_vers(QtCore.PYQT_VERSION_STR, VERS['PyQt4'], - 'PyQt4') - check_vers(QtCore.qVersion(), VERS['Qt4'], - 'Qt4') - import sqlalchemy - check_vers(sqlalchemy.__version__, VERS['sqlalchemy'], 'sqlalchemy') - import enchant - check_vers(enchant.__version__, VERS['enchant'], 'enchant') + try: + from PyQt4 import QtCore + check_vers(QtCore.PYQT_VERSION_STR, VERS['PyQt4'], + 'PyQt4') + check_vers(QtCore.qVersion(), VERS['Qt4'], + 'Qt4') + except ImportError: + print_vers_fail(VERS['PyQt4'], 'PyQt4') + print_vers_fail(VERS['Qt4'], 'Qt4') + 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') def check_module(mod, text='', indent=' '): @@ -125,24 +139,31 @@ def check_module(mod, text='', indent=' '): def verify_pyenchant(): - print('Enchant...') - import enchant - 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) + 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) def verify_pyqt(): - print('Qt4 image formats...') - from PyQt4 import QtGui - read_f = ', '.join([unicode(format).lower() \ - for format in QtGui.QImageReader.supportedImageFormats()]) - write_f= ', '.join([unicode(format).lower() \ - for format in QtGui.QImageWriter.supportedImageFormats()]) - print(' read: %s' % read_f) - print(' write: %s' % write_f) - from PyQt4 import phonon + w('Qt4 image formats... ') + try: + from PyQt4 import QtGui + read_f = ', '.join([unicode(format).lower() \ + for format in QtGui.QImageReader.supportedImageFormats()]) + write_f= ', '.join([unicode(format).lower() \ + for format in QtGui.QImageWriter.supportedImageFormats()]) + w(os.linesep) + print(' read: %s' % read_f) + print(' write: %s' % write_f) + except ImportError: + w('FAIL' + os.linesep) def main(): @@ -157,7 +178,7 @@ def main(): for m in OPTIONAL_MODULES: check_module(m[0], text=m[1]) - if sys.platform.startswith('win'): + if is_win: print('Checking for Windows specific modules...') for m in WIN32_MODULES: check_module(m)