simsearch / SConstruct

# -*- coding: utf-8 -*-
#  SConstruct
#  simsearch
#  Created by Lars Yencken on 27-08-2010.
#  Copyright 2010 Lars Yencken. All rights reserved.

Build instructions for the stroke similarity extension."


import os
from distutils import sysconfig


# Default include path for python, version inspecific.
scons_python_version = sysconfig.get_config_var('VERSION')
python_version = ARGUMENTS.get('python') or scons_python_version 

print 'Using Python %s' % python_version


def check_libraries(env):
    """ Check whether the correct libraries exist, and thus whether building
        is possible.
    # Detect OS X python installation, and attempt to correct for it.
    if os.uname()[0] == 'Darwin':
        env.Replace(SHLINKFLAGS='$LINKFLAGS -bundle -flat_namespace -undefined suppress')
        if os.path.isdir('/opt/local'):

    # Detect the presence of necessary dependencies.
    conf = Configure(env)

    if not conf.CheckLibWithHeader('m', 'math.h', 'c'):
        print "Can't find standard math libraries."

    if not conf.CheckLibWithHeader('python%s' % python_version,
            'Python.h', 'c'):
        print "Can't find python %s." % python_version

    env = conf.Finish()

    return env


# Set up the compilation environment.
env = Environment(
                scons_python_version, python_version)],
        LIBS=['python%s' % python_version],

environmentVars = (

envDict = env['ENV']
for var in environmentVars:
    if var in os.environ:
        envDict[var] = os.environ[var]

# Choose between debugging or optimized mode.
if ARGUMENTS.get('debug'):
    print 'Using debug targets'
    env.Replace(DEBUG=True, CXXFLAGS='-O0 -g -Wall ', CFLAGS='-O0 -g -Wall ')
    print 'Using optimised targets'
    env.Replace(DEBUG=False, CXXFLAGS='-O3 -DNDEBUG -Wall ',
           CFLAGS='-O3 -DNDEBUG -Wall ')

# Configure the environment.
env = check_libraries(env)

pyxbuild = Builder(action='cython -o $TARGET $SOURCE')
env.Append(BUILDERS={'Cython': pyxbuild})


SConscript('simsearch/search/SConscript', exports='env')

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.