|
3 | 3 | matplotlib, inlcuding the *-devel versions of these libraries if you
|
4 | 4 | are using a package manager like RPM or debian.
|
5 | 5 |
|
6 |
| -matplotlib has added some extension module code which can optionally |
7 |
| -be built by setting the appropriate flag below. |
8 |
| -
|
9 |
| -The GTKAgg and TkAgg will try to build if they detect pygtk or Tkinter |
10 |
| -respectively; set them to 0 if you do not want to build them |
| 6 | +The matplotlib build options can be modified with a setup.cfg file. See |
| 7 | +setup.cfg.template for more information. |
11 | 8 | """
|
12 | 9 |
|
13 | 10 |
|
14 |
| -rc = {'backend':'PS', 'numerix':'numpy'} |
15 |
| - |
16 |
| -# build the image support module - requires agg. By default, matplotlib will |
17 |
| -# build support for whatever array packages you have installed. |
18 |
| -BUILD_IMAGE = 1 |
19 |
| - |
20 |
| - |
21 |
| -# build a small extension to manage the focus on win32 platforms. |
22 |
| -#BUILD_WINDOWING = 0 |
23 |
| -BUILD_WINDOWING = 'auto' |
24 |
| - |
25 |
| - |
26 | 11 | VERBOSE = False # insert lots of diagnostic prints in extension code
|
27 | 12 |
|
28 |
| - |
29 |
| - |
30 |
| - |
31 |
| -## You shouldn't need to customize below this point |
32 |
| -import ConfigParser |
33 |
| -import os |
34 |
| - |
35 |
| -# Build the antigrain geometry toolkit. Agg makes heavy use of |
36 |
| -# templates, so it probably requires a fairly recent compiler to build |
37 |
| -# it. It makes very nice antialiased output and also supports alpha |
38 |
| -# blending |
39 |
| -BUILD_AGG = 1 |
40 |
| -BUILD_GTKAGG = 1 |
41 |
| -BUILD_GTK = 1 |
42 |
| - |
43 |
| -# build TK GUI with Agg renderer ; requires Tkinter Python extension |
44 |
| -# and Tk includes |
45 |
| -# Use False or 0 if you don't want to build |
46 |
| -BUILD_TKAGG = 'auto' |
47 |
| - |
48 |
| - |
49 |
| -# build wxPython extension code to efficiently blit agg into wx. Only |
50 |
| -# needed for wxpython <2.8 if you plan on doing animations |
51 |
| -BUILD_WXAGG = 1 |
52 |
| - |
53 |
| -if os.path.exists("setup.cfg"): |
54 |
| - config = ConfigParser.SafeConfigParser() |
55 |
| - config.read("setup.cfg") |
56 |
| - try: |
57 |
| - BUILD_GTK = config.getboolean("gui_support", "gtk") |
58 |
| - except: |
59 |
| - pass |
60 |
| - try: |
61 |
| - BUILD_GTKAGG = config.getboolean("gui_support", "gtkagg") |
62 |
| - except: |
63 |
| - pass |
64 |
| - try: |
65 |
| - BUILD_TKAGG = config.getboolean("gui_support", "tkagg") |
66 |
| - except: |
67 |
| - pass |
68 |
| - try: |
69 |
| - BUILD_WXAGG = config.getboolean("gui_support", "wxagg") |
70 |
| - except: |
71 |
| - pass |
| 13 | +# This dict will be updated as we try to select the best option during |
| 14 | +# the build process. However, values in setup.cfg will be used, if |
| 15 | +# defined. |
| 16 | +rc = {'backend':'Agg', 'numerix':'numpy'} |
72 | 17 |
|
73 | 18 |
|
74 | 19 | # BEFORE importing disutils, remove MANIFEST. distutils doesn't properly
|
|
106 | 51 | check_for_cairo, check_provide_traits, check_provide_pytz, \
|
107 | 52 | check_provide_dateutil, check_provide_configobj, check_for_dvipng, \
|
108 | 53 | check_for_ghostscript, check_for_latex, check_for_pdftops, \
|
109 |
| - check_for_datetime |
| 54 | + check_for_datetime, options |
110 | 55 | #import distutils.sysconfig
|
111 | 56 |
|
112 | 57 | # jdh
|
|
127 | 72 |
|
128 | 73 | ext_modules = []
|
129 | 74 |
|
130 |
| -# these are not optional |
131 |
| -BUILD_FT2FONT = 1 |
132 |
| -BUILD_TTCONV = 1 |
133 |
| -BUILD_CONTOUR = 1 |
134 |
| -BUILD_NXUTILS = 1 |
135 |
| - |
136 | 75 | for line in file('lib/matplotlib/__init__.py').readlines():
|
137 | 76 | if (line.startswith('__version__')):
|
138 | 77 | exec(line.strip())
|
|
166 | 105 | if not check_for_numpy():
|
167 | 106 | sys.exit()
|
168 | 107 |
|
169 |
| -# The NUMERIX variable (a list) is left over from the days when it had |
170 |
| -# a string for each of the supported backends. Now there is only one |
171 |
| -# supported backend, so this approach could (should?) get changed for |
172 |
| -# simplicity. |
173 |
| - |
174 |
| -import numpy |
175 |
| -NUMERIX = ['numpy'] |
176 |
| - |
177 |
| -rc['numerix'] = NUMERIX[-1] |
178 |
| - |
179 | 108 | try: import subprocess
|
180 | 109 | except ImportError: havesubprocess = False
|
181 | 110 | else: havesubprocess = True
|
|
196 | 125 | if not check_for_freetype():
|
197 | 126 | sys.exit(1)
|
198 | 127 |
|
199 |
| -if BUILD_FT2FONT: |
200 |
| - build_ft2font(ext_modules, packages) |
201 |
| - |
202 |
| -if BUILD_TTCONV: |
203 |
| - build_ttconv(ext_modules, packages) |
204 |
| - |
205 |
| -if 1: # I don't think we need to make these optional |
206 |
| - build_contour(ext_modules, packages) |
207 |
| - build_nxutils(ext_modules, packages) |
| 128 | +build_ft2font(ext_modules, packages) |
| 129 | +build_ttconv(ext_modules, packages) |
| 130 | +build_contour(ext_modules, packages) |
| 131 | +build_nxutils(ext_modules, packages) |
208 | 132 |
|
209 | 133 | build_swigagg(ext_modules, packages)
|
210 | 134 | build_transforms(ext_modules, packages)
|
211 | 135 |
|
212 | 136 | print_raw("")
|
213 | 137 | print_raw("OPTIONAL BACKEND DEPENDENCIES")
|
214 | 138 |
|
215 |
| -if check_for_gtk() and (BUILD_GTK or BUILD_GTKAGG): |
216 |
| - if BUILD_GTK: |
| 139 | + |
| 140 | +# the options can be True, False, or 'auto'. If True, try to build |
| 141 | +# regardless of the lack of dependencies. If auto, silently skip |
| 142 | +# when dependencies are missing. |
| 143 | +hasgtk = check_for_gtk() |
| 144 | +if options['build_gtk']: |
| 145 | + if hasgtk or (options['build_gtk'] is True): |
217 | 146 | build_gdk(ext_modules, packages)
|
218 | 147 | rc['backend'] = 'GTK'
|
219 |
| - if BUILD_GTKAGG: |
220 |
| - BUILD_AGG = 1 |
| 148 | +if options['build_gtkagg']: |
| 149 | + if hasgtk or (options['build_gtkagg'] is True): |
| 150 | + options['build_agg'] = 1 |
221 | 151 | build_gtkagg(ext_modules, packages)
|
222 | 152 | rc['backend'] = 'GTKAgg'
|
223 | 153 |
|
224 |
| -if check_for_tk() and BUILD_TKAGG: |
225 |
| - BUILD_AGG = 1 |
226 |
| - build_tkagg(ext_modules, packages) |
227 |
| - rc['backend'] = 'TkAgg' |
228 |
| - |
229 |
| -explanation = None |
230 |
| -if check_for_wx() and BUILD_WXAGG: |
231 |
| - BUILD_AGG = 1 |
232 |
| - import wx |
233 |
| - if getattr(wx, '__version__', '0.0')[0:3] < '2.8': |
234 |
| - build_wxagg(ext_modules, packages) |
235 |
| - wxagg_backend_status = "yes" |
236 |
| - else: |
237 |
| - print_message("WxAgg extension not required for wxPython >= 2.8") |
238 |
| - rc['backend'] = 'WXAgg' |
239 |
| - |
240 |
| -# These are informational only. We don't build |
241 |
| -# any extensions for them. |
| 154 | +if options['build_tkagg']: |
| 155 | + if check_for_tk() or (options['build_tkagg'] is True): |
| 156 | + options['build_agg'] = 1 |
| 157 | + build_tkagg(ext_modules, packages) |
| 158 | + rc['backend'] = 'TkAgg' |
| 159 | + |
| 160 | +if options['build_wxagg']: |
| 161 | + if check_for_wx() or (options['build_wxagg'] is True): |
| 162 | + options['build_agg'] = 1 |
| 163 | + import wx |
| 164 | + if getattr(wx, '__version__', '0.0')[0:3] < '2.8' : |
| 165 | + build_wxagg(ext_modules, packages) |
| 166 | + wxagg_backend_status = "yes" |
| 167 | + else: |
| 168 | + print_message("WxAgg extension not required for wxPython >= 2.8") |
| 169 | + rc['backend'] = 'WXAgg' |
| 170 | + |
| 171 | +# These are informational only. We don't build any extensions for them. |
242 | 172 | check_for_qt()
|
243 | 173 | check_for_qt4()
|
244 | 174 | check_for_cairo()
|
245 | 175 |
|
246 |
| -if check_for_libpng() and BUILD_AGG: |
| 176 | +if check_for_libpng() and options['build_agg']: |
247 | 177 | build_agg(ext_modules, packages)
|
248 |
| - if rc['backend'] == 'PS': rc['backend'] = 'Agg' |
| 178 | + rc['backend'] = 'Agg' |
| 179 | +else: |
| 180 | + rc['backend'] = 'SVG' |
249 | 181 |
|
250 |
| -if BUILD_WINDOWING and sys.platform=='win32': |
| 182 | +if options['build_windowing'] and sys.platform=='win32': |
251 | 183 | build_windowing(ext_modules, packages)
|
252 | 184 |
|
253 |
| -if BUILD_IMAGE: |
| 185 | +if options['build_image']: |
254 | 186 | build_image(ext_modules, packages)
|
255 | 187 |
|
256 | 188 | for mod in ext_modules:
|
@@ -314,12 +246,13 @@ def add_dateutil():
|
314 | 246 | print_raw("[Edit setup.cfg to suppress the above messages]")
|
315 | 247 | print_line()
|
316 | 248 |
|
317 |
| -# packagers: set rc['numerix'] and rc['backend'] here to override the auto |
318 |
| -# defaults, eg |
319 |
| -#rc['numerix'] = numpy |
320 |
| -#rc['backend'] = 'GTKAgg' |
| 249 | +# Write the default matplotlibrc file |
321 | 250 | if sys.platform=='win32':
|
322 |
| - rc = dict(backend='TkAgg', numerix='numpy') |
| 251 | + rc['backend'] = 'TkAgg' |
| 252 | + rc['numerix'] = 'numpy' |
| 253 | +else: |
| 254 | + if options['backend']: rc['backend'] = options['backend'] |
| 255 | + if options['numerix']: rc['numerix'] = options['numerix'] |
323 | 256 | template = file('matplotlibrc.template').read()
|
324 | 257 | file('lib/matplotlib/mpl-data/matplotlibrc', 'w').write(template%rc)
|
325 | 258 |
|
|
0 commit comments