build matplotlib-0.98.3 on Solaris with SunStudio 12

1. Set the CBE environment (/opt/jdsbld/bin/env.sh), and export CC=$CXX, so that /usr/lib/python2.4/pycc would eventually use the C++ compiler in SunStudio.

2. Download the source code from http://matplotlib.sourceforge.net, then apply the following patch,

--- setupext.py	2008-08-04 02:15:22.000000000 +0800
+++ setupext.py	2008-11-03 17:08:41.387138200 +0800
@@ -218,6 +218,8 @@ def get_win32_compiler():
 win32_compiler = get_win32_compiler()
 if sys.platform == 'win32' and win32_compiler == 'msvc':
     std_libs = []
+elif sys.platform == 'sunos5':
+    std_libs = ['Crun', 'Cstd']
 else:
     std_libs = ['stdc++', 'm']

@@ -298,6 +300,7 @@ def check_for_freetype():
         for d in basedirs:
             module.include_dirs.append(os.path.join(d, 'freetype2'))

+    module.include_dirs.append('/usr/include')
     print_status("freetype2", get_pkgconfig_version('freetype2'))
     if not find_include_file(module.include_dirs, 'ft2build.h'):
         print_message(
--- src/_backend_gdk.c	2008-08-04 02:14:18.000000000 +0800
+++ src/_backend_gdk.c	2008-11-03 17:31:32.896210699 +0800
@@ -62,6 +62,7 @@ static PyMethodDef _backend_gdk_function
     { NULL, NULL, 0 }
 };

+extern "C"
 DL_EXPORT(void)
 init_backend_gdk(void)
 {

3. Then build and install,

$ python setup.py build
$ pfexec python setup.py install

Note: this version of matplotlib requires numpy-1.1 or higher version, you need build and install a newer one since solaris only has 1.0.4.

9 thoughts on “build matplotlib-0.98.3 on Solaris with SunStudio 12

  1. I thought this post was going to be a godsend, because I really want to use Matplotlib... However, I tried the above, and ran into more problems with version 0.98.5.3.

    When compiling src/ft2font.cpp, I get the following:

    building 'matplotlib.ft2font' extension
    CC -xO3 -xarch=v8 -DNDEBUG -O -xcode=pic32 -I/opt/csw/lib/python/site-packages/numpy/core/include -I/opt/csw/include/freetype2 -I/opt/csw/include -I. -I/opt/csw/include/python2.6 -c src/ft2font.cpp -o build/temp.solaris-2.10-sun4u-2.6/src/ft2font.o
    "/opt/sunstudio12.1/prod/include/CC/Cstd/rw/traits", line 531: Error: The function "wcsstr" must have a prototype.

    There's also a number of warnings, but they come after the above.

    I'm using Python 2.6 from the opencsw.org distribution.

    If you have any pointers, I'd appreciate the help.

  2. Hi,
    related to the previous post, I'm trying to get the newest SVN version of matplotlib to work on OpenSolaris 2009.06 (developer repository) with SunStudio Express and Python 2.6. Your patches above worked like a charm, but only after I commented out the line

    $CC --version >/dev/null 2>&1 && is_gcc=yes

    in /usr/lib/python2.6/pyCC, because it kept detecting the Sun compiler as being gnu.
    I can now import pylab, but when I try to plot something I end up with
    [...]
    File "/local/Downloads/matplotlib/lib/matplotlib/backends/backend_tkagg.py", line 90, in new_figure_manager
    window = Tk.Tk()
    File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1643, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
    _tkinter.TclError: Can't find a usable tk.tcl in the following directories:
    /usr/lib/tcl8.4/tk8.4 /usr/lib/tk8.4 /opt/csw/lib/tk8.4 /opt/lib/tk8.4 /opt/csw/library /opt/library /opt/tk8.4.18/library /tk8.4.18/library

    /usr/lib/tk8.4/tk.tcl: no event type or button # or keysym
    no event type or button # or keysym
    while executing
    "bind Listbox {
    %W yview scroll [expr {- (%D / 120) * 4}] units
    }"
    [...]
    I'm using the following Tcl package:
    pkg:/SUNWTcl@8.4.18,5.11-0.118:20090707T211100Z

    Maybe if you try Python2.6, could you check this as well, pleeease? Meanwhlie, I'll try somewhat older versions of matplotlib...
    Thanks, Martin

  3. I'm sorry that I'm crazy busy these days, that I don't have time to look at this issue. I would let you know, if I have any progress.

  4. Hi,

    after successfully building matplotlib is your intention to make it available on jucr.opensolaris.org? I would be great!

    I'm also interested in scipy and if nobody has plans to make a package to be published on jucr.opensolaris.org, I was thinking of trying myself.

    Thanks,
    Fede

  5. Hi,

    is your intention to publish scipy and matplotlib as packages on jucr.opensolaris.org at some point? I would really be great!!

    Thanks,
    Fede

  6. bnitz, great, it's so wonderful! And thanks so much for informing me, sorry that I did not follow up this since Aug, I'm just too busy on my new job :( ...

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

To submit your comment, click the image below where it asks you to...
Clickcha - The One-Click Captcha