summaryrefslogtreecommitdiff
path: root/Examples/python/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/python/index.html')
-rw-r--r--Examples/python/index.html112
1 files changed, 112 insertions, 0 deletions
diff --git a/Examples/python/index.html b/Examples/python/index.html
new file mode 100644
index 0000000..8443a85
--- /dev/null
+++ b/Examples/python/index.html
@@ -0,0 +1,112 @@
+<html>
+<head>
+<title>SWIG:Examples:python</title>
+</head>
+
+<body bgcolor="#ffffff">
+<H1>SWIG Python Examples</H1>
+
+<p>
+The following examples illustrate the use of SWIG with Python.
+
+<ul>
+<li><a href="simple/index.html">simple</a>. A minimal example showing how SWIG can
+be used to wrap a C function, a global variable, and a constant.
+<li><a href="constants/index.html">constants</a>. This shows how preprocessor macros and
+certain C declarations are turned into constants.
+<li><a href="variables/index.html">variables</a>. An example showing how to access C global variables from Python.
+<li><a href="value/index.html">value</a>. How to pass and return structures by value.
+<li><a href="class/index.html">class</a>. Wrapping a simple C++ class.
+<li><a href="reference/index.html">reference</a>. C++ references.
+<li><a href="pointer/index.html">pointer</a>. Simple pointer handling.
+<li><a href="funcptr/index.html">funcptr</a>. Pointers to functions.
+</ul>
+
+<h2>Compilation Issues</h2>
+
+<ul>
+<li>To create a Python extension, SWIG is run with the following options:
+
+<blockquote>
+<pre>
+% swig -python interface.i
+</pre>
+</blockquote>
+
+<li>
+Please see the <a href="../../Doc/Manual/Windows.html">Windows</a> page in the main manual for information on using the examples on Windows. <p>
+</li>
+
+<li>On Unix the compilation of examples is done using the file <tt>Example/Makefile</tt>. This
+makefile performs a manual module compilation which is platform specific. Typically,
+the steps look like this (Linux):
+
+<blockquote>
+<pre>
+% swig -python interface.i
+% gcc -fpic -c interface_wrap.c -I/usr/local/include/python1.5
+% gcc -shared interface_wrap.o $(OBJS) -o interfacemodule.so
+% python
+Python 1.5.2 (#3, Oct 9 1999, 22:09:34) [GCC 2.95.1 19990816 (release)] on linux2
+Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
+&gt;&gt;&gt; import interface
+&gt;&gt;&gt; interface.blah(...)
+...
+</pre>
+</blockquote>
+
+<li>The politically "correct" way to compile a Python extension is to follow the steps
+described at <a href="http://www.python.org/doc/current/ext/building-on-unix.html">www.python.org</a>
+or in the most excellent (and shamelessly plugged) <a href="http://islab.cs.uchicago.edu/python">Python Essential Reference</a>:
+
+<p>
+<ol>
+<li>Create a file called <tt>Setup</tt> that looks like the following where $(SRCS) is filled
+in with any other source files you need to build the extension:
+
+<blockquote>
+<pre>
+*shared*
+interface interface_wrap.c $(SRCS)
+</pre>
+</blockquote>
+<li>Copy the file <tt>Makefile.pre.in</tt> from the Python distribution. Usually it's located
+in the directory <tt>/usr/local/lib/python1.5/config</tt> on a Unix machine.
+
+<p>
+<li>Type the following to build the extension:
+
+<blockquote>
+<pre>
+% make -f Makefile.pre.in boot
+% make
+</pre>
+</blockquote>
+<li> And that's it. If you are preparing an extension for distribution, you may want
+to look at the <a href="http://www.python.org/sigs/distutils-sig/">distutils</a>.
+</ol>
+</ul>
+
+<h2>Compatibility</h2>
+
+The examples have been extensively tested on the following platforms:
+
+<ul>
+<li>Linux
+<li>Solaris
+</ul>
+
+All of the examples were last tested with the following configuration (9/1/2000):
+
+<ul>
+<li>Sparc Solaris 2.8.
+<li>gcc-2.95.2
+<li>Python 1.6b1.
+</ul>
+
+Your mileage may vary. If you experience a problem, please let us know by
+contacting us on the <a href="http://www.swig.org/mail.html">mailing lists</a>.
+</body>
+</html>
+
+