1'''
2Checks if all required Python modules are installed.
3
4@author: Peter Parente
5@organization: IBM Corporation
6@copyright: Copyright (c) 2005, 2007 IBM Corporation
7@license: The BSD License
8
9All rights reserved. This program and the accompanying materials are made
10available under the terms of the BSD License which accompanies
11this distribution, and is available at
12U{http://www.opensource.org/licenses/bsd-license.php}
13'''
14import sys, os, imp
15
16PYGTK_REQ = '2.0'
17PYATSPI_REQ = (2, 23, 3)
18GTK_VERSION = (2, 8, 0)
19
20try:
21  # stop the gail bridge from loading during build
22  val = os.environ['GTK_MODULES']
23  os.environ['GTK_MODULES'] = val.replace('gail:atk-bridge', '')
24except KeyError:
25  pass
26
27# test for python modules
28modules = ['pyatspi', 'cairo', 'rsvg', 'gi', 'gi.repository.Gtk', \
29          'gi.repository.GConf', 'gi.repository.Gdk', 'gi.repository.Atk', \
30          'gi.repository.GObject', 'gi.repository.GdkPixbuf', \
31          'gi.repository.Wnck', 'gi.repository.Gio']
32
33for name in modules:
34  try:
35    m = __import__(name)
36    print(name)
37  except ImportError as e:
38    print(name, '*MISSING*')
39    sys.exit(1)
40  except RuntimeError:
41    # ignore other errors which might be from lack of a display
42    continue
43  if name =='pyatspi':
44    try:
45      compared = [cmp(*x) for x in zip(PYATSPI_REQ, m.__version__)]
46    except AttributeError:
47      # Installed pyatspi does not support __version__, too old.
48      compared = [-1, 0, 0]
49    if -1 in compared and 1 not in compared[:compared.index(-1)]:
50      # A -1 without a 1 preceding it means an older version.
51      print("\nNeed pyatspi 1.23.4 or higher (or SVN trunk)")
52      sys.exit(1)
53print()
54