OS X 10.6 port

From: Tony S Yu <tsyu80@...149...>
Date: Mon, Sep 28, 2009 at 8:41 AM
Subject: Re: [matplotlib-devel] Fwd: OS X 10.6 port
To: John Hunter <jdh2358@...149...>
Cc: matplotlib development list <matplotlib-devel@lists.sourceforge.net>

in case anyone has some suggestions, I'm forwarding this from the sage list

From: William Stein <wstein@...149...>
Date: Sun, Sep 27, 2009 at 10:51 PM
Subject: OS X 10.6 port
To: sage-devel <sage-devel@...614...>, John Hunter <jdh2358@...149...>

Hi,

I spent several hours yesterday trying to get matplotlib for Sage to
work on OS X 10.6. On my laptop everything works perfectly, but on
another test machine (bsd.math) the workaround from my laptop doesn't
work. So at this point Sage still does not support OS X 10.6.

The problem is in matplotlib's C++ wrapper for freetype2. It's a
Python extension module implemented directly in C++, and it simply
doesn't work correctly at all. For example, whenever it tries to
raise a Python exception, it just terminates Python with

"11713 Abort trap sage-ipython "$@" -i"

The stack trace looks like this:

#4 0x000000010cd907e2 in ~PythonExtension [inlined] () at
/Users/was/build/sage-4.1.2.alpha4/spkg/build/matplotlib/trunk/matplotlib/CXX/Extensions.hxx:778
#5 0x000000010cd907e2 in FT2Font::FT2Font (this=0x10baf2b10,
facefile=@...772...) at src/ft2font.cpp:778
#6 0x000000010cd90e98 in ft2font_module::new_ft2font (this=<value
temporarily unavailable, due to optimizations>, args=<value
temporarily unavailable, due to optimizations>) at src/ft2font.cpp:778
#7 0x000000010cd94912 in
Py::ExtensionModule<ft2font_module>::invoke_method_varargs
(this=0x10ce05f10, name=@...773..., args=@...774...) at
Extensions.hxx:422
#8 0x000000010cda3190 in method_varargs_call_handler
(_self_and_name_tuple=<value temporarily unavailable, due to

, _args=<value temporarily unavailable, due to
) at CXX/cxx_extensions.cxx:1403

...

I thought I'd chime in since I recently upgraded to OSX 10.6. I don't
think I ever got this error, so I probably didn't have the same issue,
but just in case...

I reinstalled freetype2, but I'm not sure if I needed to. I also made
a change to setupext.py so that the setup script could find freetype2,
but this doesn't seem to be your problem because your errors don't
occur during the build.

Did you happen to build on top of an old install? I had to clean out
the old compiled extensions before everything would build properly. I
had to clean out the build directory (obviously), but there are also
*.so files in lib/matplotlib and lib/matplotlib/backends.

I should note that I'm built on top of the system python (2.6.1) and I
did not use make.osx.

I did a 100% clean build from source of Sage, which means building
Python and essentially all dependencies (including freetype) in a
single self-contained directory. I've replicated this on maybe 5 or
6 different OS X 10.6 machines. It is a total show stopper for
releasing the next version of Sage, and is in fact the only problem
left (of many) in porting Sage to OS X 10.6

I used the latest version of XCode, which comes with OS X 10.6:
  gcc version 4.2.1 (Apple Inc. build 5646)

The version of Python is:
        Python 2.6.2 (r262:71600, Sep 27 2009, 13:41:53)

The Abort trap appears when building the font cache the moment an
exception is raised in C++ code. By hacking around that exception
getting raised, the Abort trap happens when some exception somewhere
else happens in Matplotlib's C++ code. Etc.

I'm going to try looking into pyCXX now, since that seems the best hope.

William

···

On Mon, Sep 28, 2009 at 8:47 AM, John Hunter <jdh2358@...149...> wrote:

---------- Forwarded message ----------
On Sep 28, 2009, at 2:14 AM, John Hunter wrote:

---------- Forwarded message ----------

From: Tony S Yu <tsyu80@...149...>
Date: Mon, Sep 28, 2009 at 8:41 AM
Subject: Re: [matplotlib-devel] Fwd: OS X 10.6 port
To: John Hunter <jdh2358@...149...>
Cc: matplotlib development list <matplotlib-devel@lists.sourceforge.net>

in case anyone has some suggestions, I'm forwarding this from the sage list

From: William Stein <wstein@...149...>
Date: Sun, Sep 27, 2009 at 10:51 PM
Subject: OS X 10.6 port
To: sage-devel <sage-devel@...614...>, John Hunter <jdh2358@...149...>

Hi,

I spent several hours yesterday trying to get matplotlib for Sage to
work on OS X 10.6. On my laptop everything works perfectly, but on
another test machine (bsd.math) the workaround from my laptop doesn't
work. So at this point Sage still does not support OS X 10.6.

The problem is in matplotlib's C++ wrapper for freetype2. It's a
Python extension module implemented directly in C++, and it simply
doesn't work correctly at all. For example, whenever it tries to
raise a Python exception, it just terminates Python with

"11713 Abort trap sage-ipython "$@" -i"

The stack trace looks like this:

#4 0x000000010cd907e2 in ~PythonExtension [inlined] () at
/Users/was/build/sage-4.1.2.alpha4/spkg/build/matplotlib/trunk/matplotlib/CXX/Extensions.hxx:778
#5 0x000000010cd907e2 in FT2Font::FT2Font (this=0x10baf2b10,
facefile=@...772...) at src/ft2font.cpp:778
#6 0x000000010cd90e98 in ft2font_module::new_ft2font (this=<value
temporarily unavailable, due to optimizations>, args=<value
temporarily unavailable, due to optimizations>) at src/ft2font.cpp:778
#7 0x000000010cd94912 in
Py::ExtensionModule<ft2font_module>::invoke_method_varargs
(this=0x10ce05f10, name=@...773..., args=@...774...) at
Extensions.hxx:422
#8 0x000000010cda3190 in method_varargs_call_handler
(_self_and_name_tuple=<value temporarily unavailable, due to
>, _args=<value temporarily unavailable, due to
>) at CXX/cxx_extensions.cxx:1403
...

I thought I'd chime in since I recently upgraded to OSX 10.6. I don't
think I ever got this error, so I probably didn't have the same issue,
but just in case...

I reinstalled freetype2, but I'm not sure if I needed to. I also made
a change to setupext.py so that the setup script could find freetype2,
but this doesn't seem to be your problem because your errors don't
occur during the build.

Did you happen to build on top of an old install? I had to clean out
the old compiled extensions before everything would build properly. I
had to clean out the build directory (obviously), but there are also
*.so files in lib/matplotlib and lib/matplotlib/backends.

I should note that I'm built on top of the system python (2.6.1) and I
did not use make.osx.

I did a 100% clean build from source of Sage, which means building
Python and essentially all dependencies (including freetype) in a
single self-contained directory. I've replicated this on maybe 5 or
6 different OS X 10.6 machines. It is a total show stopper for
releasing the next version of Sage, and is in fact the only problem
left (of many) in porting Sage to OS X 10.6

I used the latest version of XCode, which comes with OS X 10.6:
gcc version 4.2.1 (Apple Inc. build 5646)

The version of Python is:
Python 2.6.2 (r262:71600, Sep 27 2009, 13:41:53)

The Abort trap appears when building the font cache the moment an
exception is raised in C++ code. By hacking around that exception
getting raised, the Abort trap happens when some exception somewhere
else happens in Matplotlib's C++ code. Etc.

I'm going to try looking into pyCXX now, since that seems the best hope.

I rebuild matplotlib using the newest version of pyCXX (which has seen
4 new releases since the version in matplotlib), but the problem
remains the same. (I've also tried using the latest version of
libfreetype.)

bash-3.2$ python
Python 2.6.2 (r262:71600, Sep 27 2009, 13:41:53)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

import pylab

Abort trap

···

On Mon, Sep 28, 2009 at 8:55 AM, William Stein <wstein@...149...> wrote:

On Mon, Sep 28, 2009 at 8:47 AM, John Hunter <jdh2358@...149...> wrote:

---------- Forwarded message ----------
On Sep 28, 2009, at 2:14 AM, John Hunter wrote:

---------- Forwarded message ----------

-----

(gdb) bt
#0 0x00007fff82adf096 in __kill ()
#1 0x00007fff82b800c2 in abort ()
#2 0x00000001015d0d51 in uw_init_context_1 ()
#3 0x00000001015d14cc in _Unwind_Resume ()
#4 0x000000010182f7f3 in ~PythonExtension [inlined] () at
/Users/was/build/sage-4.1.2.alpha4/spkg/build/matplotlib/trunk/matplotlib/CXX/Python2/ExtensionOldType.hxx:778
#5 0x000000010182f7f3 in FT2Font::FT2Font (this=0x101171620,
facefile=@...775...) at src/ft2font.cpp:778
#6 0x000000010182fee8 in ft2font_module::new_ft2font (this=<value
temporarily unavailable, due to optimizations>, args=<value
temporarily unavailable, due to optimizations>) at src/ft2font.cpp:778
#7 0x0000000101830a80 in
Py::ExtensionModule<ft2font_module>::invoke_method_varargs
(this=<value temporarily unavailable, due to optimizations>,
method_def=<value temporarily unavailable, due to optimizations>,
args=<value temporarily unavailable, due to optimizations>) at
ExtensionModule.hxx:184
#8 0x000000010183f8d0 in method_varargs_call_handler
(_self_and_name_tuple=<value temporarily unavailable, due to

, _args=<value temporarily unavailable, due to
) at CXX/cxx_extensions.cxx:1714

#9 0x00000001000b3b25 in PyEval_EvalFrameEx ()
#10 0x00000001000b4ce0 in PyEval_EvalCodeEx ()
#11 0x00000001000b2afd in PyEval_EvalFrameEx ()
#12 0x00000001000b4ce0 in PyEval_EvalCodeEx ()