So in my case, the name of the library I want to create is called bright.

Scons is aware of swig, all you need is the SwigFlags and the .i in your sources for it all to work nicely.

I have my individual .i files (one per C++ header) mixed in with the source, and a bright.i class that sets the module name, and includes all the other .i files.

Here's an example:


# Works on linux and Mac,
# Mac use scons 0.96.90.D001 or later
# linux use 0.96.1 or later

import as conf

library = '_bright'
wxPrefix = '/usr/'
sourceDir = '../../src/'

# on linux, it's probably in the system's /usr/local/lib

env = Environment()

sourceFiles = [
# ...

sources = [os.path.join(sourceDir, src) for src in sourceFiles]

env['CPPPATH'] = [

SwigFlags = "-c++ -Wall -nodefault -python -keyword -new_repr -modern -I/usr/include/wx-2.6/wx/wxPython/i_files/"

# Adds the necessary flags for compiling and linking wxWidgets projects
env.ParseConfig('wx-config --cppflags --libs')


brightlib = env.SharedLibrary(library, sources,
    build_dir='/tmp/', duplicate=0)

# manage dependancies by target's content
# this way a change to a comment will cause
# a recompile, but not a relink

import pprint
pprint.pprint( brightlib)

so all I have to do is type scons to create my wxPython extension, and then I have to go hunt for where it places the various resulting files. The ends up in the source directory, and the file is in the directory where scons is invoked from (if I remember right.)

SconsExtensions (last edited 2008-03-11 10:50:24 by localhost)

NOTE: To edit pages in this wiki you must be a member of the TrustedEditorsGroup.