Use $EXTERNAL_STORAGE on Android (bug 1290)
[gpodder.git] / setup.py
blobf3a9b41d1d740ac8eee56362fcc7f1420d675139
1 #!/usr/bin/env python
4 # gPodder - A media aggregator and podcast client
5 # Copyright (c) 2005-2011 Thomas Perl and the gPodder Team
7 # gPodder is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # gPodder is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 import glob
22 import os
23 import re
24 import sys
25 from distutils.core import setup
27 # build targets
28 (DEFAULT, MAEMO) = range(2)
30 # import the gpodder module locally for module metadata
31 sys.path.insert(0, 'src')
32 import gpodder
34 # if we are running "setup.py sdist", include all targets (see below)
35 building_source = ('sdist' in sys.argv)
37 # build target
38 if 'TARGET' in os.environ:
39 if os.environ['TARGET'].strip().lower() == 'maemo':
40 target = MAEMO
41 else:
42 target = DEFAULT
44 # search for translations, taking $LINGUAS into account
45 translation_files = []
46 linguas = os.environ.get('LINGUAS', None)
47 if linguas is not None:
48 linguas = linguas.split()
50 for mofile in glob.glob('data/locale/*/LC_MESSAGES/gpodder.mo'):
51 _, _, lang, _ = mofile.split('/', 3)
53 # Only install if either $LINGUAS it not set or the
54 # language is specified in the $LINGUAS variable
55 if linguas is None or lang in linguas:
56 modir = os.path.dirname(mofile).replace('data', 'share')
57 translation_files.append((modir, [mofile]))
59 if not len(translation_files) and \
60 'clean' not in sys.argv and \
61 linguas not in (None, []):
62 print >>sys.stderr, """
63 Warning: No translation files. (Did you forget to run "make messages"?)
64 """
66 DBUS_SERVICE_FILE = 'data/org.gpodder.service'
68 if not os.path.exists(DBUS_SERVICE_FILE) and \
69 'clean' not in sys.argv:
70 print >>sys.stderr, """
71 Warning: D-Bus service file not found. This usually means that you
72 used setup.py directly. The recommended way is to use "make install",
73 which will generate the prerequisites and then call setup.py.
75 Using "make install" will also allow you to set DESTDIR and PREFIX.
76 """
79 # files to install
80 inst_manpages = glob.glob( 'doc/man/*.1')
81 inst_share_ui = glob.glob('data/ui/*.ui')
82 inst_share_ui_desktop = glob.glob('data/ui/desktop/*.ui')
83 inst_share_ui_maemo = glob.glob('data/ui/maemo/*.ui')
84 inst_share_ui_frmntl = glob.glob('data/ui/frmntl/*.ui')
85 inst_share_gpodder = [ 'data/credits.txt' ] + glob.glob('data/images/*.png')
86 inst_desktop = [ 'data/gpodder.desktop' ]
87 inst_desktop_maemo = [ 'data/maemo/gpodder.desktop' ]
88 inst_share_dbus_services = [ DBUS_SERVICE_FILE ]
90 inst_icons = [ 'data/gpodder.png' ]
91 inst_icons_64 = [ 'data/icons/64/gpodder.png' ]
92 inst_icons_40 = [ 'data/icons/40/gpodder.png' ]
93 inst_icons_32 = [ 'data/icons/32/gpodder.png' ]
94 inst_icons_26 = [ 'data/icons/26/gpodder.png' ]
95 inst_icons_24 = [ 'data/icons/24/gpodder.png' ]
96 inst_icons_22 = [ 'data/icons/22/gpodder.png' ]
97 inst_icons_16 = [ 'data/icons/16/gpodder.png' ]
98 inst_icons_svg = [ 'data/gpodder.svg' ]
100 data_files = [
101 ('share/man/man1', inst_manpages),
102 ('share/gpodder/ui', inst_share_ui),
103 ('share/pixmaps', inst_icons),
104 ('share/gpodder', inst_share_gpodder),
105 ('share/dbus-1/services',inst_share_dbus_services),
108 packages = [
109 'gpodder',
110 'gpodder.gtkui',
111 'gpodder.gtkui.interface',
114 # target-specific installation data files
115 if target == DEFAULT or building_source:
116 data_files += [
117 ('share/gpodder/ui/desktop', inst_share_ui_desktop),
118 ('share/applications', inst_desktop),
119 ('share/icons/hicolor/scalable/apps', inst_icons_svg),
120 ('share/icons/hicolor/48x48/apps', inst_icons),
121 ('share/icons/hicolor/24x24/apps', inst_icons_24),
122 ('share/icons/hicolor/22x22/apps', inst_icons_22),
123 ('share/icons/hicolor/16x16/apps', inst_icons_16),
125 packages += [
126 'gpodder.gtkui.desktop',
128 additional_scripts = []
130 if target == MAEMO or building_source:
131 data_files += [
132 ('share/gpodder/ui/maemo', inst_share_ui_maemo),
133 ('share/gpodder/ui/frmntl', inst_share_ui_frmntl),
134 ('share/applications/hildon', inst_desktop_maemo),
135 ('share/icons/hicolor/scalable/apps', inst_icons_64),
136 ('share/icons/hicolor/40x40/apps', inst_icons_40),
137 ('share/icons/hicolor/32x32/apps', inst_icons_32),
138 ('share/icons/hicolor/26x26/apps', inst_icons_26),
139 ('share/icons/hicolor/16x16/apps', inst_icons_16),
141 packages += [
142 'gpodder.gtkui.maemo',
143 'gpodder.gtkui.frmntl',
145 additional_scripts = [
146 'data/maemo/gpodder-mplayer',
149 author, email = re.match(r'^(.*) <(.*)>$', gpodder.__author__).groups()
151 setup(
152 name = 'gpodder',
153 version = gpodder.__version__,
154 package_dir = { '':'src' },
155 packages = packages,
156 description = 'media aggregator',
157 author = author,
158 author_email = email,
159 url = gpodder.__url__,
160 scripts = glob.glob('bin/*') + additional_scripts,
161 data_files = data_files + translation_files