Revision: 4239
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4239&view=rev
Author:   dsdale
Date:     2007-11-12 14:00:15 -0800 (Mon, 12 Nov 2007)

Log Message:
-----------
expose remaining build options in setup.cfg. See setup.cfg for details 

Modified Paths:
--------------
    trunk/matplotlib/CHANGELOG
    trunk/matplotlib/lib/configobj.py
    trunk/matplotlib/lib/dateutil/__init__.py
    trunk/matplotlib/lib/pytz/__init__.py
    trunk/matplotlib/setup.cfg.template
    trunk/matplotlib/setup.py
    trunk/matplotlib/setupext.py

Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG  2007-11-12 20:45:15 UTC (rev 4238)
+++ trunk/matplotlib/CHANGELOG  2007-11-12 22:00:15 UTC (rev 4239)
@@ -1,3 +1,9 @@
+2007-11-12 Exposed all the build options in setup.cfg. These options are
+           read into a dict called "options" by setupext.py. Also, added
+           "-mpl" tags to the version strings for packages provided by
+           matplotlib. Versions provided by mpl will be identified and 
+           updated on subsequent installs - DSD
+
 2007-11-12 Added support for STIX fonts.  A new rcParam,
           mathtext.fontset, can be used to choose between: 
            

Modified: trunk/matplotlib/lib/configobj.py
===================================================================
--- trunk/matplotlib/lib/configobj.py   2007-11-12 20:45:15 UTC (rev 4238)
+++ trunk/matplotlib/lib/configobj.py   2007-11-12 22:00:15 UTC (rev 4239)
@@ -109,7 +109,7 @@
     True, False = 1, 0
 
 
-__version__ = '4.4.0'
+__version__ = '4.4.0-mpl'
 
 __revision__ = '$Id: configobj.py 156 2006-01-31 14:57:08Z fuzzyman $'
 

Modified: trunk/matplotlib/lib/dateutil/__init__.py
===================================================================
--- trunk/matplotlib/lib/dateutil/__init__.py   2007-11-12 20:45:15 UTC (rev 
4238)
+++ trunk/matplotlib/lib/dateutil/__init__.py   2007-11-12 22:00:15 UTC (rev 
4239)
@@ -6,4 +6,4 @@
 """
 __author__ = "Gustavo Niemeyer <[EMAIL PROTECTED]>"
 __license__ = "PSF License"
-__version__ = "1.2"
+__version__ = "1.2-mpl"

Modified: trunk/matplotlib/lib/pytz/__init__.py
===================================================================
--- trunk/matplotlib/lib/pytz/__init__.py       2007-11-12 20:45:15 UTC (rev 
4238)
+++ trunk/matplotlib/lib/pytz/__init__.py       2007-11-12 22:00:15 UTC (rev 
4239)
@@ -12,7 +12,7 @@
 OLSON_VERSION = '2007g'
 VERSION = OLSON_VERSION
 #VERSION = OLSON_VERSION + '.2'
-__version__ = OLSON_VERSION
+__version__ = OLSON_VERSION+'-mpl'
 
 OLSEN_VERSION = OLSON_VERSION # Old releases had this misspelling
 

Modified: trunk/matplotlib/setup.cfg.template
===================================================================
--- trunk/matplotlib/setup.cfg.template 2007-11-12 20:45:15 UTC (rev 4238)
+++ trunk/matplotlib/setup.cfg.template 2007-11-12 22:00:15 UTC (rev 4239)
@@ -13,7 +13,11 @@
 [provide_packages]
 # By default, matplotlib checks for a few dependencies and 
 # installs them if missing. This feature can be turned off 
-# by uncommenting the following lines:
+# by uncommenting the following lines. Acceptible values are:
+#     True: install, overwrite an existing installation
+#     False: do not install
+#     auto: install only if the package is unavailable. This 
+#           is the default behavior
 #
 ## Date/timezone support:
 #pytz = False
@@ -40,8 +44,34 @@
 # installed on your system.
 # 
 # You can uncomment any the following lines if you know you do
-# not want to use the GUI toolkit.
+# not want to use the GUI toolkit. Acceptible values are:
+#     True: build the extension. Exits with a warning if the 
+#           required dependencies are not available
+#     False: do not build the extension
+#     auto: build if the required dependencies are available,
+#           otherwise skip silently. This is the default 
+#           behavior
+#
 #gtk = False
 #gtkagg = False
 #tkagg = False
 #wxagg = False
+
+[rc_options]
+# User-configurable options
+#
+# Default backend, one of: Agg, Cairo, CocoaAgg, GTK, GTKAgg, 
+# GTKCairo, FltkAgg, QtAgg, Qt4Agg, SVG, TkAgg, WX, WXAgg. 
+# Only the Agg and SVG backends do not require external 
+# dependencies. Do not choose GTK, GTKAgg, GTKCairo, TkAgg or 
+# WXAgg if you have disabled the relevent extension modules.
+# Agg will be used by default.
+#backend = Agg
+#
+# The numerix module was historically used to provide 
+# compatibility between the Numeric, numarray, and NumPy array
+# packages. Now that NumPy has emerge as the universal array 
+# package for python, numerix is not really necessary and is 
+# maintained to provide backward compatibility. Do not change 
+# this unless you have a compelling reason to do so.
+#numerix = numpy

Modified: trunk/matplotlib/setup.py
===================================================================
--- trunk/matplotlib/setup.py   2007-11-12 20:45:15 UTC (rev 4238)
+++ trunk/matplotlib/setup.py   2007-11-12 22:00:15 UTC (rev 4239)
@@ -3,74 +3,19 @@
 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
+The matplotlib build options can be modified with a setup.cfg file. See
+setup.cfg.template for more information.
 """
 
 
-rc = {'backend':'PS', 'numerix':'numpy'}
-
-# build the image support module - requires agg.  By default, matplotlib will 
-# build support for whatever array packages you have installed.
-BUILD_IMAGE = 1
-
-
-# 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
 
+# This dict will be updated as we try to select the best option during
+# the build process. However, values in setup.cfg will be used, if 
+# defined.
+rc = {'backend':'Agg', 'numerix':'numpy'}
 
 
-
-## You shouldn't need to customize below this point
-import ConfigParser
-import os
-
-# 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       = 1
-BUILD_GTK          = 1
-
-# 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        = 1
-
-if os.path.exists("setup.cfg"):
-    config = ConfigParser.SafeConfigParser()
-    config.read("setup.cfg")
-    try:
-        BUILD_GTK = config.getboolean("gui_support", "gtk")
-    except:
-        pass
-    try:
-        BUILD_GTKAGG = config.getboolean("gui_support", "gtkagg")
-    except:
-        pass
-    try:
-        BUILD_TKAGG = config.getboolean("gui_support", "tkagg")
-    except:
-        pass
-    try:
-        BUILD_WXAGG = config.getboolean("gui_support", "wxagg")
-    except:
-        pass
-
-
 # BEFORE importing disutils, remove MANIFEST. distutils doesn't properly
 # update it when the contents of directories change.
 import os
@@ -106,7 +51,7 @@
      check_for_cairo, check_provide_traits, check_provide_pytz, \
      check_provide_dateutil, check_provide_configobj, check_for_dvipng, \
      check_for_ghostscript, check_for_latex, check_for_pdftops, \
-     check_for_datetime
+     check_for_datetime, options
 #import distutils.sysconfig
 
 # jdh
@@ -127,12 +72,6 @@
 
 ext_modules = []
 
-# these are not optional
-BUILD_FT2FONT = 1
-BUILD_TTCONV  = 1
-BUILD_CONTOUR = 1
-BUILD_NXUTILS = 1
-
 for line in file('lib/matplotlib/__init__.py').readlines():
     if (line.startswith('__version__')):
         exec(line.strip())
@@ -166,16 +105,6 @@
 if not check_for_numpy():
     sys.exit()
 
-# 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.
-
-import numpy
-NUMERIX = ['numpy']
-
-rc['numerix'] = NUMERIX[-1]
-
 try: import subprocess
 except ImportError: havesubprocess = False
 else: havesubprocess = True
@@ -196,61 +125,64 @@
 if not check_for_freetype():
     sys.exit(1)
     
-if BUILD_FT2FONT:
-    build_ft2font(ext_modules, packages)
+build_ft2font(ext_modules, packages)
+build_ttconv(ext_modules, packages)
+build_contour(ext_modules, packages)
+build_nxutils(ext_modules, packages)
 
-if BUILD_TTCONV:
-    build_ttconv(ext_modules, packages)
-
-if 1:  # I don't think we need to make these optional
-    build_contour(ext_modules, packages)
-    build_nxutils(ext_modules, packages)
-
 build_swigagg(ext_modules, packages)
 build_transforms(ext_modules, packages)
 
 print_raw("")
 print_raw("OPTIONAL BACKEND DEPENDENCIES")
 
-if check_for_gtk() and (BUILD_GTK or BUILD_GTKAGG):
-    if BUILD_GTK:
+
+# the options can be True, False, or 'auto'. If True, try to build
+# regardless of the lack of dependencies. If auto, silently skip 
+# when dependencies are missing.
+hasgtk = check_for_gtk()
+if options['build_gtk']:
+    if hasgtk or (options['build_gtk'] is True):
         build_gdk(ext_modules, packages)
         rc['backend'] = 'GTK'
-    if BUILD_GTKAGG:
-        BUILD_AGG = 1
+if options['build_gtkagg']:
+    if hasgtk or (options['build_gtkagg'] is True):
+        options['build_agg'] = 1
         build_gtkagg(ext_modules, packages)
         rc['backend'] = 'GTKAgg'
 
-if check_for_tk() and BUILD_TKAGG:
-    BUILD_AGG = 1
-    build_tkagg(ext_modules, packages)
-    rc['backend'] = 'TkAgg'
+if options['build_tkagg']:
+    if check_for_tk() or (options['build_tkagg'] is True):
+        options['build_agg'] = 1
+        build_tkagg(ext_modules, packages)
+        rc['backend'] = 'TkAgg'
 
-explanation = None
-if check_for_wx() and BUILD_WXAGG:
-    BUILD_AGG = 1
-    import wx
-    if getattr(wx, '__version__', '0.0')[0:3] < '2.8':
-        build_wxagg(ext_modules, packages)
-        wxagg_backend_status = "yes"
-    else:
-        print_message("WxAgg extension not required for wxPython >= 2.8")
-    rc['backend'] = 'WXAgg'
+if options['build_wxagg']:
+    if check_for_wx() or (options['build_wxagg'] is True):
+        options['build_agg'] = 1
+        import wx
+        if getattr(wx, '__version__', '0.0')[0:3] < '2.8' :
+            build_wxagg(ext_modules, packages)
+            wxagg_backend_status = "yes"
+        else:
+            print_message("WxAgg extension not required for wxPython >= 2.8")
+        rc['backend'] = 'WXAgg'
 
-# These are informational only.  We don't build
-# any extensions for them.
+# These are informational only.  We don't build any extensions for them.
 check_for_qt()
 check_for_qt4()
 check_for_cairo()
     
-if check_for_libpng() and BUILD_AGG:
+if check_for_libpng() and options['build_agg']:
     build_agg(ext_modules, packages)
-    if rc['backend'] == 'PS': rc['backend'] = 'Agg'
+    rc['backend'] = 'Agg'
+else:
+    rc['backend'] = 'SVG'
 
-if BUILD_WINDOWING and sys.platform=='win32':
+if options['build_windowing'] and sys.platform=='win32':
    build_windowing(ext_modules, packages)
 
-if BUILD_IMAGE:
+if options['build_image']:
     build_image(ext_modules, packages)
 
 for mod in ext_modules:
@@ -314,12 +246,13 @@
 print_raw("[Edit setup.cfg to suppress the above messages]")
 print_line()
 
-# packagers: set rc['numerix'] and rc['backend'] here to override the auto
-# defaults, eg
-#rc['numerix'] = numpy
-#rc['backend'] = 'GTKAgg'
+# Write the default matplotlibrc file
 if sys.platform=='win32':
-    rc = dict(backend='TkAgg', numerix='numpy')
+    rc['backend'] = 'TkAgg'
+    rc['numerix'] = 'numpy'
+else:
+    if options['backend']: rc['backend'] = options['backend']
+    if options['numerix']: rc['numerix'] = options['numerix']
 template = file('matplotlibrc.template').read()
 file('lib/matplotlib/mpl-data/matplotlibrc', 'w').write(template%rc)
 

Modified: trunk/matplotlib/setupext.py
===================================================================
--- trunk/matplotlib/setupext.py        2007-11-12 20:45:15 UTC (rev 4238)
+++ trunk/matplotlib/setupext.py        2007-11-12 22:00:15 UTC (rev 4239)
@@ -97,38 +97,64 @@
 # for nonstandard installation/build with --prefix variable
 numpy_inc_dirs = []
 
-# Based on the contents of setup.cfg, determine if the status block
-# should be displayed, if missing external packages should be provided
-display_status = True
-provide_pytz = True
-provide_dateutil = True
-provide_configobj = True
-provide_traits = True
+# matplotlib build options, which can be altered using setup.cfg
+options = {'display_status': True, 
+           'provide_pytz': 'auto', 
+           'provide_dateutil': 'auto', 
+           'provide_configobj': 'auto', 
+           'provide_traits': 'auto', 
+           'build_agg': True, 
+           'build_gtk': 'auto', 
+           'build_gtkagg': 'auto', 
+           'build_tkagg': 'auto', 
+           'build_wxagg': 'auto', 
+           'build_image': True, 
+           'build_windowing': True, 
+           'backend': None, 
+           'numerix': None}
+
+# Based on the contents of setup.cfg, determine the build options
 if os.path.exists("setup.cfg"):
     config = ConfigParser.SafeConfigParser()
     config.read("setup.cfg")
-    try:
-        display_status = not config.getboolean("status", "suppress")
-    except:
-        pass
-    try:
-        provide_pytz = config.getboolean("provide_packages", "pytz")
-    except:
-        pass
-    try:
-        provide_dateutil = config.getboolean("provide_packages", "dateutil")
-    except:
-        pass
-    try:
-        provide_configobj = config.getboolean("provide_packages", "configobj")
-    except:
-        pass
-    try:
-        provide_traits = config.getboolean("provide_packages", 
"enthought.traits")
-    except:
-        pass
+    try: options['display_status'] = not config.getboolean("status", 
"suppress")
+    except: pass
 
-if display_status:
+    try: options['provide_pytz'] = config.getboolean("provide_packages", 
"pytz")
+    except: options['provide_pytz'] = 'auto'
+
+    try: options['provide_dateutil'] = config.getboolean("provide_packages",
+                                                         "dateutil")
+    except: options['provide_dateutil'] = 'auto'
+
+    try: options['provide_configobj'] = config.getboolean("provide_packages",
+                                                          "configobj")
+    except: options['provide_configobj'] = 'auto'
+
+    try: options['provide_traits'] = config.getboolean("provide_packages",
+                                                       "enthought.traits")
+    except: options['provide_traits'] = 'auto'
+
+    try: options['build_gtk'] = config.getboolean("gui_support", "gtk")
+    except: options['build_gtk'] = 'auto'
+
+    try: options['build_gtkagg'] = config.getboolean("gui_support", "gtkagg")
+    except: options['build_gtkagg'] = 'auto'
+
+    try: options['build_tkagg'] = config.getboolean("gui_support", "tkagg")
+    except: options['build_tkagg'] = 'auto'
+
+    try: options['build_wxagg'] = config.getboolean("gui_support", "wxagg")
+    except: options['build_wxagg'] = 'auto'
+
+    try: options['backend'] = config.get("rc_options", "backend")
+    except: pass
+
+    try: options['numerix'] = config.get("rc_options", "numerix")
+    except: pass
+
+
+if options['display_status']:
     def print_line(char='='):
         print char * 76
 
@@ -356,24 +382,34 @@
         return True
 
 def check_provide_pytz(hasdatetime=True):
+    if hasdatetime and (options['provide_pytz'] is True):
+        print_status("pytz", "matplotlib will provide")
+        return True
     try:
         import pytz
     except ImportError:
-        if hasdatetime and provide_pytz:
+        if hasdatetime and options['provide_pytz']:
             print_status("pytz", "matplotlib will provide")
             return True
         else:
             print_status("pytz", "no")
             return False
     else:
-        print_status("pytz", pytz.__version__)
-        return False
+        if pytz.__version__.endswith('mpl'):
+            print_status("pytz", "matplotlib will provide")
+            return True
+        else:
+            print_status("pytz", pytz.__version__)
+            return False
 
 def check_provide_dateutil(hasdatetime=True):
+    if hasdatetime and (options['provide_dateutil'] is True):
+        print_status("dateutil", "matplotlib will provide")
+        return True
     try:
         import dateutil
     except ImportError:
-        if hasdatetime and provide_dateutil:
+        if hasdatetime and options['provide_dateutil']:
             print_status("dateutil", "matplotlib will provide")
             return True
         else:
@@ -381,26 +417,41 @@
             return False
     else:
         try:
-            print_status("dateutil", dateutil.__version__)
+            if dateutil.__version__.endswith('mpl'):
+                print_status("dateutil", "matplotlib will provide")
+                return True
+            else:
+                print_status("dateutil", dateutil.__version__)
+                return False
         except AttributeError:
             print_status("dateutil", "present, version unknown")
-        return False
+            return False
 
 def check_provide_configobj():
+    if options['provide_configobj'] is True:
+        print_status("configobj", "matplotlib will provide")
+        return True
     try:
         import configobj
     except ImportError:
-        if provide_configobj:
+        if options['provide_configobj']:
             print_status("configobj", "matplotlib will provide")
             return True
         else:
             print_status("configobj", "no")
             return False
     else:
-        print_status("configobj", configobj.__version__)
-        return False
+        if configobj.__version__.endswith('mpl'):
+            print_status("configobj", "matplotlib will provide")
+            return True
+        else:
+            print_status("configobj", configobj.__version__)
+            return False
 
 def check_provide_traits():
+    if options['provide_traits'] is True:
+        print_status("enthought.traits", "matplotlib will provide")
+        return True
     try:
         from enthought import traits
         try:
@@ -416,7 +467,7 @@
                 print_status("enthought.traits", version.version)
                 return False
     except ImportError:
-        if provide_traits:
+        if options['provide_traits']:
             print_status("enthought.traits", "matplotlib will provide")
             return True
         else:


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to