- complete feed properties dialog redesign - updated Changelog
[straw.git] / setup.py
blob55b26f8b3ba3d44027f87ad4d97b80d801cf7289
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)}
33 if sys.version < strawenv['PYTHON']:
34 sys.exit('Error: %s or newer is required. Current version:\n %s'
35 % (strawenv['PYTHON'],sys.version))
37 doclines = __doc__.split("\n")
39 def modules_check():
40 '''Check if necessary modules is installed.
41 The function is executed by distutils (by the install command).'''
42 # Set This For Machines with No DISPLAY
43 nogtk = 0
45 import imp
46 # Check for PyGTK version
47 try:
48 import pygtk
49 pygtk.require('2.0')
50 imp.find_module('gtk')
51 import gtk
52 if gtk.pygtk_version < strawenv['PYGTK']:
53 raise
54 except AssertionError:
55 pass # We ignore this because gtk must be present to build"
56 except RuntimeError, msg:
57 if os.environ.get ('DISPLAY', '') != '':
58 etype, value, tb = sys.exc_info ()
59 traceback.print_exception (etype, value, tb)
61 sys.exit('Error: unexpected runtime error checking for gtk module')
62 nogtk = 1
63 pass # No DISPLAY set, pass
64 except:
65 sys.exit('Error: PyGTK-%d.%d.%d or newer is required.' % strawenv['PYGTK'])
67 # Check other module requirements.
68 # In pygtk versions prior to 2.10, gtkhtml2 is included in
69 # the 'gnome' module. But as of 2.10, the gtkhtml2 module was
70 # removed in 'gnome' and added in 'gnome-extras' module.
71 # The egg.trayicon module is also included in g-p-e, so no need to check here.
72 mod_list = [
73 ('gnome', 'python-gnome2', 0),
74 ('gtkhtml2', "python-gnome2-extras", 0),
75 ('gconf', "python-gnome2", 1),
76 ('bsddb.db', 'python-bsddb', 0),
77 ('dbus', 'python-dbus', 0)]
79 for m, w, x in mod_list:
80 if nogtk == 1 and m == 'gtkhtml2':
81 pass;
82 else:
83 try:
84 if not x: exec('import %s' % m)
85 else: imp.find_module(m)
86 except ImportError, msg:
87 sys.exit("Error: '%s' module in package '%s' is required to install %s" \
88 % (m,w,strawenv['APPNAME']))
90 # Check for dbus version
91 if getattr(dbus, 'version', None) is None:
92 print "Warning: Recent versions of DBus is needed to run Straw"
94 # gtk.glade needs special care (ugly...)
95 path = imp.find_module('gtk')
96 if not os.path.exists(path[1] + '/glade.so'):
97 sys.exit('Error: %s module is required to install %s' \
98 % ("PyGTK's glade", strawenv['APPNAME']))
100 # Check for ADNS
101 try:
102 import adns, ADNS
103 except ImportError:
104 print 'Warning: ADNS Python module not found, will continue without.'
106 def translations():
107 '''Build mo-po mapping from po directory'''
108 trans = []
109 dest = 'share/locale/%s/LC_MESSAGES/%s.mo'
110 for po in glob.glob('po/*.po'):
111 lang = os.path.splitext(os.path.basename(po))[0]
112 trans.append((dest % (lang , strawenv['APPNAME'].lower()), po))
113 return trans
115 def translation_files():
116 '''Files for translation...'''
117 potfile = './po/POTFILES.in'
118 if not os.path.exists(potfile):
119 sys.exit("No such file, '%s'. This file should've been built \
120 automatically. You can run \"intltool-update --pot\" to create it manually.\
121 We also encourage you to file a bug report against Straw." % potfile)
122 try:
123 f = open(potfile)
124 files = []
125 for line in f:
126 # ignore comments and newline
127 if not line.startswith('#') or not line.startswith('\n'):
128 files.append(line.strip())
129 finally:
130 f.close()
131 return files
133 def data_files():
134 '''Build list of data files to be installed'''
135 images = glob.glob('images/*.png')
136 misc = [
137 'data/default_subscriptions.opml',
138 'data/straw.css',
139 'glade/straw.glade'
141 files = [
142 ('share/pixmaps', ['images/straw.png']),
143 ('share/straw', images + misc)]
144 return files
146 # Let distutils do the work
147 from tools.straw_distutils import setup
148 setup(name = strawenv['APPNAME'],
149 version = strawenv['VERSION'],
150 description = doclines[0],
151 long_description = "\n".join(doclines[2:]),
152 author = 'Juri Pakaste',
153 author_email = 'juri@iki.fi',
154 maintainer = 'Jan Alonzo',
155 maintainer_email = 'jmalonzo@unpluggable.com',
156 url = 'http://www.gnome.org/projects/straw/',
157 license = 'GPL',
158 data_files = data_files(),
159 pot_file = 'po/straw.pot',
160 translations = translations(),
161 modules_check = modules_check,
162 msg_sources = translation_files(),
163 desktop_file = ['straw.desktop.in'],
164 constants = [('constants.py.in', strawenv)],
165 scripts = ['src/straw'],
166 packages = ['straw'],
167 package_dir = {'straw' : 'src/lib'},
168 config_files = [('gconf/schemas',['data/straw.schemas'],
169 'with-gconf-schema-file-dir')],
170 classifiers = filter(None, classifiers.split("\n")))