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
|
#! /usr/bin/env python
#
# setup.py for Straw
#
#
import imp
import sys
import glob
import os.path
from tools.straw_distutils import setup
try:
from dsextras import TemplateExtension, getoutput, GLOBAL_MACROS
except ImportError:
try:
from gtk.dsextras import TemplateExtension, getoutput, GLOBAL_MACROS
except ImportError:
sys.exit('Error: Can not find dsextras or gtk.dsextras')
name = 'straw'
version = '0.25.1'
# Check for Python < 2.2
if sys.version < '2.2':
sys.exit('Error: Python-2.2 or newer is required. Current version:\n %s'
% sys.version)
def modules_check():
'''Check if necessary modules is installed.
The function is executed by distutils (by the install command).'''
try:
import pygtk
pygtk.require('2.0')
imp.find_module('gtk')
except AssertionError:
# We ignore this because gtk must be present to build"
pass
except:
sys.exit('Error: PyGTK-1.99.13 or newer is required.')
mod_list = [
('gnome', 'gnome', 0),
('gnome.vfs', "gnome", 0),
('gtkhtml2', "gtkhtml2", 1),
('gconf', "gconf", 0)]
if sys.version < '2.3':
mod_list.append(('bsddb3.db', 'bsddb3', 0))
ok = 1
for m, w, x in mod_list:
try:
if not x:
exec('import %s' % m)
else:
imp.find_module(m)
except ImportError:
ok = False
print 'Error: %s Python module is required to install %s' \
% (w, name.title())
try:
import adns, ADNS
except ImportError:
print 'Warning: ADNS Python module not found, will continue without.'
# gtk.glade needs special care (ugly...)
if ok:
path = imp.find_module('gtk')
if not os.path.exists(path[1] + '/glade.so'):
ok = False
print 'Error: %s module is required to install %s' \
% ("PyGTK's glade", name.title())
if not ok:
sys.exit(1)
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 , name), 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'. Please file a bug report.." % potfile)
f = open(potfile)
files = []
for line in f:
# ignore comments and newline
if line.startswith('#') or line.startswith('\n'):
continue
else: files.append(line.strip())
f.close()
return files
def data_files():
'''Build list of data files to be installed'''
images = glob.glob('images/*.png')
files = [
('share/pixmaps', ['images/straw.png']),
('share/straw', images + ['data/default_subscriptions.opml', 'data/straw.css', 'glade/straw.glade'])]
return files
long_desc = '''\
Straw is a desktop news aggregator for the GNOME environment.
Its aim is to be a faster, easier and more accessible way to read
news and blogs than the traditional browser.'''
#Stuff for dsextras to work properly
sys.path.insert(0, getoutput('pkg-config --variable=codegendir pygtk-2.0'))
GLOBAL_MACROS+=[('GETTEXT_PACKAGE','"straw"')]
# Let distutils do the work
setup(name = name,
version = version,
description = 'Desktop news aggregator for GNOME',
long_description = long_desc,
author = 'Juri Pakaste',
author_email = 'juri@iki.fi',
url = 'http://www.nongnu.org/straw/',
license = 'GPL',
data_files = data_files(),
pot_file = 'po/straw.pot',
translations = translations(),
#config_files = [('gconf/schemas',['data/straw.schemas'],
# 'with-gconf-schema-file-dir')],
scripts = ['src/straw'],
modules_check = modules_check,
packages = ['straw'],
package_dir = {'straw' : 'src/lib'},
msg_sources = translation_files(),
desktop_file = ['straw.desktop.in'],
ext_modules = [TemplateExtension(name='trayicon',
pkc_name='pygtk-2.0 gtk+-2.0',
pkc_version='2.0.0',
output='straw.pytrayicon',
defs='src/eggtray/trayicon.defs',
sources=['src/eggtray/trayiconmodule.c',
'src/eggtray/trayicon.c',
'src/eggtray/eggtrayicon.c'],
register=['src/eggtray/trayicon.defs'],
override='src/eggtray/trayicon.override')])
|