diff -ruN ../empty/readme.txt ./readme.txt --- ../empty/readme.txt 1970-01-01 12:00:00.000000000 +1200 +++ ./readme.txt 2010-08-25 13:26:02.476800996 +1200 @@ -0,0 +1,18 @@ +I tested building this module under windows 2000 with python 2.6 and with python 2.5 +both in normal windows location c:/pythonXX and also tested with python2.5 +installed under C:/Program Files/Python. + +Command to build extension: + +python setup.py build_ext -c mingw32 --inplace + + +Then from python can use with +>>> import example +>>> example.gcd + + +For linux its even easier: +python setup.py build_ext --inplace + +then move the _example.so file from build into the current dir... diff -ruN ../empty/without_space/example.c ./without_space/example.c --- ../empty/without_space/example.c 1970-01-01 12:00:00.000000000 +1200 +++ ./without_space/example.c 2008-12-18 15:04:18.000000000 +1300 @@ -0,0 +1,19 @@ +/* File : example.c */ + +/* A global variable */ +double Foo = 3.0; + +/* Compute the greatest common divisor of positive integers */ +int gcd(int x, int y) { + int g; + g = y; + while (x > 0) + { + g = x; + x = y % x; + y = g; + } + return g; +} + + diff -ruN ../empty/without_space/example.i ./without_space/example.i --- ../empty/without_space/example.i 1970-01-01 12:00:00.000000000 +1200 +++ ./without_space/example.i 2008-12-18 15:04:18.000000000 +1300 @@ -0,0 +1,7 @@ +/* File : example.i */ +%module example + +%inline %{ +extern int gcd(int x, int y); +extern double Foo; +%} diff -ruN ../empty/without_space/setup.py ./without_space/setup.py --- ../empty/without_space/setup.py 1970-01-01 12:00:00.000000000 +1200 +++ ./without_space/setup.py 2010-08-25 13:27:39.888036557 +1200 @@ -0,0 +1,18 @@ +# setup.py for compiling a python extension with swig... +import distutils +from distutils.core import setup, Extension + +setup( + name = "Example C Extension wrapped up all nice for python", + author = 'Brian Thorne', + author_email = 'hardbyte+python@gmail.com', + license='GPL v3 :: GNU General Public License', + version = "0.1", + ext_modules = [ + Extension( + "_example", + ["example.i","example.c"] + ) + ] + ) + diff -ruN ../empty/with space/ex ample.c ./with space/ex ample.c --- ../empty/with space/ex ample.c 1970-01-01 12:00:00.000000000 +1200 +++ ./with space/ex ample.c 2008-12-18 15:04:18.000000000 +1300 @@ -0,0 +1,19 @@ +/* File : example.c */ + +/* A global variable */ +double Foo = 3.0; + +/* Compute the greatest common divisor of positive integers */ +int gcd(int x, int y) { + int g; + g = y; + while (x > 0) + { + g = x; + x = y % x; + y = g; + } + return g; +} + + diff -ruN ../empty/with space/example.i ./with space/example.i --- ../empty/with space/example.i 1970-01-01 12:00:00.000000000 +1200 +++ ./with space/example.i 2008-12-18 15:04:18.000000000 +1300 @@ -0,0 +1,7 @@ +/* File : example.i */ +%module example + +%inline %{ +extern int gcd(int x, int y); +extern double Foo; +%} diff -ruN ../empty/with space/setup.py ./with space/setup.py --- ../empty/with space/setup.py 1970-01-01 12:00:00.000000000 +1200 +++ ./with space/setup.py 2010-08-25 13:27:22.576786482 +1200 @@ -0,0 +1,18 @@ +# setup.py for compiling a python extension with swig... +import distutils +from distutils.core import setup, Extension + +setup( + name = "Example C Extension wrapped up all nice for python", + author = 'Brian Thorne', + author_email = 'hardbyte+python@gmail.com', + license='GPL v3 :: GNU General Public License', + version = "0.1", + ext_modules = [ + Extension( + "_example", + ["example.i","ex ample.c"] + ) + ] + ) +