Menu

[r3770]: / branches / mathtext_mgd / setup.py  Maximize  Restore  History

Download this file

324 lines (262 with data), 10.2 kB

  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
319
320
321
322
323
"""
Note! If you are building for python2.2, you must comment out the
py_modules line below and manually copy lib/pylab.py to
site-packages/pylab.py
You will need to have freetype, libpng and zlib installed to compile
matplotlib, inlcuding the *-devel versions of these libraries if you
are using a package manager like RPM or debian.
matplotlib has added some extension module code which can optionally
be built by setting the appropriate flag below.
The GTKAgg and TkAgg will try to build if they detect pygtk or Tkinter
respectively; set them to 0 if you do not want to build them
"""
rc = {'backend':'PS', 'numerix':'numpy'}
# build the image support module - requires agg and Numeric or
# numarray. You can build the image module with either Numeric or
# numarray or both. By default, matplotlib will build support for
# whatever array packages you have installed.
BUILD_IMAGE = 1
# Build the antigrain geometry toolkit. Agg makes heavy use of
# templates, so it probably requires a fairly recent compiler to build
# it. It makes very nice antialiased output and also supports alpha
# blending
BUILD_AGG = 1
BUILD_GTKAGG = 'auto'
BUILD_GTK = 'auto'
# build TK GUI with Agg renderer ; requires Tkinter Python extension
# and Tk includes
# Use False or 0 if you don't want to build
BUILD_TKAGG = 'auto'
# build wxPython extension code to efficiently blit agg into wx. Only
# needed for wxpython <2.8 if you plan on doing animations
BUILD_WXAGG = 0
# build a small extension to manage the focus on win32 platforms.
#BUILD_WINDOWING = 0
BUILD_WINDOWING = 'auto'
VERBOSE = False # insert lots of diagnostic prints in extension code
## You shouldn't need to customize below this point
# BEFORE importing disutils, remove MANIFEST. distutils doesn't properly
# update it when the contents of directories change.
import os
if os.path.exists('MANIFEST'): os.remove('MANIFEST')
import sys
major, minor1, minor2, s, tmp = sys.version_info
if major==2 and minor1==2:
print >> sys.stderr, "***\n\nWARNING, see build info for python2.2 in the header of setup.py\n\n***"
if major==2 and minor1<=3:
# setuptools monkeypatches distutils.core.Distribution to support
# package_data
try: import setuptools
except ImportError:
raise SystemExit("""\
matplotlib requires setuptools for installation. Visit:
http://cheeseshop.python.org/pypi/setuptools
for installation instructions for the proper version of setuptools for your
system. If this is your first time upgrading matplotlib with the new
setuptools requirement, you must delete the old matplotlib install
directory.""")
import glob
from distutils.core import Extension, setup
from setupext import build_agg, build_gtkagg, build_tkagg, build_wxagg,\
build_ft2font, build_image, build_windowing, build_transforms, \
build_contour, build_nxutils, build_enthought, build_swigagg, build_gdk, \
build_subprocess, build_isnan, build_ttconv
import distutils.sysconfig
for line in file('lib/matplotlib/__init__.py').readlines():
if line[:11] == '__version__':
exec(line.strip())
# Specify all the required mpl data
package_data = {'matplotlib':['mpl-data/fonts/afm/*.afm',
'mpl-data/fonts/pdfcorefonts/*.afm',
'mpl-data/fonts/pdfcorefonts/*.txt',
'mpl-data/fonts/ttf/*.ttf',
'mpl-data/images/*.xpm',
'mpl-data/images/*.svg',
'mpl-data/images/*.png',
'mpl-data/images/*.ppm',
'mpl-data/matplotlibrc',
'mpl-data/*.glade',
'backends/Matplotlib.nib/*',
]}
# The NUMERIX variable (a list) is left over from the days when it had
# a string for each of the supported backends. Now there is only one
# supported backend, so this approach could (should?) get changed for
# simplicity.
try:
import numpy
NUMERIX = ['numpy']
except ImportError:
raise RuntimeError("You must install numpy to build matplotlib")
rc['numerix'] = NUMERIX[-1]
ext_modules = []
# these are not optional
BUILD_FT2FONT = 1
BUILD_TTCONV = 1
BUILD_CONTOUR = 1
BUILD_NXUTILS = 1
# jdh
packages = [
'matplotlib',
'matplotlib.backends',
'matplotlib.toolkits',
'matplotlib.numerix',
'matplotlib.numerix.mlab',
'matplotlib.numerix.ma',
'matplotlib.numerix.npyma',
'matplotlib.numerix.linear_algebra',
'matplotlib.numerix.random_array',
'matplotlib.numerix.fft',
]
try: import subprocess
except ImportError: havesubprocess = False
else: havesubprocess = True
if havesubprocess and sys.version < '2.4':
# Python didn't come with subprocess, so let's make sure it's
# not in some Python egg (e.g. an older version of matplotlib)
# that may get removed.
subprocess_dir = os.path.dirname(subprocess.__file__)
if subprocess_dir.endswith('.egg/subprocess'):
havesubprocess = False
if not havesubprocess:
packages.append('subprocess')
if sys.platform == 'win32':
build_subprocess(ext_modules, packages)
build_isnan(ext_modules, packages)
try: import datetime
except ImportError: havedate = False
else: havedate = True
if havedate: # dates require python23 datetime
# only install pytz and dateutil if the user hasn't got them
def add_pytz():
packages.append('pytz')
# install pytz subdirs
for dirpath, dirname, filenames in os.walk(os.path.join('lib', 'pytz','zoneinfo')):
if '.svn' not in dirpath:
packages.append('/'.join(dirpath.split(os.sep)[1:]))
def add_dateutil():
packages.append('dateutil')
if sys.platform=='win32':
# always add these to the win32 installer
add_pytz()
add_dateutil()
else:
# only add them if we need them
try: import dateutil
except ImportError:
add_dateutil()
try: import pytz
except ImportError:
add_pytz()
build_swigagg(ext_modules, packages)
build_transforms(ext_modules, packages, NUMERIX)
build_enthought(ext_modules, packages)
def havegtk():
'check for the presence of pygtk'
if havegtk.gotit is not None: return havegtk.gotit
try:
import gtk
except ImportError:
print 'building for GTK requires pygtk; you must be able to "import gtk" in your build/install environment'
havegtk.gotit = False
except RuntimeError:
print 'pygtk present but import failed'
havegtk.gotit = False
else:
version = (2,2,0)
if gtk.pygtk_version < version:
print "Error: GTK backend requires PyGTK %d.%d.%d (or later), " \
"%d.%d.%d was detected." % (
version + gtk.pygtk_version)
havegtk.gotit = False
else:
havegtk.gotit = True
return havegtk.gotit
havegtk.gotit = None
if BUILD_GTK and havegtk():
build_gdk(ext_modules, packages, NUMERIX)
rc['backend'] = 'GTK'
if BUILD_GTKAGG and havegtk():
BUILD_AGG = 1
build_gtkagg(ext_modules, packages, NUMERIX)
rc['backend'] = 'GTKAgg'
if BUILD_TKAGG:
try:
import Tkinter
except ImportError:
print 'TKAgg requires TkInter'
BUILD_TKAGG = 0
except RuntimeError:
print 'Tkinter present but import failed'
BUILD_TKAGG = 0
else:
try:
tk = Tkinter.Tk()
tk.withdraw()
except Tkinter.TclError:
print 'Tkinter present, but window failed to open'
BUILD_TKAGG = 0
else:
BUILD_AGG = 1
build_tkagg(ext_modules, packages, NUMERIX)
rc['backend'] = 'TkAgg'
if BUILD_WXAGG:
try:
import wx
except ImportError:
if BUILD_WXAGG != 'auto':
print 'WXAgg\'s accelerator requires wxPython'
BUILD_WXAGG = 0
else:
if getattr(wx, '__version__', '0.0')[0:3] < '2.8':
BUILD_AGG = 1
build_wxagg(ext_modules, packages, NUMERIX,
not (isinstance(BUILD_WXAGG, str) # don't abort if BUILD_WXAGG
and BUILD_WXAGG.lower() == 'auto')) # is "auto"
rc['backend'] = 'WXAgg'
if BUILD_AGG:
build_agg(ext_modules, packages, NUMERIX)
if rc['backend'] == 'PS': rc['backend'] = 'Agg'
if BUILD_FT2FONT:
build_ft2font(ext_modules, packages)
if BUILD_TTCONV:
build_ttconv(ext_modules, packages)
if BUILD_WINDOWING and sys.platform=='win32':
build_windowing(ext_modules, packages)
if BUILD_IMAGE:
build_image(ext_modules, packages, NUMERIX)
if 1: # I don't think we need to make these optional
build_contour(ext_modules, packages)
build_nxutils(ext_modules, packages)
for mod in ext_modules:
if VERBOSE:
mod.extra_compile_args.append('-DVERBOSE')
# packagers: set rc['numerix'] and rc['backend'] here to override the auto
# defaults, eg
#rc['numerix'] = numpy
#rc['backend'] = GTKAgg
if sys.platform=='win32':
rc = dict(backend='TkAgg', numerix='numpy')
template = file('matplotlibrc.template').read()
file('lib/matplotlib/mpl-data/matplotlibrc', 'w').write(template%rc)
try: additional_params # has setupegg.py provided
except NameError: additional_params = {}
distrib = setup(name="matplotlib",
version= __version__,
description = "Matlab(TM) style python plotting package",
author = "John D. Hunter",
author_email="jdhunter@ace.bsd.uchicago.edu",
url = "http://matplotlib.sourceforge.net",
long_description = """
matplotlib strives to produce publication quality 2D graphics
using matlab plotting for inspiration. Although the main lib is
object oriented, there is a functional interface "pylab"
for people coming from Matlab.
""",
packages = packages,
platforms='any',
py_modules = ['pylab'],
ext_modules = ext_modules,
package_dir = {'': 'lib'},
package_data = package_data,
**additional_params
)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.