100 likes | 238 Views
A PyTrilinos Overview for Developers. Bill Spotz Trilinos Users Group Meeting November 4, 2004. Outline. Quick PyTrilinos demo Wrapping code for python SWIG (Simple Wrapper Interface Generator) Interface files Compiling wrapped code Python distutils module setup.py scripts
E N D
A PyTrilinos Overview for Developers Bill Spotz Trilinos Users Group Meeting November 4, 2004
Outline • Quick PyTrilinos demo • Wrapping code for python • SWIG (Simple Wrapper Interface Generator) • Interface files • Compiling wrapped code • Python distutils module • setup.py scripts • Integration into Trilinos repository • Current structure • Alternative structure • Unit test example • PyTrilinos Issues
Simple Wrapper Interface Generator Source languages: C C++ Target languages: chicken csharp guile java mzscheme ocaml perl php python ruby sexp tcl xml Generate code using target language API that converts arguments calls function (method) converts return arguments Wrapping Code for Python: SWIG
Wrapping Code for Python: SWIG • SWIG directives in interface file • %{ … %}insert source code • %ignoreignore code • %renamerename function, class, etc. • %typemapdefine argument conversions • %includewrap functions, etc., in header file • %extendnew methods for a class • Command-line invocation: • swig -I../include -python -c++ interface.i • Produces • interface_wrap.cxx • interface.py
Compiling Wrapped Code • Need to compile interface_wrap.cxx and link to compiled source code to produce dynamic library or shared object compatible with python. • Python distutils module to the rescue: knows how python was compiled on current platform and how new modules need to be compiled. • By convention, setup.py script • import distutils • Extension class • setup() function • Commands: • python setup.py build • python setup.py install • etc.
Integration into Trilinos Repository Trilinos config doc packages testharness epetra epetraext nox PyTrilinos Makefile.am configure.ac setup.py src NOX Epetra.i EpetraExt.i Abstract.i Epetra.i Parameter.i Solver.i StatusTest.i
Alternative (Proposed) Structure Trilinos config doc packages testharness epetra epetraext nox Makefile.am configure.ac python src test Makefile.am setup.py Epetra.i
PyTrilinos Issues • Dependencies • Currently serial only . . . • Python • Numeric • SWIG (1.3.19 - 1.3.21 . . . not 1.3.22) • SWIG issues • Could make *_wrap.cxx files part of distribution . . . • Currently relies on installed runtime libraries (which are deprecated in 1.3.22) • Could compile runtime library locally . . . libtool • Plans • Eliminate SWIG dependency • Make structure decision • Add MPI • Add more Trilinos packages…