Updated Spanish translation
[straw.git] / setup.py
blobdde3aa63ee77204173203c593d23bdf99e5473ef
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
27 from os.path import splitext, exists, join
29 strawenv = {'APPNAME': 'Straw',
30 'VERSION': '0.28-dev',
31 'PYTHON': '2.4',
32 'PYGTK': (2,10,0)}
35 pyver = float(sys.version.split()[0][:3])
36 if pyver < float(strawenv["PYTHON"]):
37 sys.exit('Error: %s or newer is required. Current version:\n %s'
38 % (strawenv['PYTHON'],pyver))
40 doclines = __doc__.split("\n")
42 def modules_check():
43 '''Check if necessary modules is installed.
44 The function is executed by distutils (by the install command).'''
46 # Check other module requirements.
47 # In pygtk versions prior to 2.10, gtkhtml2 is included in
48 # the 'gnome' module. But as of 2.10, the gtkhtml2 module was
49 # removed in 'gnome' and added in 'gnome-extras' module.
50 # The egg.trayicon module is also included in g-p-e, so no need to check here.
51 mod_list = [
52 ('gtk', 'pygtk2', 0),
53 ('gnome', 'python-gnome2', 0),
54 ('gtkhtml2', "python-gnome2-extras", 0),
55 ('dbus', 'python-dbus', 0)]
57 for m, w, x in mod_list:
58 try:
59 if not x: exec('import %s' % m)
60 else: imp.find_module(m)
61 except ImportError, msg:
62 sys.exit("Error: '%s' module in package '%s' is required to install %s" \
63 % (m,w,strawenv['APPNAME']))
65 def translations():
66 '''Build mo-po mapping from po directory'''
67 trans = []
68 dest = 'share/locale/%s/LC_MESSAGES/%s.mo'
69 for po in glob.glob('po/*.po'):
70 lang = splitext(os.path.basename(po))[0]
71 trans.append((dest % (lang , strawenv['APPNAME'].lower()), po))
72 return trans
74 def translation_files():
75 '''Files for translation...'''
76 potfile = './po/POTFILES.in'
77 if not exists(potfile):
78 sys.exit("No such file, '%s'. This file should've been built \
79 automatically. You can run \"intltool-update --pot\" to create it manually.\
80 We also encourage you to file a bug report against Straw." % potfile)
81 try:
82 f = open(potfile)
83 files = []
84 for line in f:
85 # ignore comments and newline
86 if not line.startswith('#') or not line.startswith('\n'):
87 files.append(line.strip())
88 finally:
89 f.close()
90 return files
92 def data_files():
93 '''Build list of data files to be installed'''
94 images = glob.glob('data/*.svg')
95 images.append('data/straw.png')
96 misc = [
97 'data/default_subscriptions.opml',
98 'data/straw.css',
99 'data/straw.glade'
101 files = [
102 ('share/pixmaps', ['data/straw.png']),
103 ('share/straw', images + misc)]
104 return files
106 # Let distutils do the work
107 from tools.straw_distutils import setup
108 setup(
109 requires = ['adns'],
110 name = strawenv['APPNAME'],
111 version = strawenv['VERSION'],
112 description = doclines[0],
113 long_description = "\n".join(doclines[2:]),
114 author = 'Juri Pakaste',
115 author_email = 'juri@iki.fi',
116 maintainer = 'Jan Alonzo',
117 maintainer_email = 'jmalonzo@unpluggable.com',
118 url = 'http://www.gnome.org/projects/straw/',
119 license = 'GPL',
120 data_files = data_files(),
121 pot_file = 'po/straw.pot',
122 translations = translations(),
123 modules_check = modules_check,
124 msg_sources = translation_files(),
125 desktop_file = ['straw.desktop.in'],
126 constants = [('constants.py.in', strawenv)],
127 scripts = ['src/straw'],
128 packages = ['straw','straw.httplib2'],
129 package_dir = {'straw' : 'src/lib', 'straw.httplib2' : 'src/lib/httplib2'},
130 config_files = [('gconf/schemas',['data/straw.schemas'],
131 'with-gconf-schema-file-dir')],
132 classifiers = filter(None, classifiers.split("\n")))