fix proxy change detection
[straw.git] / setup.py
blob25c42e7ed0b7fc9942d743eee12d04694d29d13f
1 #! /usr/bin/env python
2 """Straw: A feed aggregator for open source desktops.
4 Straw is a feed aggregator for open source desktops. Its goal is to be a
5 faster, easier, and more accessible way to read news and blogs than the
6 web browser. It uses the Python bindings to the GTK+ toolkit and supports RSS
7 and ATOM feeds.
8 """
10 classifiers = """\
11 Development Status :: 4 - Beta
12 Environment :: X11 Applications :: GTK
13 Environment :: X11 Applications :: Gnome
14 Intended Audience :: End Users/Desktop
15 License :: OSI Approved :: GNU General Public License (GPL)
16 Operating System :: POSIX
17 Operating System :: POSIX :: Linux
18 Programming Language :: Python
19 Topic :: Desktop Environment
20 Topic :: Desktop Environment :: Gnome
21 Topic :: Internet :: WWW/HTTP
22 """
24 import sys
25 import glob
26 import os.path
28 strawenv = {'APPNAME': 'Straw',
29 'VERSION': '0.28-dev',
30 'PYTHON': '2.4',
31 'PYGTK': (2,8,0)}
34 pyver = float(sys.version.split()[0][:3])
35 if pyver <= float(strawenv["PYTHON"]):
36 sys.exit('Error: %s or newer is required. Current version:\n %s'
37 % (strawenv['PYTHON'],pyver))
39 doclines = __doc__.split("\n")
41 def modules_check():
42 '''Check if necessary modules is installed.
43 The function is executed by distutils (by the install command).'''
44 # Set This For Machines with No DISPLAY
45 nogtk = 0
47 import imp
48 # Check for PyGTK version
49 try:
50 import pygtk
51 pygtk.require('2.0')
52 imp.find_module('gtk')
53 import gtk
54 if gtk.pygtk_version < strawenv['PYGTK']:
55 raise
56 except AssertionError:
57 pass # We ignore this because gtk must be present to build"
58 except RuntimeError, msg:
59 if os.environ.get ('DISPLAY', '') != '':
60 etype, value, tb = sys.exc_info ()
61 traceback.print_exception (etype, value, tb)
63 sys.exit('Error: unexpected runtime error checking for gtk module')
64 nogtk = 1
65 pass # No DISPLAY set, pass
66 except:
67 sys.exit('Error: PyGTK-%d.%d.%d or newer is required.' % strawenv['PYGTK'])
69 # Check other module requirements.
70 # In pygtk versions prior to 2.10, gtkhtml2 is included in
71 # the 'gnome' module. But as of 2.10, the gtkhtml2 module was
72 # removed in 'gnome' and added in 'gnome-extras' module.
73 # The egg.trayicon module is also included in g-p-e, so no need to check here.
74 mod_list = [
75 ('gnome', 'python-gnome2', 0),
76 ('gtkhtml2', "python-gnome2-extras", 0),
77 ('gconf', "python-gnome2", 1),
78 ('bsddb.db', 'python-bsddb', 0),
79 ('dbus', 'python-dbus', 0)]
81 for m, w, x in mod_list:
82 if nogtk == 1 and m == 'gtkhtml2':
83 pass;
84 else:
85 try:
86 if not x: exec('import %s' % m)
87 else: imp.find_module(m)
88 except ImportError, msg:
89 sys.exit("Error: '%s' module in package '%s' is required to install %s" \
90 % (m,w,strawenv['APPNAME']))
92 # Check for dbus version
93 if getattr(dbus, 'version', None) is None:
94 print "Warning: Recent versions of DBus is needed to run Straw"
96 # gtk.glade needs special care (ugly...)
97 path = imp.find_module('gtk')
98 if not os.path.exists(path[1] + '/glade.so'):
99 sys.exit('Error: %s module is required to install %s' \
100 % ("PyGTK's glade", strawenv['APPNAME']))
102 # Check for ADNS
103 try:
104 import adns, ADNS
105 except ImportError:
106 print 'Warning: ADNS Python module not found, will continue without.'
108 def translations():
109 '''Build mo-po mapping from po directory'''
110 trans = []
111 dest = 'share/locale/%s/LC_MESSAGES/%s.mo'
112 for po in glob.glob('po/*.po'):
113 lang = os.path.splitext(os.path.basename(po))[0]
114 trans.append((dest % (lang , strawenv['APPNAME'].lower()), po))
115 return trans
117 def translation_files():
118 '''Files for translation...'''
119 potfile = './po/POTFILES.in'
120 if not os.path.exists(potfile):
121 sys.exit("No such file, '%s'. This file should've been built \
122 automatically. You can run \"intltool-update --pot\" to create it manually.\
123 We also encourage you to file a bug report against Straw." % potfile)
124 try:
125 f = open(potfile)
126 files = []
127 for line in f:
128 # ignore comments and newline
129 if not line.startswith('#') or not line.startswith('\n'):
130 files.append(line.strip())
131 finally:
132 f.close()
133 return files
135 def data_files():
136 '''Build list of data files to be installed'''
137 images = glob.glob('images/*.png')
138 misc = [
139 'data/default_subscriptions.opml',
140 'data/straw.css',
141 'glade/straw.glade'
143 files = [
144 ('share/pixmaps', ['images/straw.png']),
145 ('share/straw', images + misc)]
146 return files
148 # Let distutils do the work
149 from tools.straw_distutils import setup
150 setup(name = strawenv['APPNAME'],
151 version = strawenv['VERSION'],
152 description = doclines[0],
153 long_description = "\n".join(doclines[2:]),
154 author = 'Juri Pakaste',
155 author_email = 'juri@iki.fi',
156 maintainer = 'Jan Alonzo',
157 maintainer_email = 'jmalonzo@unpluggable.com',
158 url = 'http://www.gnome.org/projects/straw/',
159 license = 'GPL',
160 data_files = data_files(),
161 pot_file = 'po/straw.pot',
162 translations = translations(),
163 modules_check = modules_check,
164 msg_sources = translation_files(),
165 desktop_file = ['straw.desktop.in'],
166 constants = [('constants.py.in', strawenv)],
167 scripts = ['src/straw'],
168 packages = ['straw'],
169 package_dir = {'straw' : 'src/lib'},
170 config_files = [('gconf/schemas',['data/straw.schemas'],
171 'with-gconf-schema-file-dir')],
172 classifiers = filter(None, classifiers.split("\n")))