"""
import os.path
-import string
import sys
import TestSCons
-if sys.platform =='darwin':
- # change to make it work with stock OS X python framework
- # we can't link to static libpython because there isn't one on OS X
- # so we link to a framework version. However, testing must also
- # use the same version, or else you get interpreter errors.
- python = "/System/Library/Frameworks/Python.framework/Versions/Current/bin/python"
- _python_ = '"' + python + '"'
-else:
- python = TestSCons.python
- _python_ = TestSCons._python_
-
# swig-python expects specific filenames.
# the platform specific suffix won't necessarily work.
if sys.platform == 'win32':
_dll = '.dll'
else:
- _dll = '.so'
+ _dll = '.so'
test = TestSCons.TestSCons()
swig = test.where_is('swig')
-
if not swig:
test.skip_test('Can not find installed "swig", skipping test.\n')
-
-
-version = sys.version[:3] # see also sys.prefix documentation
+python, python_include, python_libpath, python_lib = \
+ test.get_platform_python_info()
+Python_h = os.path.join(python_include, 'Python.h')
+if not os.path.exists(Python_h):
+ test.skip_test('Can not find %s, skipping test.\n' % Python_h)
# handle testing on other platforms:
ldmodule_prefix = '_'
-frameworks = ''
-platform_sys_prefix = sys.prefix
-if sys.platform == 'darwin':
- # OS X has a built-in Python but no static libpython
- # so you should link to it using apple's 'framework' scheme.
- # (see top of file for further explanation)
- frameworks = '-framework Python'
- platform_sys_prefix = '/System/Library/Frameworks/Python.framework/Versions/%s/' % version
-
-python_include_dir = os.path.join(platform_sys_prefix,
- 'include',
- 'python' + version)
-Python_h = os.path.join(python_include_dir, 'Python.h')
-
-if not os.path.exists(Python_h):
- test.skip_test('Can not find %s, skipping test.\n' % Python_h)
-
test.write("wrapper.py",
"""import os
-import string
import sys
open('%s', 'wb').write("wrapper.py\\n")
-os.system(string.join(sys.argv[1:], " "))
-""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
+os.system(" ".join(sys.argv[1:]))
+""" % test.workpath('wrapper.out').replace('\\', '\\\\'))
-test.write('SConstruct', """
+test.write('SConstruct', """\
foo = Environment(SWIGFLAGS='-python',
- CPPPATH='%(python_include_dir)s/',
+ CPPPATH=[r'%(python_include)s'],
LDMODULEPREFIX='%(ldmodule_prefix)s',
LDMODULESUFFIX='%(_dll)s',
- FRAMEWORKSFLAGS='%(frameworks)s',
+ SWIG=[r'%(swig)s'],
+ LIBPATH=[r'%(python_libpath)s'],
+ LIBS='%(python_lib)s',
)
import sys
foo.Append(SWIGFLAGS = ' -classic')
swig = foo.Dictionary('SWIG')
-bar = foo.Clone(SWIG = r'%(_python_)s wrapper.py ' + swig)
+bar = foo.Clone(SWIG = [r'%(python)s', 'wrapper.py', swig])
foo.LoadableModule(target = 'foo', source = ['foo.c', 'foo.i'])
bar.LoadableModule(target = 'bar', source = ['bar.c', 'bar.i'])
""" % locals())
test.up_to_date(arguments = '.')
-
test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4: