Skip to content

Commit 10376a7

Browse files
committed
added mdehoon's native macosx patch
svn path=/trunk/matplotlib/; revision=6530
1 parent b960c4b commit 10376a7

File tree

7 files changed

+54
-19
lines changed

7 files changed

+54
-19
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2008-12-08 Added mdehoon's native maxosx backend from sf patch 2179017
2+
13
2008-12-08 Removed the prints in the set_*style commands. Return the
24
list of pprinted strings instead
35

lib/matplotlib/mathtext.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2749,7 +2749,8 @@ class MathTextParser(object):
27492749
'ps' : MathtextBackendPs,
27502750
'pdf' : MathtextBackendPdf,
27512751
'svg' : MathtextBackendSvg,
2752-
'cairo' : MathtextBackendCairo
2752+
'cairo' : MathtextBackendCairo,
2753+
'macosx': MathtextBackendAgg,
27532754
}
27542755

27552756
_font_type_mapping = {

lib/matplotlib/rcsetup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
# The capitalized forms are needed for ipython at present; this may
2424
# change for later versions.
2525

26-
interactive_bk = ['GTK', 'GTKAgg', 'GTKCairo', 'FltkAgg', 'QtAgg', 'Qt4Agg',
27-
'TkAgg', 'WX', 'WXAgg', 'CocoaAgg']
26+
interactive_bk = ['GTK', 'GTKAgg', 'GTKCairo', 'FltkAgg', 'MacOSX',
27+
'QtAgg', 'Qt4Agg', 'TkAgg', 'WX', 'WXAgg', 'CocoaAgg']
2828

2929

3030
non_interactive_bk = ['agg', 'cairo', 'emf', 'gdk',

matplotlibrc.template

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
#### CONFIGURATION BEGINS HERE
2525

2626
# the default backend; one of GTK GTKAgg GTKCairo CocoaAgg FltkAgg
27-
# QtAgg Qt4Agg TkAgg WX WXAgg Agg Cairo GDK PS PDF SVG Template You
28-
# can also deploy your own backend outside of matplotlib by referring
29-
# to the module name (which must be in the PYTHONPATH) as
27+
# MacOSX QtAgg Qt4Agg TkAgg WX WXAgg Agg Cairo GDK PS PDF SVG Template
28+
# You can also deploy your own backend outside of matplotlib by
29+
# referring to the module name (which must be in the PYTHONPATH) as
3030
# 'module://my_backend'
3131
backend : %(backend)s
3232

setup.cfg.template

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ tag_svn_revision = 1
3232

3333
[gui_support]
3434
# Matplotlib supports multiple GUI toolkits, including Cocoa,
35-
# GTK, Fltk, Qt, Qt4, Tk, and WX. Support for many of these
36-
# toolkits requires AGG, the Anti-Grain Geometry library, which
37-
# is provided by matplotlib and built by default.
35+
# GTK, Fltk, MacOSX, Qt, Qt4, Tk, and WX. Support for many of
36+
# these toolkits requires AGG, the Anti-Grain Geometry library,
37+
# which is provided by matplotlib and built by default.
3838
#
3939
# Some backends are written in pure Python, and others require
4040
# extension code to be compiled. By default, matplotlib checks
@@ -59,16 +59,17 @@ tag_svn_revision = 1
5959
#gtkagg = False
6060
#tkagg = False
6161
#wxagg = False
62+
#macosx = False
6263

6364
[rc_options]
6465
# User-configurable options
6566
#
66-
# Default backend, one of: Agg, Cairo, CocoaAgg, GTK, GTKAgg,
67-
# GTKCairo, FltkAgg, Pdf, Ps, QtAgg, Qt4Agg, SVG, TkAgg, WX, WXAgg.
67+
# Default backend, one of: Agg, Cairo, CocoaAgg, GTK, GTKAgg, GTKCairo,
68+
# FltkAgg, MacOSX, Pdf, Ps, QtAgg, Qt4Agg, SVG, TkAgg, WX, WXAgg.
6869
#
6970
# The Agg, Ps, Pdf and SVG backends do not require external
70-
# dependencies. Do not choose GTK, GTKAgg, GTKCairo, TkAgg or WXAgg if
71-
# you have disabled the relevent extension modules. Agg will be used
71+
# dependencies. Do not choose GTK, GTKAgg, GTKCairo, MacOSX, TkAgg or WXAgg
72+
# if you have disabled the relevent extension modules. Agg will be used
7273
# by default.
7374
#
7475
#backend = Agg

setup.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
import glob
2727
from distutils.core import setup
2828
from setupext import build_agg, build_gtkagg, build_tkagg, build_wxagg,\
29-
build_ft2font, build_image, build_windowing, build_path, \
29+
build_macosx, build_ft2font, build_image, build_windowing, build_path, \
3030
build_contour, build_delaunay, build_nxutils, build_traits, build_gdk, \
3131
build_ttconv, print_line, print_status, print_message, \
3232
print_raw, check_for_freetype, check_for_libpng, check_for_gtk, \
33-
check_for_tk, check_for_wx, check_for_numpy, check_for_qt, check_for_qt4, \
34-
check_for_cairo, check_provide_traits, check_provide_pytz, \
35-
check_provide_dateutil, check_provide_configobj, check_for_dvipng, \
36-
check_for_ghostscript, check_for_latex, check_for_pdftops, \
37-
check_for_datetime, options, build_png
33+
check_for_tk, check_for_wx, check_for_macosx, check_for_numpy, \
34+
check_for_qt, check_for_qt4, check_for_cairo, check_provide_traits, \
35+
check_provide_pytz, check_provide_dateutil, check_provide_configobj, \
36+
check_for_dvipng, check_for_ghostscript, check_for_latex, \
37+
check_for_pdftops, check_for_datetime, options, build_png
3838
#import distutils.sysconfig
3939

4040
# jdh
@@ -149,6 +149,11 @@
149149
build_gtkagg(ext_modules, packages)
150150
rc['backend'] = 'GTKAgg'
151151

152+
if options['build_macosx']:
153+
if check_for_macosx() or (options['build_macosx'] is True):
154+
build_macosx(ext_modules, packages)
155+
rc['backend'] = 'MacOSX'
156+
152157
# These are informational only. We don't build any extensions for them.
153158
check_for_qt()
154159
check_for_qt4()

setupext.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
BUILT_TTCONV = False
7777
BUILT_GTKAGG = False
7878
BUILT_IMAGE = False
79+
BUILT_MACOSX = False
7980
BUILT_TKAGG = False
8081
BUILT_WXAGG = False
8182
BUILT_WINDOWING = False
@@ -105,6 +106,7 @@
105106
'build_gtkagg': 'auto',
106107
'build_tkagg': 'auto',
107108
'build_wxagg': 'auto',
109+
'build_macosx': 'auto',
108110
'build_image': True,
109111
'build_windowing': True,
110112
'backend': None,
@@ -867,6 +869,17 @@ def check_for_tk():
867869
print_message(explanation)
868870
return gotit
869871

872+
def check_for_macosx():
873+
gotit = False
874+
import sys
875+
if sys.platform=='darwin':
876+
gotit = True
877+
if gotit:
878+
print_status("Mac OS X native", "yes")
879+
else:
880+
print_status("Mac OS X native", "no")
881+
return gotit
882+
870883
def query_tcltk():
871884
"""Tries to open a Tk window in order to query the Tk object about its library paths.
872885
This should never be called more than once by the same process, as Tk intricacies
@@ -1214,6 +1227,19 @@ def build_wxagg(ext_modules, packages):
12141227
ext_modules.append(module)
12151228
BUILT_WXAGG = True
12161229

1230+
1231+
def build_macosx(ext_modules, packages):
1232+
global BUILT_MACOSX
1233+
if BUILT_MACOSX: return # only build it if you you haven't already
1234+
module = Extension('matplotlib.backends._macosx',
1235+
['src/_macosx.m'],
1236+
extra_link_args = ['-framework','Cocoa'],
1237+
)
1238+
add_numpy_flags(module)
1239+
ext_modules.append(module)
1240+
BUILT_MACOSX = True
1241+
1242+
12171243
def build_png(ext_modules, packages):
12181244
global BUILT_PNG
12191245
if BUILT_PNG: return # only build it if you you haven't already

0 commit comments

Comments
 (0)