Skip to content

Instantly share code, notes, and snippets.

@nfarring
Created October 28, 2010 17:58
Show Gist options
  • Save nfarring/651931 to your computer and use it in GitHub Desktop.
Save nfarring/651931 to your computer and use it in GitHub Desktop.
This script manually builds a Python wrapper library for a C library. There is an easier/better way to do this using distutils.
#!/usr/bin/env bash
#
# Generate my_python_library_wrap.c and MyPythonLibrary.py
#
swig -python my_python_library.i
#
# Generate _MyPythonLibrary.so
#
gcc `python-config --cflags --ldflags` -I/path/to/my/c/library/headers -L/path/to/my/c/library -lmy_c_library my_python_library_wrap.c -fPIC -shared -o _MyPythonLibrary.so
#
# Now you can copy MyPythonLibrary.py and _MyPythonLibrary.so into your python site-packages/ directory.
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment