Build matplotlib 0.98 on OSX

Is this really the current solution to building matplotlib on OSX,
installing a new compiler and hacking the python Makefile?

I was able to build matplotlib 0.91.2 just fine on OSX, sometime
around March I checked out the truck to fix a bug and discovered I
couldn't build the svn version. Matplotlib is the only package with a
dependency on gcc 4.2, all the other packages I build, numpy, scipy,
ipython, etc... build with gcc 4.0. Why do you have this dependency?
Is there an easier solution?

I'm reluctant to upgrade to gcc 4.2 and loose the ability to build
other packages I need.

Chris

···

On Thu, May 29, 2008 at 4:51 AM, Joshua Lippai <discerptor@...287...> wrote:

I've consistently been able to build matplotlib on OS X. Just make
sure you have all the dependencies installed. Personally, I have lbpng
and whatnot installed in /usr/local instead of /usr/X11. I don't know
if that'll help. Also, I use the GCC 4.2 that Apple has available for
download on developer.apple.com. Then you just change the Makefile in
the /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/config/
directory to not use Wno-long-double or no-cpp-precomp. I also took
out all the ppc arch flags since it was causing some issues there with
my versions of libpng and whatnot technically not being universal
binaries. If you don't want to build univeral binary versions of your
dependencies or use the ones alread provided in /usr/X11 (which are
universal I think), you should make Python only build for your
architecture, which is what I did.

My only issue with matplotlib thusfar seems to be the inability to do
the plot3d examples from the scipy website, but I'm told that stuff is
officially unsupported anyway.

Josh

--
Christopher Burns
Computational Infrastructure for Research Labs
10 Giannini Hall, UC Berkeley
phone: 510.643.4014
http://cirl.berkeley.edu/

Christopher Burns wrote:

Is this really the current solution to building matplotlib on OSX,
installing a new compiler and hacking the python Makefile?

No, I don't think so. I haven't built it in a while, but I think the OP chose to install 4.2 for some other reason, and maybe had to patch the Makefile because of that.

Charlie, what are you building with?

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...

An upgrade to 4.2 is not required. On the svn trunk (0.98) there is a
bug in the apple gcc compiler with our agg extension that causes a
compiler error if the optimization level is -O3. You can work around
it by using -Os instead. I build with the default apple compiler and
have a line in the Makefile in the mpl src dir that reads::

    build_osx105:
      CFLAGS="-Os -arch i386 -arch ppc" LDFLAGS="-Os -arch i386 -arch
ppc" python setup.py build

Some of the other suggested tricks like editing the Python Makefile
configs may be handy so you don't have to pass around CFLAGS and
LDFLAGS, but they are in no way required. My build notes are at:

    http://ipython.scipy.org/moin/Py4Science/InstallationOSX

but I need to update them with the info in this email. Don't ignore
the pkgconfig stuff, as it is helpful to help find freetype and
libpng. Here is my build output::

    home:~/mpl> rm -rf build
    home:~/mpl> gcc --version
    i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5465)

home:~/mpl> make build_osx105 >& build.out

build.out (112 KB)

···

On Thu, Jun 5, 2008 at 4:19 PM, Christopher Burns <cburns@...1016...> wrote:

Is this really the current solution to building matplotlib on OSX,
installing a new compiler and hacking the python Makefile?

I was able to build matplotlib 0.91.2 just fine on OSX, sometime
around March I checked out the truck to fix a bug and discovered I
couldn't build the svn version. Matplotlib is the only package with a
dependency on gcc 4.2, all the other packages I build, numpy, scipy,
ipython, etc... build with gcc 4.0. Why do you have this dependency?
Is there an easier solution?

I'm reluctant to upgrade to gcc 4.2 and loose the ability to build
other packages I need.

'make build_osx105' worked great, thank you!

Sorry I didn't see that earlier.

···

On Thu, Jun 5, 2008 at 6:50 PM, John Hunter <jdh2358@...287...> wrote:

On Thu, Jun 5, 2008 at 4:19 PM, Christopher Burns <cburns@...1016...> wrote:

Is this really the current solution to building matplotlib on OSX,
installing a new compiler and hacking the python Makefile?

I was able to build matplotlib 0.91.2 just fine on OSX, sometime
around March I checked out the truck to fix a bug and discovered I
couldn't build the svn version. Matplotlib is the only package with a
dependency on gcc 4.2, all the other packages I build, numpy, scipy,
ipython, etc... build with gcc 4.0. Why do you have this dependency?
Is there an easier solution?

I'm reluctant to upgrade to gcc 4.2 and loose the ability to build
other packages I need.

An upgrade to 4.2 is not required. On the svn trunk (0.98) there is a
bug in the apple gcc compiler with our agg extension that causes a
compiler error if the optimization level is -O3. You can work around
it by using -Os instead. I build with the default apple compiler and
have a line in the Makefile in the mpl src dir that reads::

   build_osx105:
           CFLAGS="-Os -arch i386 -arch ppc" LDFLAGS="-Os -arch i386 -arch
ppc" python setup.py build

Some of the other suggested tricks like editing the Python Makefile
configs may be handy so you don't have to pass around CFLAGS and
LDFLAGS, but they are in no way required. My build notes are at:

   http://ipython.scipy.org/moin/Py4Science/InstallationOSX

but I need to update them with the info in this email. Don't ignore
the pkgconfig stuff, as it is helpful to help find freetype and
libpng. Here is my build output::

   home:~/mpl> rm -rf build
   home:~/mpl> gcc --version
   i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5465)

home:~/mpl> make build_osx105 >& build.out

--
Christopher Burns
Computational Infrastructure for Research Labs
10 Giannini Hall, UC Berkeley
phone: 510.643.4014
http://cirl.berkeley.edu/

I just used the default 10.5 compiler. I didn't use -Os for the whole
run though. I would just copy the gcc command on the files where it
failed and replace -O3 with -Os. Kind of lame, I know, but most the
build I did was ran with -O3.

- Charlie

···

On Thu, Jun 5, 2008 at 8:19 PM, Christopher Barker <Chris.Barker@...259...> wrote:

Christopher Burns wrote:

Is this really the current solution to building matplotlib on OSX,
installing a new compiler and hacking the python Makefile?

No, I don't think so. I haven't built it in a while, but I think the OP
chose to install 4.2 for some other reason, and maybe had to patch the
Makefile because of that.

Charlie, what are you building with?

-Chris

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

I'm sure that would work, but John's make target 'build_osx105' is
much easier, particularly for end users.

$ make build_osx105

That's it. Unpythonic in it's appearance, but sets the required
CFLAGS and calls setup.py.

···

On Fri, Jun 6, 2008 at 7:41 AM, Charlie Moad <cwmoad@...287...> wrote:

I just used the default 10.5 compiler. I didn't use -Os for the whole
run though. I would just copy the gcc command on the files where it
failed and replace -O3 with -Os. Kind of lame, I know, but most the
build I did was ran with -O3.

- Charlie

--
Christopher Burns
Computational Infrastructure for Research Labs
10 Giannini Hall, UC Berkeley
phone: 510.643.4014
http://cirl.berkeley.edu/

What Charlie is saying is my solution will result in a slower mpl than
his, since my solution uses a lower optimization level for all files,
and he uses the lower level only on the problematic files. But the
make solution has the advantage of being a one step automatic build,
and I'm not looking for great performance on my laptop usually...

JDH

···

On Fri, Jun 6, 2008 at 11:16 AM, Christopher Burns <cburns@...1016...> wrote:

I'm sure that would work, but John's make target 'build_osx105' is
much easier, particularly for end users.

$ make build_osx105

That's it. Unpythonic in it's appearance, but sets the required
CFLAGS and calls setup.py.

Has this been reported to Apple?

Cheers

Adam

···

On Thu, Jun 5, 2008 at 8:50 PM, John Hunter <jdh2358@...287...> wrote:

On the svn trunk (0.98) there is a
bug in the apple gcc compiler with our agg extension that causes a
compiler error if the optimization level is -O3.

You don't have to do everything that I did, but I have libpng and
whatnot installed in /usr/local for other purposes anyway, and I
didn't have a particular need to build a universal binary version of
matplotlib. Furthermore, using GCC 4.2, while forcing one to get rid
of Wno-long-double (an Apple-only thing anyway, and I think it's bad
practice to include assumption of such options in a Makefile), allowed
me to keep -O3 since it does not have that particular bug. So IF you
want to keep the O3 optimisation, then you should install the 4.2
compiler, make sure it gets used, and eliminate the -Wno-long-double
flag from the Makefile. No other changes necessary relative to the
standard instructions. I've filed a bug report with Apple about the
problem with their GCC 4.0.1 in Xcode 3, and as soon as I can get my
bug reporting ability up and running again (login has been wonky
lately), I'm following up with some additional information they asked
for. I'm sorry if I caused some confusion with my personal
preferences.

Josh

···

On Thu, Jun 5, 2008 at 5:19 PM, Christopher Burns <cburns@...1016...> wrote:

Is this really the current solution to building matplotlib on OSX,
installing a new compiler and hacking the python Makefile?

I was able to build matplotlib 0.91.2 just fine on OSX, sometime
around March I checked out the truck to fix a bug and discovered I
couldn't build the svn version. Matplotlib is the only package with a
dependency on gcc 4.2, all the other packages I build, numpy, scipy,
ipython, etc... build with gcc 4.0. Why do you have this dependency?
Is there an easier solution?

I'm reluctant to upgrade to gcc 4.2 and loose the ability to build
other packages I need.

Chris

On Thu, May 29, 2008 at 4:51 AM, Joshua Lippai <discerptor@...287...> wrote:

I've consistently been able to build matplotlib on OS X. Just make
sure you have all the dependencies installed. Personally, I have lbpng
and whatnot installed in /usr/local instead of /usr/X11. I don't know
if that'll help. Also, I use the GCC 4.2 that Apple has available for
download on developer.apple.com. Then you just change the Makefile in
the /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/config/
directory to not use Wno-long-double or no-cpp-precomp. I also took
out all the ppc arch flags since it was causing some issues there with
my versions of libpng and whatnot technically not being universal
binaries. If you don't want to build univeral binary versions of your
dependencies or use the ones alread provided in /usr/X11 (which are
universal I think), you should make Python only build for your
architecture, which is what I did.

My only issue with matplotlib thusfar seems to be the inability to do
the plot3d examples from the scipy website, but I'm told that stuff is
officially unsupported anyway.

Josh

--
Christopher Burns
Computational Infrastructure for Research Labs
10 Giannini Hall, UC Berkeley
phone: 510.643.4014
http://cirl.berkeley.edu/