openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #10765
[Merge] lp:~mzibricky/openlp/testing into lp:openlp
matysek has proposed merging lp:~mzibricky/openlp/testing into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~mzibricky/openlp/testing/+merge/67438
Add python script to check dependencies needed for OpenLP.
--
https://code.launchpad.net/~mzibricky/openlp/testing/+merge/67438
Your team OpenLP Core is requested to review the proposed merge of lp:~mzibricky/openlp/testing into lp:openlp.
=== added file 'scripts/check_dependencies.py'
--- scripts/check_dependencies.py 1970-01-01 00:00:00 +0000
+++ scripts/check_dependencies.py 2011-07-09 21:06:36 +0000
@@ -0,0 +1,171 @@
+#!/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')
+ import sqlalchemy
+ check_vers(sqlalchemy.__version__, VERS['sqlalchemy'], 'sqlalchemy')
+ import enchant
+ check_vers(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 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()
+
+ 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()
+ verify_pyqt()
+ verify_pyenchant()
+
+
+if __name__ == u'__main__':
+ main()
Follow ups