File: setup.py

package info (click to toggle)
straw 0.27-0.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,972 kB
  • ctags: 2,318
  • sloc: python: 13,450; ansic: 107; makefile: 21
file content (170 lines) | stat: -rwxr-xr-x 5,932 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#! /usr/bin/env python
"""Straw: A feed aggregator for open source desktops.

Straw is a feed aggregator for open source desktops. Its goal is to be a
faster, easier, and more accessible way to read news and blogs than the
web browser. It uses the Python bindings to the GTK+ toolkit and supports RSS
and ATOM feeds.
"""

classifiers = """\
Development Status :: 4 - Beta
Environment :: X11 Applications :: GTK
Environment :: X11 Applications :: Gnome
Intended Audience :: End Users/Desktop
License :: OSI Approved :: GNU General Public License (GPL)
Operating System :: POSIX
Operating System :: POSIX :: Linux
Programming Language :: Python
Topic :: Desktop Environment
Topic :: Desktop Environment :: Gnome
Topic :: Internet :: WWW/HTTP
"""

import sys
import glob
import os.path

strawenv = {'APPNAME': 'Straw',
            'VERSION': '0.27',
            'PYTHON':  '2.4',
            'PYGTK': (2,8,0)}

if sys.version < strawenv['PYTHON']:
    sys.exit('Error: %s or newer is required. Current version:\n %s'
             % (strawenv['PYTHON'],sys.version))

doclines = __doc__.split("\n")

def modules_check():
    '''Check if necessary modules is installed.
    The function is executed by distutils (by the install command).'''
    # Set This For Machines with No DISPLAY
    nogtk = 0

    import imp
    # Check for PyGTK version
    try:
        import pygtk
        pygtk.require('2.0')
        imp.find_module('gtk')
        import gtk
        if gtk.pygtk_version < strawenv['PYGTK']:
            raise
    except AssertionError:
        pass # We ignore this because gtk must be present to build"
    except RuntimeError, msg:
        if os.environ.get ('DISPLAY', '') != '':
            etype, value, tb = sys.exc_info ()
            traceback.print_exception (etype, value, tb)

            sys.exit('Error: unexpected runtime error checking for gtk module')
	nogtk = 1
        pass # No DISPLAY set, pass
    except:
        sys.exit('Error: PyGTK-%d.%d.%d or newer is required.' % strawenv['PYGTK'])

    # Check other module requirements.
    # In pygtk versions prior to 2.10, gtkhtml2 is included in
    # the 'gnome' module. But as of 2.10, the gtkhtml2 module was
    # removed in 'gnome' and added in 'gnome-extras' module.
    # The egg.trayicon module is also included in g-p-e, so no need to check here.
    mod_list = [
        ('gnome', 'python-gnome2', 0),
        ('gtkhtml2', "python-gnome2-extras", 0),
        ('gconf', "python-gnome2", 1),
        ('bsddb.db', 'python-bsddb', 0),
        ('dbus', 'python-dbus', 0)]

    for m, w, x in mod_list:
	if nogtk == 1 and m == 'gtkhtml2':
	    pass;
	else:
            try:
                if not x: exec('import %s' % m)
                else: imp.find_module(m)
            except ImportError, msg:
                sys.exit("Error: '%s' module in package '%s' is required to install %s" \
                      % (m,w,strawenv['APPNAME']))

    # Check for dbus version
    if getattr(dbus, 'version', None) is None:
        print "Warning: Recent versions of  DBus is needed to run Straw"

    # gtk.glade needs special care (ugly...)
    path = imp.find_module('gtk')
    if not os.path.exists(path[1] + '/glade.so'):
        sys.exit('Error: %s module is required to install %s' \
                 % ("PyGTK's glade", strawenv['APPNAME']))

    # Check for ADNS
    try:
        import adns, ADNS
    except ImportError:
        print 'Warning: ADNS Python module not found, will continue without.'

def translations():
    '''Build mo-po mapping from po directory'''
    trans = []
    dest = 'share/locale/%s/LC_MESSAGES/%s.mo'
    for po in glob.glob('po/*.po'):
        lang = os.path.splitext(os.path.basename(po))[0]
        trans.append((dest % (lang , strawenv['APPNAME'].lower()), po))
    return trans

def translation_files():
    '''Files for translation...'''
    potfile = './po/POTFILES.in'
    if not os.path.exists(potfile):
        sys.exit("No such file, '%s'. This file should've been built \
        automatically. You can run \"intltool-update --pot\" to create it manually.\
        We also encourage you to file a bug report against Straw." % potfile)
    try:
        f = open(potfile)
        files = []
        for line in f:
            # ignore comments and newline
            if not line.startswith('#') or not line.startswith('\n'):
                files.append(line.strip())
    finally:
        f.close()
    return files

def data_files():
    '''Build list of data files to be installed'''
    images = glob.glob('images/*.png')
    misc = [
        'data/default_subscriptions.opml',
        'data/straw.css',
        'glade/straw.glade'
        ]
    files = [
        ('share/pixmaps', ['images/straw.png']),
        ('share/straw', images + misc)]
    return files

# Let distutils do the work
from tools.straw_distutils import setup
setup(name             = strawenv['APPNAME'],
      version          = strawenv['VERSION'],
      description      = doclines[0],
      long_description = "\n".join(doclines[2:]),
      author           = 'Juri Pakaste',
      author_email     = 'juri@iki.fi',
      maintainer       = 'Jan Alonzo',
      maintainer_email = 'jmalonzo@unpluggable.com',
      url              = 'http://www.gnome.org/projects/straw/',
      license          = 'GPL',
      data_files       = data_files(),
      pot_file         = 'po/straw.pot',
      translations     = translations(),
      modules_check    = modules_check,
      msg_sources      = translation_files(),
      desktop_file     = ['straw.desktop.in'],
      constants        = [('constants.py.in', strawenv)],
      scripts          = ['src/straw'],
      packages         = ['straw'],
      package_dir      = {'straw' : 'src/lib'},
      config_files     = [('gconf/schemas',['data/straw.schemas'],
                         'with-gconf-schema-file-dir')],
      classifiers      = filter(None, classifiers.split("\n")))