forked from mate-desktop-legacy-archive/python-mate
/
setup.py
executable file
·318 lines (282 loc) · 14 KB
/
setup.py
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
#!/usr/bin/env python
#
# setup.py - distutils configuration for pygtk
#
# TODO:
# pygtk.spec(.in)
# win32 testing
# install *.pyc for codegen
#
"""Python Bindings for Mate.
TODO: Write a good long description"""
from distutils.command.build import build
from distutils.core import setup
import os
import sys
sys.stderr.write('''-- WARNING --
The distutils method (setup.py) of building mate-python is not
supported. setup.py is *unmaintained* and therefore not up-to-date
with the latest developments. Use at your own risk.
--
''')
try:
import pygtk
pygtk.require('2.0')
except (ImportError, AssertionError):
raise SystemExit, 'ERROR: Could not find a recent version of pygtk.'
from dsextras import list_files, have_pkgconfig, GLOBAL_INC, GLOBAL_MACROS
from dsextras import InstallLib, BuildExt, PkgConfigExtension
from dsextras import Template, TemplateExtension, pkgc_version_check
from dsextras import getoutput
MAJOR_VERSION = 2
MINOR_VERSION = 5
MICRO_VERSION = 91
VERSION = "%d.%d.%d" % (MAJOR_VERSION,
MINOR_VERSION,
MICRO_VERSION)
PYGTK_REQUIRED_VERSION = '2.0.0'
PYMATECORBA_REQUIRED_VERSION = '1.1.0'
LIBMATE_REQUIRED_VERSION = '1.1.0'
LIBMATEUI_REQUIRED_VERSION = '1.1.0'
LIBMATECANVAS_REQUIRED_VERSION = '1.1.0'
LIBZVT_REQUIRED_VERSION = '2.0.0'
MATECONF_REQUIRED_VERSION = '1.1.0'
MATECOMPONENT_ACTIVATION_REQUIRED_VERSION = '1.1.0'
LIBMATECOMPONENT_REQUIRED_VERSION = '1.1.0'
LIBMATECOMPONENTUI_REQUIRED_VERSION = '1.1.0'
LIBCAJA_REQUIRED_VERSION = '1.1.0'
LIBPANELAPPLET_REQUIRED_VERSION = '1.1.0'
GTKHTML2_REQUIRED_VERSION = '2.0.0'
LIBMATEPRINT_REQUIRED_VERSION = '1.1.0'
LIBMATEPRINTUI_REQUIRED_VERSION = '1.1.0'
PYGTK_SUFFIX = '2.0'
PYGTK_SUFFIX_LONG = 'gtk-' + PYGTK_SUFFIX
GLOBAL_INC += ['mateconf', 'mate', 'mateprint']
DEFS_DIR = os.path.join('share', 'pygtk', PYGTK_SUFFIX, 'defs')
CODEGEN_DIR = os.path.join('share', 'pygtk', PYGTK_SUFFIX, 'codegen')
INCLUDE_DIR = os.path.join('include', 'pygtk-%s' % PYGTK_SUFFIX)
str_version = sys.version[:3]
version = map(int, str_version.split('.'))
if version < [2, 2]:
raise SystemExit, \
"Python 2.2 or higher is required, %s found" % str_version
class MatePythonInstallLib(InstallLib):
def run(self):
self.add_template_option('VERSION', VERSION)
self.prepare()
self.install_template('mate-python-2.0.pc.in',
os.path.join(self.libdir, 'pkgconfig'))
# Modify the base installation dir
install_dir = os.path.join(self.install_dir, PYGTK_SUFFIX_LONG)
self.set_install_dir(install_dir)
InstallLib.run(self)
if not pkgc_version_check('pygtk-2.0', 'PyGTK', PYGTK_REQUIRED_VERSION):
raise SystemExit, "Aborting"
pygtkincludedir = getoutput('pkg-config --variable pygtkincludedir pygtk-2.0')
codegendir = getoutput('pkg-config --variable codegendir pygtk-2.0')
defsdir = getoutput('pkg-config --variable defsdir pygtk-2.0')
GLOBAL_INC.append(pygtkincludedir)
GTKDEFS = [os.path.join(defsdir, 'pango-types.defs'),
os.path.join(defsdir, 'gdk-types.defs'),
os.path.join(defsdir, 'gtk-types.defs')]
MATECOMPONENTDEFS = [os.path.join('matecomponent', 'matecomponent-types.defs'),
os.path.join('matecomponent', 'matecomponentui-types.defs')]
CANVASDEFS = [os.path.join('mate', 'canvas.defs')]
sys.path.append(codegendir)
try:
from override import Overrides
except ImportError:
raise SystemExit, \
'Could not find code generator in %s, do you have installed pygtk correctly?'
have_pymatecorba = pkgc_version_check('pymatecorba-2', 'PyMateCORBA.',
PYMATECORBA_REQUIRED_VERSION)
if have_pymatecorba:
includedir = getoutput('pkg-config --variable includedir pymatecorba-2')
GLOBAL_INC.append(os.path.join(includedir, 'pymatecorba-2'))
libmate = TemplateExtension(name='mate', pkc_name='libmate-2.0',
pkc_version=LIBMATE_REQUIRED_VERSION,
output='mate._mate',
defs='mate/mate.defs',
sources=['mate/matemodule.c',
'mate/mate.c'],
register=GTKDEFS+['mate/mate.defs'],
override='mate/mate.override')
libmateui = TemplateExtension(name='ui', pkc_name='libmateui-2.0',
pkc_version=LIBMATEUI_REQUIRED_VERSION,
output='mate.ui',
defs='mate/ui.defs',
sources=['mate/uimodule.c',
'mate/ui.c'],
register=GTKDEFS+MATECOMPONENTDEFS + \
['mate/mate.defs',
'mate/ui.defs'],
override='mate/ui.override')
libmatecanvas = TemplateExtension(name='canvas',
pkc_name='libmatecanvas-2.0',
pkc_version=LIBMATECANVAS_REQUIRED_VERSION,
output='mate.canvas',
defs='mate/canvas.defs',
sources=['mate/canvasmodule.c',
'mate/canvas.c'],
register=['mate/canvas.defs'],
override='mate/canvas.override')
libzvt = TemplateExtension(name='zvt',
pkc_name='libzvt-2.0',
pkc_version=LIBZVT_REQUIRED_VERSION,
output='mate.zvt',
defs='mate/zvt.defs',
sources=['mate/zvtmodule.c',
'mate/zvt.c'],
register=['mate/zvt.defs'],
override='mate/zvt.override')
mateconf = TemplateExtension(name='mateconf',
pkc_name='mateconf-2.0',
pkc_version=MATECONF_REQUIRED_VERSION,
output='mate.mateconf',
defs='mateconf/mateconf.defs',
sources=['mateconf/mateconfmodule.c',
'mateconf/mateconf-fixes.c',
'mateconf/mateconf.c'],
register=['mateconf/mateconf.defs'],
override='mateconf/mateconf.override')
matecomponent_activation = PkgConfigExtension(name='matecomponent.activation',
pkc_name='matecomponent-activation-2.0',
pkc_version=MATECOMPONENT_ACTIVATION_REQUIRED_VERSION,
sources=['matecomponent/activationmodule.c'])
libmatecomponent = TemplateExtension(name='matecomponent',
pkc_name='libmatecomponent-2.0',
pkc_version=LIBMATECOMPONENT_REQUIRED_VERSION,
output='matecomponent._matecomponent',
defs='matecomponent/matecomponent.defs',
sources=['matecomponent/matecomponentmodule.c',
'matecomponent/matecomponent-arg.c',
'matecomponent/matecomponent.c'],
register=MATECOMPONENTDEFS + \
['matecomponent/matecomponentui.defs'],
load_types='matecomponent/matecomponent-arg-types.py',
override='matecomponent/matecomponent.override')
libmatecomponentui = TemplateExtension(name='matecomponentui',
pkc_name='libmatecomponentui-2.0',
pkc_version=LIBMATECOMPONENTUI_REQUIRED_VERSION,
output='matecomponent.ui',
defs='matecomponent/matecomponentui.defs',
sources=['matecomponent/matecomponentuimodule.c',
'matecomponent/matecomponentui.c'],
register=GTKDEFS + CANVASDEFS + \
MATECOMPONENTDEFS + \
['matecomponent/matecomponentui.defs'],
load_types='matecomponent/matecomponent-arg-types.py',
override='matecomponent/matecomponentui.override')
libcaja = TemplateExtension(name='caja',
pkc_name='libcaja',
pkc_version=LIBCAJA_REQUIRED_VERSION,
output='mate.caja',
defs='mate/caja.defs',
sources=['mate/cajamodule.c',
'mate/caja.c'],
register=['mate/caja.defs'],
override='mate/caja.override')
libmatepanelapplet = TemplateExtension(name='applet',
pkc_name='libmatepanelapplet-2.0',
pkc_version=LIBPANELAPPLET_REQUIRED_VERSION,
output='mate.applet',
defs='mate/applet.defs',
sources=['mate/appletmodule.c',
'mate/applet.c'],
register=['mate/applet.defs'],
override='mate/applet.override')
gtkhtml2 = TemplateExtension(name='gtkhtml2',
pkc_name='libgtkhtml-2.0',
pkc_version=GTKHTML2_REQUIRED_VERSION,
output='gtkhtml2',
defs='gtkhtml2/gtkhtml2.defs',
sources=['gtkhtml2/gtkhtml2module.c',
'gtkhtml2/gtkhtml2.c'],
register=['gtkhtml2/gtkhtml2.defs'],
override='gtkhtml2/gtkhtml2.override')
libmateprint = TemplateExtension(name='print',
pkc_name='libmateprint-2.2',
pkc_version=LIBMATEPRINT_REQUIRED_VERSION,
output='mateprint._print',
defs='mateprint/print.defs',
sources=['mateprint/printmodule.c',
'mateprint/print.c'],
register=GTKDEFS + ['mateprint/print.defs'],
override='mateprint/print.override')
libmateprintui = TemplateExtension(name='printui',
pkc_name='libmateprintui-2.2',
pkc_version=LIBMATEPRINTUI_REQUIRED_VERSION,
output='mateprint.printui',
defs='mateprint/printui.defs',
sources=['mateprint/printuimodule.c',
'mateprint/printui.c'],
register=GTKDEFS + CANVASDEFS + \
['mateprint/print.defs',
'mateprint/printui.defs'],
override='mateprint/printui.override')
data_files = []
ext_modules = []
py_modules = []
if libmate.can_build() or libmatecanvas.can_build():
py_modules.append('mate.__init__')
if libmate.can_build():
ext_modules.append(libmate)
data_files.append((DEFS_DIR, ('mate/mate.defs',)))
if have_pymatecorba and libmateui.can_build():
ext_modules.append(libmateui)
data_files.append((DEFS_DIR, ('mate/ui.defs',)))
if libmatecanvas.can_build():
ext_modules.append(libmatecanvas)
data_files.append((DEFS_DIR, ('mate/canvas.defs',)))
if libzvt.can_build():
ext_modules.append(libzvt)
data_files.append((DEFS_DIR, ('mate/zvt.defs',)))
if mateconf.can_build():
ext_modules.append(mateconf)
data_files.append((DEFS_DIR, ('mateconf/mateconf.defs',)))
if have_pymatecorba and matecomponent_activation.can_build():
ext_modules.append(matecomponent_activation)
if have_pymatecorba and libmatecomponent.can_build():
ext_modules.append(libmatecomponent)
data_files.append((DEFS_DIR, ('matecomponent/matecomponent.defs',
'matecomponent/matecomponent-types.defs')))
if have_pymatecorba and libmatecomponentui.can_build():
ext_modules.append(libmatecomponentui)
data_files.append((DEFS_DIR, ('matecomponent/matecomponentui.defs',
'matecomponent/matecomponentui-types.defs')))
if libcaja.can_build():
ext_modules.append(libcaja)
data_files.append((DEFS_DIR, ('mate/caja.defs',)))
if libmatepanelapplet.can_build():
ext_modules.append(libmatepanelapplet)
data_files.append((DEFS_DIR, ('mate/applet.defs',)))
if gtkhtml2.can_build():
ext_modules.append(gtkhtml2)
data_files.append((DEFS_DIR, ('gtkhtml2/gtkhtml2.defs',)))
if libmateprint.can_build():
ext_modules.append(libmateprint)
data_files.append((DEFS_DIR, ('mateprint/print.defs',)))
py_modules.append('mateprint.__init__')
if libmateprintui.can_build():
ext_modules.append(libmateprintui)
data_files.append((DEFS_DIR, ('mateprint/printui.defs',)))
# Install matecomponent/__init__.py
if have_pymatecorba and (matecomponent_activation.can_build() or
libmatecomponent.can_build() or
libmatecomponentui.can_build()):
py_modules.append('matecomponent.__init__')
doclines = __doc__.split("\n")
setup(name="mate-python",
url='http://www.daa.com.au/~james/mate/',
version=VERSION,
license='LGPL',
platforms=['yes'],
maintainer="James Henstridge",
maintainer_email="james@daa.com.au",
description = doclines[0],
long_description = "\n".join(doclines[2:]),
py_modules=py_modules,
ext_modules=ext_modules,
data_files=data_files,
cmdclass={'install_lib': MatePythonInstallLib,
'build_ext': BuildExt })