Skip to content

Commit 278cb96

Browse files
committed
expose remaining build options in setup.cfg. See setup.cfg for details
svn path=/trunk/matplotlib/; revision=4239
1 parent 116051a commit 278cb96

File tree

7 files changed

+181
-161
lines changed

7 files changed

+181
-161
lines changed

CHANGELOG

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2007-11-12 Exposed all the build options in setup.cfg. These options are
2+
read into a dict called "options" by setupext.py. Also, added
3+
"-mpl" tags to the version strings for packages provided by
4+
matplotlib. Versions provided by mpl will be identified and
5+
updated on subsequent installs - DSD
6+
17
2007-11-12 Added support for STIX fonts. A new rcParam,
28
mathtext.fontset, can be used to choose between:
39

lib/configobj.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def enumerate(obj):
109109
True, False = 1, 0
110110

111111

112-
__version__ = '4.4.0'
112+
__version__ = '4.4.0-mpl'
113113

114114
__revision__ = '$Id: configobj.py 156 2006-01-31 14:57:08Z fuzzyman $'
115115

lib/dateutil/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
"""
77
__author__ = "Gustavo Niemeyer <gustavo@niemeyer.net>"
88
__license__ = "PSF License"
9-
__version__ = "1.2"
9+
__version__ = "1.2-mpl"

lib/pytz/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
OLSON_VERSION = '2007g'
1313
VERSION = OLSON_VERSION
1414
#VERSION = OLSON_VERSION + '.2'
15-
__version__ = OLSON_VERSION
15+
__version__ = OLSON_VERSION+'-mpl'
1616

1717
OLSEN_VERSION = OLSON_VERSION # Old releases had this misspelling
1818

setup.cfg.template

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ tag_svn_revision = 1
1313
[provide_packages]
1414
# By default, matplotlib checks for a few dependencies and
1515
# installs them if missing. This feature can be turned off
16-
# by uncommenting the following lines:
16+
# by uncommenting the following lines. Acceptible values are:
17+
# True: install, overwrite an existing installation
18+
# False: do not install
19+
# auto: install only if the package is unavailable. This
20+
# is the default behavior
1721
#
1822
## Date/timezone support:
1923
#pytz = False
@@ -40,8 +44,34 @@ tag_svn_revision = 1
4044
# installed on your system.
4145
#
4246
# You can uncomment any the following lines if you know you do
43-
# not want to use the GUI toolkit.
47+
# not want to use the GUI toolkit. Acceptible values are:
48+
# True: build the extension. Exits with a warning if the
49+
# required dependencies are not available
50+
# False: do not build the extension
51+
# auto: build if the required dependencies are available,
52+
# otherwise skip silently. This is the default
53+
# behavior
54+
#
4455
#gtk = False
4556
#gtkagg = False
4657
#tkagg = False
4758
#wxagg = False
59+
60+
[rc_options]
61+
# User-configurable options
62+
#
63+
# Default backend, one of: Agg, Cairo, CocoaAgg, GTK, GTKAgg,
64+
# GTKCairo, FltkAgg, QtAgg, Qt4Agg, SVG, TkAgg, WX, WXAgg.
65+
# Only the Agg and SVG backends do not require external
66+
# dependencies. Do not choose GTK, GTKAgg, GTKCairo, TkAgg or
67+
# WXAgg if you have disabled the relevent extension modules.
68+
# Agg will be used by default.
69+
#backend = Agg
70+
#
71+
# The numerix module was historically used to provide
72+
# compatibility between the Numeric, numarray, and NumPy array
73+
# packages. Now that NumPy has emerge as the universal array
74+
# package for python, numerix is not really necessary and is
75+
# maintained to provide backward compatibility. Do not change
76+
# this unless you have a compelling reason to do so.
77+
#numerix = numpy

setup.py

Lines changed: 51 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -3,72 +3,17 @@
33
matplotlib, inlcuding the *-devel versions of these libraries if you
44
are using a package manager like RPM or debian.
55
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.
118
"""
129

1310

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-
2611
VERBOSE = False # insert lots of diagnostic prints in extension code
2712

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'}
7217

7318

7419
# BEFORE importing disutils, remove MANIFEST. distutils doesn't properly
@@ -106,7 +51,7 @@
10651
check_for_cairo, check_provide_traits, check_provide_pytz, \
10752
check_provide_dateutil, check_provide_configobj, check_for_dvipng, \
10853
check_for_ghostscript, check_for_latex, check_for_pdftops, \
109-
check_for_datetime
54+
check_for_datetime, options
11055
#import distutils.sysconfig
11156

11257
# jdh
@@ -127,12 +72,6 @@
12772

12873
ext_modules = []
12974

130-
# these are not optional
131-
BUILD_FT2FONT = 1
132-
BUILD_TTCONV = 1
133-
BUILD_CONTOUR = 1
134-
BUILD_NXUTILS = 1
135-
13675
for line in file('lib/matplotlib/__init__.py').readlines():
13776
if (line.startswith('__version__')):
13877
exec(line.strip())
@@ -166,16 +105,6 @@
166105
if not check_for_numpy():
167106
sys.exit()
168107

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-
179108
try: import subprocess
180109
except ImportError: havesubprocess = False
181110
else: havesubprocess = True
@@ -196,61 +125,64 @@
196125
if not check_for_freetype():
197126
sys.exit(1)
198127

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)
208132

209133
build_swigagg(ext_modules, packages)
210134
build_transforms(ext_modules, packages)
211135

212136
print_raw("")
213137
print_raw("OPTIONAL BACKEND DEPENDENCIES")
214138

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):
217146
build_gdk(ext_modules, packages)
218147
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
221151
build_gtkagg(ext_modules, packages)
222152
rc['backend'] = 'GTKAgg'
223153

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.
242172
check_for_qt()
243173
check_for_qt4()
244174
check_for_cairo()
245175

246-
if check_for_libpng() and BUILD_AGG:
176+
if check_for_libpng() and options['build_agg']:
247177
build_agg(ext_modules, packages)
248-
if rc['backend'] == 'PS': rc['backend'] = 'Agg'
178+
rc['backend'] = 'Agg'
179+
else:
180+
rc['backend'] = 'SVG'
249181

250-
if BUILD_WINDOWING and sys.platform=='win32':
182+
if options['build_windowing'] and sys.platform=='win32':
251183
build_windowing(ext_modules, packages)
252184

253-
if BUILD_IMAGE:
185+
if options['build_image']:
254186
build_image(ext_modules, packages)
255187

256188
for mod in ext_modules:
@@ -314,12 +246,13 @@ def add_dateutil():
314246
print_raw("[Edit setup.cfg to suppress the above messages]")
315247
print_line()
316248

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
321250
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']
323256
template = file('matplotlibrc.template').read()
324257
file('lib/matplotlib/mpl-data/matplotlibrc', 'w').write(template%rc)
325258

0 commit comments

Comments
 (0)