2011-07-09 14:51:06 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# --------------------------------------------------------------------------- #
|
2012-12-29 20:56:56 +00:00
|
|
|
# Copyright (c) 2008-2013 Raoul Snyman #
|
|
|
|
# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan #
|
2012-06-22 14:14:53 +00:00
|
|
|
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
|
2012-11-11 21:16:14 +00:00
|
|
|
# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
|
2012-10-21 13:16:22 +00:00
|
|
|
# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
|
|
|
|
# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
|
|
|
|
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
|
2012-12-01 07:57:54 +00:00
|
|
|
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
|
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::
|
|
|
|
|
|
|
|
@:~$ ./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'
|
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
|
|
|
|
|
|
|
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',
|
2011-08-25 20:14:02 +00:00
|
|
|
'migrate',
|
2011-10-26 07:40:12 +00:00
|
|
|
'uno',
|
2011-08-25 20:14:02 +00:00
|
|
|
]
|
2011-07-09 14:51:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
OPTIONAL_MODULES = [
|
|
|
|
('sqlite', ' (SQLite 2 support)'),
|
|
|
|
('MySQLdb', ' (MySQL support)'),
|
|
|
|
('psycopg2', ' (PostgreSQL support)'),
|
2011-09-02 11:10:07 +00:00
|
|
|
('pytest', ' (testing framework)'),
|
2011-07-13 13:41:32 +00:00
|
|
|
]
|
2011-07-09 14:51:06 +00:00
|
|
|
|
|
|
|
w = sys.stdout.write
|
|
|
|
|
|
|
|
def check_vers(version, required, text):
|
|
|
|
if type(version) is str:
|
|
|
|
version = version.split('.')
|
2011-07-13 13:41:32 +00:00
|
|
|
version = map(int, version)
|
2011-07-09 14:51:06 +00:00
|
|
|
if type(required) is str:
|
|
|
|
required = required.split('.')
|
2011-07-13 13:41:32 +00:00
|
|
|
required = map(int, required)
|
|
|
|
w(' %s >= %s ... ' % (text, '.'.join(map(str, required))))
|
2011-07-09 14:51:06 +00:00
|
|
|
if version >= required:
|
2011-07-13 13:41:32 +00:00
|
|
|
w('.'.join(map(str, version)) + os.linesep)
|
2011-07-09 14:51:06 +00:00
|
|
|
return True
|
|
|
|
else:
|
|
|
|
w('FAIL' + os.linesep)
|
|
|
|
return False
|
|
|
|
|
2011-07-10 12:00:58 +00:00
|
|
|
def print_vers_fail(required, text):
|
|
|
|
print(' %s >= %s ... FAIL' % (text, required))
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
def verify_versions():
|
|
|
|
print('Verifying version of modules...')
|
2011-07-10 12:00:58 +00:00
|
|
|
try:
|
|
|
|
from PyQt4 import QtCore
|
2011-07-13 13:41:32 +00:00
|
|
|
check_vers(QtCore.PYQT_VERSION_STR, VERS['PyQt4'], 'PyQt4')
|
|
|
|
check_vers(QtCore.qVersion(), VERS['Qt4'], 'Qt4')
|
2011-07-10 12:00:58 +00:00
|
|
|
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')
|
2011-07-09 14:51:06 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
2011-07-09 20:13:33 +00:00
|
|
|
def verify_pyenchant():
|
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
|
|
|
|
|
|
|
def verify_pyqt():
|
2011-07-10 12:00:58 +00:00
|
|
|
w('Qt4 image formats... ')
|
|
|
|
try:
|
|
|
|
from PyQt4 import QtGui
|
2011-07-13 13:41:32 +00:00
|
|
|
read_f = ', '.join([unicode(format).lower()
|
2011-07-10 12:00:58 +00:00
|
|
|
for format in QtGui.QImageReader.supportedImageFormats()])
|
2011-07-13 13:41:32 +00:00
|
|
|
write_f = ', '.join([unicode(format).lower()
|
2011-07-10 12:00:58 +00:00
|
|
|
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)
|
2011-07-09 20:13:33 +00:00
|
|
|
|
2011-07-09 14:51:06 +00:00
|
|
|
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])
|
|
|
|
|
2011-07-10 12:00:58 +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)
|
|
|
|
|
|
|
|
verify_versions()
|
2011-07-09 20:13:33 +00:00
|
|
|
verify_pyqt()
|
|
|
|
verify_pyenchant()
|
2011-07-09 14:51:06 +00:00
|
|
|
|
|
|
|
if __name__ == u'__main__':
|
|
|
|
main()
|