[cairo] successfully built bindings via SWIG

Behdad Esfahbod behdad at behdad.org
Wed Mar 19 06:13:51 PDT 2008


Hi Kyle,

This is indeed exciting.  Do you mind attaching the SWIG cairo.i file?

Thanks,

behdad

On Tue, 2008-03-18 at 22:55 -0400, Kyle Johnson wrote:
> I've been wanting to use Cairo with Python for awhile now, but the
> Python bindings are a bit out of date.
> 
> However, I have successfully built working bindings with SWIG for
> Python without having to code much at all (should work with Ruby,
> Perl, etc as well). This is based off the trunk from last night.
> 
> Relevant code (will need some dir location changes depending on where
> you have cairo installed; use pkg-config to find them)...
> 
> cairo.i (with preprocessor directives added to cairo's headers, this
> file wouldn't be needed):
> 
> %module cairo
> %{
> #include <cairo-features.h>
> #include <cairo.h>
> #include <cairo-deprecated.h>
> %}
> 
> %include "/usr/local/include/cairo/cairo-features.h"
> %include "/usr/local/include/cairo/cairo.h"
> %include "/usr/local/include/cairo/cairo-deprecated.h"
> 
> 
> 
> setup.py (run with python setup.py build_ext -i):
> 
> from distutils.core import setup, Extension
> 
> setup(ext_modules = [Extension(
>     "_cairo", # name of output library
>     ["cairo.i"], # swig file
>     libraries = ["cairo"], # link with cairo lib
>     include_dirs=["/usr/local/include/cairo",
> "/usr/local/include/libpng12", "/usr/local/include/pixman-1"]
> )])
> 
> 
> Mac OS 10.5 users will need to run setup.py like this (unless you
> specifically compiled cairo as a universal binary):
> env ARCHFLAGS='' python setup.py build_ext -i
> 
> 
> I hope this is helpful. It's probably a lot easier to maintain SWIG
> bindings than individual bindings for Java, C#, Perl, PHP, Python,
> Ruby, Lua, Scheme, and Ocaml.
> 
> --
> Kyle Johnson
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759



More information about the cairo mailing list