From: <md...@us...> - 2007-12-03 15:27:46
|
Revision: 4562 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4562&view=rev Author: mdboom Date: 2007-12-03 07:27:33 -0800 (Mon, 03 Dec 2007) Log Message: ----------- Merged revisions 4506-4561 via svnmerge from http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib ........ r4507 | jdh2358 | 2007-11-29 15:16:48 -0500 (Thu, 29 Nov 2007) | 2 lines Applied Ludwigs build tkagg w/o x11 server patch ........ r4509 | jdh2358 | 2007-11-29 17:19:26 -0500 (Thu, 29 Nov 2007) | 2 lines commited ludwigs axes3d patch ........ r4512 | cmoad | 2007-11-29 21:40:30 -0500 (Thu, 29 Nov 2007) | 1 line minor rev bump ........ r4513 | cmoad | 2007-11-29 21:41:01 -0500 (Thu, 29 Nov 2007) | 1 line minor rev bump ........ r4514 | cmoad | 2007-11-29 21:47:06 -0500 (Thu, 29 Nov 2007) | 1 line minor rev bump ........ r4515 | cmoad | 2007-11-29 22:42:35 -0500 (Thu, 29 Nov 2007) | 1 line CXX/WrapPython.h missing from MANIFEST ........ r4516 | cmoad | 2007-11-29 23:00:16 -0500 (Thu, 29 Nov 2007) | 1 line ttconv missing from MANFEST ........ r4517 | cmoad | 2007-11-29 23:09:48 -0500 (Thu, 29 Nov 2007) | 1 line added setup.cfg.template ........ r4532 | mdboom | 2007-11-30 14:48:41 -0500 (Fri, 30 Nov 2007) | 2 lines Fix mathtext in example. ........ r4537 | astraw | 2007-12-01 15:12:05 -0500 (Sat, 01 Dec 2007) | 2 lines Fix loading of AAPL data in get_two_stock_data() ........ r4557 | mdboom | 2007-12-03 08:20:19 -0500 (Mon, 03 Dec 2007) | 2 lines Fix missing font file error. ........ r4560 | jdh2358 | 2007-12-03 10:23:32 -0500 (Mon, 03 Dec 2007) | 2 lines fixed a gtk import else block in mlab ........ r4561 | mdboom | 2007-12-03 10:23:47 -0500 (Mon, 03 Dec 2007) | 3 lines Remove paragraph about MATPLOTLIBDATA environment variable, since it doesn't really apply anymore. ........ Modified Paths: -------------- branches/transforms/API_CHANGES branches/transforms/CHANGELOG branches/transforms/CODING_GUIDE branches/transforms/INSTALL branches/transforms/MANIFEST.in branches/transforms/examples/data_helper.py branches/transforms/examples/loadrec.py branches/transforms/examples/text_themes.py branches/transforms/lib/matplotlib/__init__.py branches/transforms/lib/matplotlib/axes3d.py branches/transforms/lib/matplotlib/mathtext.py branches/transforms/setupext.py Property Changed: ---------------- branches/transforms/ Property changes on: branches/transforms ___________________________________________________________________ Name: svnmerge-integrated - /trunk/matplotlib:1-4505 + /trunk/matplotlib:1-4561 Modified: branches/transforms/API_CHANGES =================================================================== --- branches/transforms/API_CHANGES 2007-12-03 15:23:47 UTC (rev 4561) +++ branches/transforms/API_CHANGES 2007-12-03 15:27:33 UTC (rev 4562) @@ -169,6 +169,8 @@ END OF TRANSFORMS REFACTORING +0.91.1 Released + 0.91.0 Released Changed cbook.is_file_like to cbook.is_writable_file_like and Modified: branches/transforms/CHANGELOG =================================================================== --- branches/transforms/CHANGELOG 2007-12-03 15:23:47 UTC (rev 4561) +++ branches/transforms/CHANGELOG 2007-12-03 15:27:33 UTC (rev 4562) @@ -1,4 +1,7 @@ =============================================================== +2007-11-27 Released 0.91.1 at revision 4517 + +=============================================================== 2007-11-27 Released 0.91.0 at revision 4478 2007-11-13 All backends now support writing to a file-like object, not Modified: branches/transforms/CODING_GUIDE =================================================================== --- branches/transforms/CODING_GUIDE 2007-12-03 15:23:47 UTC (rev 4561) +++ branches/transforms/CODING_GUIDE 2007-12-03 15:27:33 UTC (rev 4562) @@ -117,7 +117,7 @@ -for older versions of emacs (emacs<22) you may need to do +for older versions of emacs (emacs<22) you need to do (add-hook 'python-mode-hook (lambda () Modified: branches/transforms/INSTALL =================================================================== --- branches/transforms/INSTALL 2007-12-03 15:23:47 UTC (rev 4561) +++ branches/transforms/INSTALL 2007-12-03 15:27:33 UTC (rev 4562) @@ -14,7 +14,7 @@ more. If you want to produce PNGs or GUI images that support all of matplotlib's features, you should compile matplotlib with agg support and use one of the GUI agg backends: GTKAgg, WXAgg, TkAgg or - FLTKAgg. + FLTKAgg. COMPILING @@ -36,7 +36,7 @@ As discussed above, most users will want to set 'BUILD_AGG = 1' and one or more of the GUI backends to True. Exceptions to this are if you know you don't need a GUI (eg a web server) or you only want to - produce vector graphics. + produce vector graphics. If you have installed prerequisites to nonstandard places and need to inform matplotlib where they are, edit setupext.py an add the @@ -53,16 +53,12 @@ with matplotlib, it is important that you have *both* present and in your PYTHONPATH when you compile matplotlib. - Note that if you install matplotlib anywhere other than the default - location, you will need to set the MATPLOTLIBDATA environment - variable to point to the install base dir. - Once you have everything above set to your liking, just do the usual thing python setup.py build python setup.py install - + WINDOWS If you don't already have python installed, you may want to consider @@ -106,7 +102,7 @@ To build all the backends on a binary linux distro such as redhat, you need to install a number of the devel libs (and whatever dependencies they require), I suggest - + matplotlib core: zlib, zlib-devel, libpng, libpng-devel, freetype, freetype-devel, freetype-utils @@ -134,7 +130,7 @@ http://www.freshports.org/math/py-matplotlib/ Gentoo - + http://www.gentoo-portage.com/dev-python/matplotlib OS X Modified: branches/transforms/MANIFEST.in =================================================================== --- branches/transforms/MANIFEST.in 2007-12-03 15:23:47 UTC (rev 4561) +++ branches/transforms/MANIFEST.in 2007-12-03 15:27:33 UTC (rev 4562) @@ -1,7 +1,7 @@ include API_CHANGES CHANGELOG KNOWN_BUGS INSTALL NUMARRAY_ISSUES include INTERACTIVE TODO include Makefile MANIFEST.in MANIFEST -include matplotlibrc.template matplotlibrc +include matplotlibrc.template matplotlibrc setup.cfg.template include __init__.py setupext.py setup.py setupegg.py makeswig.py include examples/data/* include lib/matplotlib/toolkits @@ -12,7 +12,8 @@ recursive-include examples README *.py prune examples/_tmp_* recursive-include src *.cpp *.c *.h -recursive-include CXX *.cxx *.hxx *.c +recursive-include CXX *.cxx *.hxx *.c *.h recursive-include agg23 * recursive-include lib * recursive-include swig * +recursive-include ttconv *.cpp *.h Modified: branches/transforms/examples/data_helper.py =================================================================== --- branches/transforms/examples/data_helper.py 2007-12-03 15:23:47 UTC (rev 4561) +++ branches/transforms/examples/data_helper.py 2007-12-03 15:27:33 UTC (rev 4562) @@ -15,7 +15,7 @@ M1 = resize(M1, (M1.shape[0]/2,2) ) M2 = fromstring( file('data/%s.dat' % ticker2, 'rb').read(), '<d') - M2 = resize(M1, (M2.shape[0]/2,2) ) + M2 = resize(M2, (M2.shape[0]/2,2) ) d1, p1 = M1[:,0], M1[:,1] d2, p2 = M2[:,0], M2[:,1] Modified: branches/transforms/examples/loadrec.py =================================================================== --- branches/transforms/examples/loadrec.py 2007-12-03 15:23:47 UTC (rev 4561) +++ branches/transforms/examples/loadrec.py 2007-12-03 15:27:33 UTC (rev 4562) @@ -2,6 +2,7 @@ from pylab import figure, show a = mlab.csv2rec('data/msft.csv') +a.sort() print a.dtype fig = figure() Modified: branches/transforms/examples/text_themes.py =================================================================== --- branches/transforms/examples/text_themes.py 2007-12-03 15:23:47 UTC (rev 4561) +++ branches/transforms/examples/text_themes.py 2007-12-03 15:27:33 UTC (rev 4562) @@ -17,7 +17,7 @@ plot(t1, f(t1), 'bo', t2, f(t2), 'k') title('Damped exponential decay', font, size='large', color='r') -text(2, 0.65, 'cos(2 pi t) exp(-t)', font, color='k', family='monospace' ) +text(2, 0.65, r'$\cos(2 \pi t) \exp(-t)$', color='k') xlabel('time (s)', font, style='italic') ylabel('voltage (mV)', font) Modified: branches/transforms/lib/matplotlib/__init__.py =================================================================== --- branches/transforms/lib/matplotlib/__init__.py 2007-12-03 15:23:47 UTC (rev 4561) +++ branches/transforms/lib/matplotlib/__init__.py 2007-12-03 15:27:33 UTC (rev 4562) @@ -55,7 +55,7 @@ """ from __future__ import generators -__version__ = '0.91.0' +__version__ = '0.91.1' __revision__ = '$Revision$' __date__ = '$Date$' Modified: branches/transforms/lib/matplotlib/axes3d.py =================================================================== --- branches/transforms/lib/matplotlib/axes3d.py 2007-12-03 15:23:47 UTC (rev 4561) +++ branches/transforms/lib/matplotlib/axes3d.py 2007-12-03 15:27:33 UTC (rev 4562) @@ -313,9 +313,10 @@ def mouse_init(self): self.button_pressed = None - self.figure.canvas.mpl_connect('motion_notify_event', self.on_move) - self.figure.canvas.mpl_connect('button_press_event', self.button_press) - self.figure.canvas.mpl_connect('button_release_event', self.button_release) + if self.figure.canvas != None: + self.figure.canvas.mpl_connect('motion_notify_event', self.on_move) + self.figure.canvas.mpl_connect('button_press_event', self.button_press) + self.figure.canvas.mpl_connect('button_release_event', self.button_release) def button_press(self, event): self.button_pressed = event.button Modified: branches/transforms/lib/matplotlib/mathtext.py =================================================================== --- branches/transforms/lib/matplotlib/mathtext.py 2007-12-03 15:23:47 UTC (rev 4561) +++ branches/transforms/lib/matplotlib/mathtext.py 2007-12-03 15:27:33 UTC (rev 4562) @@ -16,8 +16,19 @@ s = r'$\mathcal{R}\prod_{i=\alpha\mathcal{B}}^\infty a_i\sin(2 \pi f x_i)$' - The fonts \cal, \rm, \it, and \tt are allowed. + Different fonts may be selected: + \mathcal Calligraphic fonts + \mathrm Roman (upright) font + \mathit Italic font + \mathtt Typewriter (monospaced) font, similar to Courier + Additionally, if using the STIX fonts: + \mathbb Blackboard (double-struck) font + \mathcircled Circled characters + \mathfrak Fraktur (Gothic-style) font + \mathscr Script (cursive) font + \mathsf Sans-serif font + The following accents are provided: \hat, \breve, \grave, \bar, \acute, \tilde, \vec, \dot, \ddot. All of them have the same syntax, eg to make an overbar you do \bar{o} or to make an o umlaut @@ -539,10 +550,7 @@ cached_font = self._fonts.get(basename) if cached_font is None: - try: - font = FT2Font(basename) - except RuntimeError: - return None + font = FT2Font(basename) cached_font = self.CachedFont(font) self._fonts[basename] = cached_font self._fonts[font.postscript_name] = cached_font @@ -650,13 +658,20 @@ if fontname in self.fontmap and latex_to_bakoma.has_key(sym): basename, num = latex_to_bakoma[sym] slanted = (basename == "cmmi10") or sym in self._slanted_symbols - cached_font = self._get_font(basename) - symbol_name = cached_font.font.get_glyph_name(num) - num = cached_font.glyphmap[num] + try: + cached_font = self._get_font(basename) + except RuntimeError: + pass + else: + symbol_name = cached_font.font.get_glyph_name(num) + num = cached_font.glyphmap[num] elif len(sym) == 1: slanted = (fontname == "it") - cached_font = self._get_font(fontname) - if cached_font is not None: + try: + cached_font = self._get_font(fontname) + except RuntimeError: + pass + else: num = ord(sym) gid = cached_font.charmap.get(num) if gid is not None: @@ -793,9 +808,12 @@ new_fontname = 'rm' slanted = (new_fontname == 'it') or sym in self._slanted_symbols - cached_font = self._get_font(new_fontname) found_symbol = False - if cached_font is not None: + try: + cached_font = self._get_font(new_fontname) + except RuntimeError: + pass + else: try: glyphindex = cached_font.charmap[uniindex] found_symbol = True Modified: branches/transforms/setupext.py =================================================================== --- branches/transforms/setupext.py 2007-12-03 15:23:47 UTC (rev 4561) +++ branches/transforms/setupext.py 2007-12-03 15:27:33 UTC (rev 4562) @@ -94,25 +94,26 @@ BUILT_PATH = False AGG_VERSION = 'agg24' +TCL_TK_CACHE = None # for nonstandard installation/build with --prefix variable numpy_inc_dirs = [] # matplotlib build options, which can be altered using setup.cfg -options = {'display_status': True, - 'verbose': False, - '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, +options = {'display_status': True, + 'verbose': False, + '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 @@ -799,51 +800,6 @@ # or else you'll build for a wrong version of the Tcl # interpreter (leading to nasty segfaults). -class FoundTclTk: - pass - -def find_tcltk(): - """Finds Tcl/Tk includes/libraries/version by interrogating Tkinter.""" - # By this point, we already know that Tkinter imports correctly - import Tkinter - o = FoundTclTk() - try: - tk=Tkinter.Tk() - except Tkinter.TclError: - o.tcl_lib = "/usr/local/lib" - o.tcl_inc = "/usr/local/include" - o.tk_lib = "/usr/local/lib" - o.tk_inc = "/usr/local/include" - o.tkv = "" - else: - tk.withdraw() - o.tcl_lib = os.path.normpath(os.path.join(str(tk.getvar('tcl_library')), '../')) - o.tk_lib = os.path.normpath(os.path.join(str(tk.getvar('tk_library')), '../')) - o.tkv = str(Tkinter.TkVersion)[:3] - o.tcl_inc = os.path.normpath(os.path.join(str(tk.getvar('tcl_library')), - '../../include/tcl'+o.tkv)) - if not os.path.exists(o.tcl_inc): - o.tcl_inc = os.path.normpath(os.path.join(str(tk.getvar('tcl_library')), - '../../include')) - o.tk_inc = os.path.normpath(os.path.join(str(tk.getvar('tk_library')), - '../../include/tk'+o.tkv)) - if not os.path.exists(o.tk_inc): - o.tk_inc = os.path.normpath(os.path.join(str(tk.getvar('tk_library')), - '../../include')) - - if ((not os.path.exists(os.path.join(o.tk_inc,'tk.h'))) and - os.path.exists(os.path.join(o.tcl_inc,'tk.h'))): - o.tk_inc = o.tcl_inc - - if not os.path.exists(o.tcl_inc): - # this is a hack for suse linux, which is broken - if (sys.platform.startswith('linux') and - os.path.exists('/usr/include/tcl.h') and - os.path.exists('/usr/include/tk.h')): - o.tcl_inc = '/usr/include/' - o.tk_inc = '/usr/include/' - return o - def check_for_tk(): gotit = False explanation = None @@ -855,28 +811,26 @@ explanation = 'Tkinter present but import failed' else: if Tkinter.TkVersion < 8.3: - explanation = "Tcl/Tk v8.3 or later required\n" - sys.exit(1) + explanation = "Tcl/Tk v8.3 or later required" else: - try: - tk = Tkinter.Tk() - tk.withdraw() - except Tkinter.TclError: - explanation = """\ -Using default library and include directories for Tcl and Tk because a -Tk window failed to open. You may need to define DISPLAY for Tk to work -so that setup can determine where your libraries are located.""" gotit = True if gotit: module = Extension('test', []) try: - add_tk_flags(module) + explanation = add_tk_flags(module) except RuntimeError, e: explanation = str(e) gotit = False - if not find_include_file(module.include_dirs, "tk.h"): - explanation = 'Tkinter present, but header files are not installed. You may need to install development packages.' + else: + if not find_include_file(module.include_dirs, "tk.h"): + message = 'Tkinter present, but header files are not found. ' + \ + 'You may need to install development packages.' + if explanation is not None: + explanation += '\n' + message + else: + explanation = message + gotit = False if gotit: print_status("Tkinter", "Tkinter: %s, Tk: %s, Tcl: %s" % @@ -887,22 +841,62 @@ print_message(explanation) return gotit +def query_tcltk(): + """Tries to open a Tk window in order to query the Tk object about its library paths. + This should never be called more than once by the same process, as Tk intricacies + may cause the Python interpreter to hang. The function also has a workaround if + no X server is running (useful for autobuild systems).""" + global TCL_TK_CACHE + # Use cached values if they exist, which ensures this function only executes once + if TCL_TK_CACHE is not None: + return TCL_TK_CACHE + + # By this point, we already know that Tkinter imports correctly + import Tkinter + tcl_lib_dir = '' + tk_lib_dir = '' + # First try to open a Tk window (requires a running X server) + try: + tk = Tkinter.Tk() + except Tkinter.TclError: + # Next, start Tcl interpreter without opening a Tk window (no need for X server) + # This feature is available in python version 2.4 and up + try: + tcl = Tkinter.Tcl() + except AttributeError: # Python version not high enough + pass + except Tkinter.TclError: # Something went wrong while opening Tcl + pass + else: + tcl_lib_dir = str(tcl.getvar('tcl_library')) + # Guess Tk location based on Tcl location + tk_lib_dir = tcl_lib_dir.replace('Tcl', 'Tk').replace('tcl', 'tk') + else: + # Obtain Tcl and Tk locations from Tk widget + tk.withdraw() + tcl_lib_dir = str(tk.getvar('tcl_library')) + tk_lib_dir = str(tk.getvar('tk_library')) + + # Save directories and version string to cache + TCL_TK_CACHE = tcl_lib_dir, tk_lib_dir, str(Tkinter.TkVersion)[:3] + return TCL_TK_CACHE + def add_tk_flags(module): 'Add the module flags to build extensions which use tk' - if sys.platform=='win32': + message = None + if sys.platform == 'win32': major, minor1, minor2, s, tmp = sys.version_info - if major==2 and minor1 in [3, 4, 5]: + if major == 2 and minor1 in [3, 4, 5]: module.include_dirs.extend(['win32_static/include/tcl8.4']) module.libraries.extend(['tk84', 'tcl84']) - elif major==2 and minor1==2: + elif major == 2 and minor1 == 2: module.include_dirs.extend(['win32_static/include/tcl8.3']) module.libraries.extend(['tk83', 'tcl83']) else: raise RuntimeError('No tk/win32 support for this python version yet') module.library_dirs.extend([os.path.join(sys.prefix, 'dlls')]) - return - elif sys.platform == 'darwin' : + elif sys.platform == 'darwin': # this config section lifted directly from Imaging - thanks to # the effbot! @@ -914,7 +908,7 @@ join(os.getenv('HOME'), '/Library/Frameworks') ] - # Find the directory that contains the Tcl.framwork and Tk.framework + # Find the directory that contains the Tcl.framework and Tk.framework # bundles. # XXX distutils should support -F! tk_framework_found = 0 @@ -947,15 +941,55 @@ module.include_dirs.extend(tk_include_dirs) module.extra_link_args.extend(frameworks) module.extra_compile_args.extend(frameworks) - return - # you're still here? ok we'll try it this way - o = find_tcltk() # todo: try/except - module.include_dirs.extend([o.tcl_inc, o.tk_inc]) - module.library_dirs.extend([o.tcl_lib, o.tk_lib]) - module.libraries.extend(['tk'+o.tkv, 'tcl'+o.tkv]) + # you're still here? ok we'll try it this way... + else: + # Query Tcl/Tk system for library paths and version string + tcl_lib_dir, tk_lib_dir, tk_ver = query_tcltk() # todo: try/except + # Process base directories to obtain include + lib dirs + if tcl_lib_dir != '' and tk_lib_dir != '': + tcl_lib = os.path.normpath(os.path.join(tcl_lib_dir, '../')) + tk_lib = os.path.normpath(os.path.join(tk_lib_dir, '../')) + tcl_inc = os.path.normpath(os.path.join(tcl_lib_dir, + '../../include/tcl' + tk_ver)) + if not os.path.exists(tcl_inc): + tcl_inc = os.path.normpath(os.path.join(tcl_lib_dir, + '../../include')) + tk_inc = os.path.normpath(os.path.join(tk_lib_dir, + '../../include/tk' + tk_ver)) + if not os.path.exists(tk_inc): + tk_inc = os.path.normpath(os.path.join(tk_lib_dir, + '../../include')) + if ((not os.path.exists(os.path.join(tk_inc,'tk.h'))) and + os.path.exists(os.path.join(tcl_inc,'tk.h'))): + tk_inc = tcl_inc + + if not os.path.exists(tcl_inc): + # this is a hack for suse linux, which is broken + if (sys.platform.startswith('linux') and + os.path.exists('/usr/include/tcl.h') and + os.path.exists('/usr/include/tk.h')): + tcl_inc = '/usr/include' + tk_inc = '/usr/include' + else: + message = """\ +Using default library and include directories for Tcl and Tk because a +Tk window failed to open. You may need to define DISPLAY for Tk to work +so that setup can determine where your libraries are located.""" + tcl_inc = "/usr/local/include" + tk_inc = "/usr/local/include" + tcl_lib = "/usr/local/lib" + tk_lib = "/usr/local/lib" + tk_ver = "" + # Add final versions of directories and libraries to module lists + module.include_dirs.extend([tcl_inc, tk_inc]) + module.library_dirs.extend([tcl_lib, tk_lib]) + module.libraries.extend(['tk' + tk_ver, 'tcl' + tk_ver]) + + return message + def add_windowing_flags(module): 'Add the module flags to build extensions using windowing api' module.include_dirs.extend(['C:/include']) @@ -1019,7 +1053,7 @@ add_ft2font_flags(module) add_pygtk_flags(module) add_numpy_flags(module) - + ext_modules.append(module) BUILT_GTKAGG = True @@ -1034,9 +1068,6 @@ deps, ) - # add agg flags before pygtk because agg only supports freetype1 - # and pygtk includes freetype2. This is a bit fragile. - add_tk_flags(module) # do this first add_agg_flags(module) add_ft2font_flags(module) @@ -1130,7 +1161,7 @@ ext_modules.append(module) BUILT_PATH = True - + def build_image(ext_modules, packages): global BUILT_IMAGE if BUILT_IMAGE: return # only build it if you you haven't already This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |