summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Noel <GregNoel@tigris.org>2009-04-18 16:56:22 (GMT)
committerGreg Noel <GregNoel@tigris.org>2009-04-18 16:56:22 (GMT)
commit588cf4a4fae059bb156ee086ff01a92b2ee025a9 (patch)
treedf97f69bcf6db6082047925e185d179fa442af55
parent935a23efa2fe53e9dcbf7df8e99f8ee424834f96 (diff)
downloadSCons-588cf4a4fae059bb156ee086ff01a92b2ee025a9.zip
SCons-588cf4a4fae059bb156ee086ff01a92b2ee025a9.tar.gz
SCons-588cf4a4fae059bb156ee086ff01a92b2ee025a9.tar.bz2
Modify the SWIG tests so that OS X is treated like a UNIX platform (which it
really is). OS X now not only runs all the SWIG tests (it used to skip many of them because it could not find the appropriate files), it now passes all the tests.
-rw-r--r--QMTest/TestCmd.py3
-rw-r--r--QMTest/TestSCons.py104
-rw-r--r--test/SWIG/SWIG.py8
-rw-r--r--test/SWIG/SWIGOUTDIR-python.py18
-rw-r--r--test/SWIG/SWIGPATH.py8
-rw-r--r--test/SWIG/build-dir.py18
-rw-r--r--test/SWIG/implicit-dependencies.py8
-rw-r--r--test/SWIG/live.py34
-rw-r--r--test/SWIG/module-parens.py18
-rw-r--r--test/SWIG/module-quoted.py16
-rw-r--r--test/SWIG/noproxy.py20
-rw-r--r--test/SWIG/remove-modules.py25
-rw-r--r--test/SWIG/subdir.py22
13 files changed, 98 insertions, 204 deletions
diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py
index a693f6a..cff50c7 100644
--- a/QMTest/TestCmd.py
+++ b/QMTest/TestCmd.py
@@ -456,11 +456,8 @@ def diff_re(a, b, fromfile='', tofile='',
return result
if os.name == 'java':
-
python_executable = os.path.join(sys.prefix, 'jython')
-
else:
-
python_executable = sys.executable
if sys.platform == 'win32':
diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py
index 729243d..26faee5 100644
--- a/QMTest/TestSCons.py
+++ b/QMTest/TestSCons.py
@@ -860,98 +860,28 @@ SConscript( sconscript )
# see also sys.prefix documentation
return python_minor_version_string()
- def get_platform_python(self):
+ def get_platform_python_info(self):
"""
Returns a path to a Python executable suitable for testing on
- this platform.
-
- Mac OS X has no static libpython for SWIG to link against,
- so we have to link against Apple's framwork version. However,
- testing must use the executable version that corresponds to the
- framework we link against, or else we get interpreter errors.
- """
- if sys.platform[:6] == 'darwin':
- return sys.prefix + '/bin/python'
- else:
- global python
- return python
-
- def get_quoted_platform_python(self):
- """
- Returns a quoted path to a Python executable suitable for testing on
- this platform.
-
- Mac OS X has no static libpython for SWIG to link against,
- so we have to link against Apple's framwork version. However,
- testing must use the executable version that corresponds to the
- framework we link against, or else we get interpreter errors.
- """
- if sys.platform[:6] == 'darwin':
- return '"' + self.get_platform_python() + '"'
- else:
- global _python_
- return _python_
-
-# def get_platform_sys_prefix(self):
-# """
-# Returns a "sys.prefix" value suitable for linking on this platform.
-#
-# Mac OS X has a built-in Python but no static libpython,
-# so we must link to it using Apple's 'framework' scheme.
-# """
-# if sys.platform[:6] == 'darwin':
-# fmt = '/System/Library/Frameworks/Python.framework/Versions/%s/'
-# return fmt % self.get_python_version()
-# else:
-# return sys.prefix
-
- def get_python_frameworks_flags(self):
- """
- Returns a FRAMEWORKS value for linking with Python.
-
- Mac OS X has a built-in Python but no static libpython,
- so we must link to it using Apple's 'framework' scheme.
- """
- if sys.platform[:6] == 'darwin':
- return 'Python'
- else:
- return ''
-
- def get_python_inc(self):
+ this platform and its associated include path, library path,
+ and library name.
"""
- Returns a path to the Python include directory.
+ python = self.where_is('python')
+ if not python:
+ self.skip_test('Can not find installed "python", skipping test.\n')
- Mac OS X has a built-in Python but no static libpython,
- so we must link to it using Apple's 'framework' scheme.
- """
- if sys.platform[:6] == 'darwin':
- return sys.prefix + '/Headers'
- try:
- import distutils.sysconfig
- except ImportError:
- return os.path.join(sys.prefix, 'include',
- 'python' + self.get_python_version())
- else:
- return distutils.sysconfig.get_python_inc()
+ self.run(program = python, stdin = """\
+import os, sys
+try:
+ py_ver = 'python%d.%d' % sys.version_info[:2]
+except AttributeError:
+ py_ver = 'python' + sys.version[:3]
+print os.path.join(sys.prefix, 'include', py_ver)
+print os.path.join(sys.prefix, 'lib', py_ver, 'config')
+print py_ver
+""")
- def get_python_library_path(self):
- """
- Returns the full path of the Python static library (libpython*.a)
- """
- if sys.platform[:6] == 'darwin':
- # Use the framework version (or try to) since that matches
- # the executable and headers we return elsewhere.
- python_lib = os.path.join(sys.prefix, 'Python')
- if os.path.exists(python_lib):
- return python_lib
- python_version = self.get_python_version()
- python_lib = os.path.join(sys.prefix, 'lib',
- 'python%s' % python_version, 'config',
- 'libpython%s.a' % python_version)
- if os.path.exists(python_lib):
- return python_lib
- # We can't find it, so maybe it's in the standard path
- return ''
+ return [python] + string.split(string.strip(self.stdout()), '\n')
def wait_for(self, fname, timeout=10.0, popen=None):
"""
diff --git a/test/SWIG/SWIG.py b/test/SWIG/SWIG.py
index d76ef64..3ddc686 100644
--- a/test/SWIG/SWIG.py
+++ b/test/SWIG/SWIG.py
@@ -35,8 +35,9 @@ _obj = TestSCons._obj
test = TestSCons.TestSCons()
-_python_ = test.get_quoted_platform_python()
-
+python = test.where_is('python')
+if not python:
+ test,skip_test('Can not find installed "python", skipping test.\n')
test.write('myswig.py', r"""
@@ -55,7 +56,8 @@ sys.exit(0)
""")
test.write('SConstruct', """
-env = Environment(tools=['default', 'swig'], SWIG = r'%(_python_)s myswig.py')
+env = Environment(tools=['default', 'swig'],
+ SWIG = [r'%(python)s', 'myswig.py'])
env.Program(target = 'test1', source = 'test1.i')
env.CFile(target = 'test2', source = 'test2.i')
env.Clone(SWIGFLAGS = '-c++').Program(target = 'test3', source = 'test3.i')
diff --git a/test/SWIG/SWIGOUTDIR-python.py b/test/SWIG/SWIGOUTDIR-python.py
index 3f6667e..763e9c4 100644
--- a/test/SWIG/SWIGOUTDIR-python.py
+++ b/test/SWIG/SWIGOUTDIR-python.py
@@ -34,27 +34,23 @@ import os
test = TestSCons.TestSCons()
-test = TestSCons.TestSCons()
-
swig = test.where_is('swig')
-
if not swig:
test.skip_test('Can not find installed "swig", skipping test.\n')
-python_include_dir = test.get_python_inc()
-
-python_frameworks_flags = test.get_python_frameworks_flags()
-
-Python_h = os.path.join(python_include_dir, 'Python.h')
+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)
test.write(['SConstruct'], """\
env = Environment(SWIGFLAGS = '-python -c++',
- CPPPATH=r"%(python_include_dir)s",
- SWIG=r'%(swig)s',
+ CPPPATH=[r"%(python_include)s"],
+ SWIG=[r'%(swig)s'],
SWIGOUTDIR='python/build dir',
- FRAMEWORKS='%(python_frameworks_flags)s',
+ LIBPATH=[r'%(python_libpath)s'],
+ LIBS='%(python_lib)s',
)
import sys
diff --git a/test/SWIG/SWIGPATH.py b/test/SWIG/SWIGPATH.py
index 4832814..30426da 100644
--- a/test/SWIG/SWIGPATH.py
+++ b/test/SWIG/SWIGPATH.py
@@ -33,12 +33,12 @@ import TestSCons
test = TestSCons.TestSCons()
swig = test.where_is('swig')
-
if not swig:
test.skip_test('Can not find installed "swig", skipping test.\n')
-_python_ = test.get_quoted_platform_python()
-
+python = test.where_is('python')
+if not python:
+ test,skip_test('Can not find installed "python", skipping test.\n')
test.subdir('inc1', 'inc2')
@@ -57,7 +57,7 @@ test.write('SConstruct', """
foo = Environment(SWIGFLAGS='-python',
SWIGPATH=['inc1', 'inc2'])
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.CFile(target = 'dependent', source = ['dependent.i'])
""" % locals())
diff --git a/test/SWIG/build-dir.py b/test/SWIG/build-dir.py
index 5fa3ceb..d5b5236 100644
--- a/test/SWIG/build-dir.py
+++ b/test/SWIG/build-dir.py
@@ -38,7 +38,6 @@ import TestSCons
test = TestSCons.TestSCons()
swig = test.where_is('swig')
-
if not swig:
test.skip_test('Can not find installed "swig", skipping test.\n')
@@ -51,27 +50,26 @@ else:
test.subdir(['source'])
-python_include_dir = test.get_python_inc()
-
-Python_h = os.path.join(python_include_dir, 'Python.h')
-
+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)
-python_frameworks_flags = test.get_python_frameworks_flags()
-
test.write(['SConstruct'], """\
#
# Create the build environment.
#
-env = Environment(CPPPATH = [".", r'%(python_include_dir)s'],
+env = Environment(CPPPATH = [".", r'%(python_include)s'],
CPPDEFINES = "NDEBUG",
- SWIG =r'%(swig)s',
+ SWIG = [r'%(swig)s'],
SWIGFLAGS = ["-python", "-c++"],
SWIGCXXFILESUFFIX = "_wrap.cpp",
LDMODULEPREFIX='_',
LDMODULESUFFIX='%(_dll)s',
- FRAMEWORKS='%(python_frameworks_flags)s')
+ LIBPATH=[r'%(python_libpath)s'],
+ LIBS='%(python_lib)s',
+ )
import sys
if sys.version[0] == '1':
diff --git a/test/SWIG/implicit-dependencies.py b/test/SWIG/implicit-dependencies.py
index 49f9cc7..6d40216 100644
--- a/test/SWIG/implicit-dependencies.py
+++ b/test/SWIG/implicit-dependencies.py
@@ -33,12 +33,12 @@ import TestSCons
test = TestSCons.TestSCons()
swig = test.where_is('swig')
-
if not swig:
test.skip_test('Can not find installed "swig", skipping test.\n')
-_python_ = test.get_quoted_platform_python()
-
+python = test.where_is('python')
+if not python:
+ test.skip_test('Can not find installed "python", skipping test.\n')
test.write("dependency.i", """\
@@ -54,7 +54,7 @@ test.write("dependent.i", """\
test.write('SConstruct', """
foo = Environment(SWIGFLAGS='-python')
swig = foo.Dictionary('SWIG')
-bar = foo.Clone(SWIG = r'%(_python_)s wrapper.py ' + swig)
+bar = foo.Clone(SWIG = [r'%(python)s', r'wrapper.py', swig])
foo.CFile(target = 'dependent', source = ['dependent.i'])
""" % locals())
diff --git a/test/SWIG/live.py b/test/SWIG/live.py
index 0caa9b5..0a4c905 100644
--- a/test/SWIG/live.py
+++ b/test/SWIG/live.py
@@ -47,31 +47,15 @@ swig = test.where_is('swig')
if not swig:
test.skip_test('Can not find installed "swig", skipping test.\n')
-
-python = test.where_is('python')
-
-# handle testing on other platforms:
-ldmodule_prefix = '_'
-
-test.run(program = python, stdin = """\
-import os, sys
-try:
- py_ver = 'python%d.%d' % sys.version_info[:2]
-except AttributeError:
- py_ver = 'python' + sys.version[:3]
-print os.path.join(sys.prefix, 'include', py_ver)
-print os.path.join(sys.prefix, 'lib', py_ver, 'config')
-print py_ver
-""")
-
-#TODO(1.5) config_info = test.stdout().strip().split('\n')
-config_info = string.split(string.strip(test.stdout()), '\n')
-python_include,python_libpath,python_lib = config_info
-
+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 = '_'
+
test.write("wrapper.py",
"""import os
import string
@@ -82,11 +66,11 @@ os.system(string.join(sys.argv[1:], " "))
test.write('SConstruct', """\
foo = Environment(SWIGFLAGS='-python',
- CPPPATH=r'%(python_include)s',
+ CPPPATH=[r'%(python_include)s'],
LDMODULEPREFIX='%(ldmodule_prefix)s',
LDMODULESUFFIX='%(_dll)s',
- SWIG=r'%(swig)s',
- LIBPATH=r'%(python_libpath)s',
+ SWIG=[r'%(swig)s'],
+ LIBPATH=[r'%(python_libpath)s'],
LIBS='%(python_lib)s',
)
@@ -96,7 +80,7 @@ if sys.version[0] == '1':
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())
diff --git a/test/SWIG/module-parens.py b/test/SWIG/module-parens.py
index f80e10c..7886218 100644
--- a/test/SWIG/module-parens.py
+++ b/test/SWIG/module-parens.py
@@ -35,24 +35,22 @@ import TestSCons
test = TestSCons.TestSCons()
swig = test.where_is('swig')
-
if not swig:
test.skip_test('Can not find installed "swig", skipping test.\n')
-python_include_dir = test.get_python_inc()
-
-python_frameworks_flags = test.get_python_frameworks_flags()
-
-Python_h = os.path.join(python_include_dir, 'Python.h')
+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)
test.write(['SConstruct'], """\
env = Environment(SWIGFLAGS = '-python -c++',
- CPPPATH=r"%(python_include_dir)s",
- SWIG=r'%(swig)s',
- FRAMEWORKS='%(python_frameworks_flags)s',
- )
+ CPPPATH=[r'%(python_include)s'],
+ SWIG=[r'%(swig)s'],
+ LIBPATH=[r'%(python_libpath)s'],
+ LIBS='%(python_lib)s',
+ )
import sys
if sys.version[0] == '1':
diff --git a/test/SWIG/module-quoted.py b/test/SWIG/module-quoted.py
index 2001582..89402eb 100644
--- a/test/SWIG/module-quoted.py
+++ b/test/SWIG/module-quoted.py
@@ -35,23 +35,21 @@ import TestSCons
test = TestSCons.TestSCons()
swig = test.where_is('swig')
-
if not swig:
test.skip_test('Can not find installed "swig", skipping test.\n')
-python_include_dir = test.get_python_inc()
-
-python_frameworks_flags = test.get_python_frameworks_flags()
-
-Python_h = os.path.join(python_include_dir, 'Python.h')
+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)
test.write(['SConstruct'], """\
env = Environment(SWIGFLAGS = '-python -c++',
- CPPPATH=r"%(python_include_dir)s",
- SWIG=r'%(swig)s',
- FRAMEWORKS='%(python_frameworks_flags)s',
+ CPPPATH=[r'%(python_include)s'],
+ SWIG=[r'%(swig)s'],
+ LIBPATH=[r'%(python_libpath)s'],
+ LIBS='%(python_lib)s',
)
import sys
diff --git a/test/SWIG/noproxy.py b/test/SWIG/noproxy.py
index 0d109b8..1aaeb08 100644
--- a/test/SWIG/noproxy.py
+++ b/test/SWIG/noproxy.py
@@ -29,6 +29,7 @@ Verify that SCons realizes the -noproxy option means no .py file will
be created.
"""
+import os
import sys
import TestSCons
@@ -43,19 +44,18 @@ else:
test = TestSCons.TestSCons()
swig = test.where_is('swig')
-
if not swig:
test.skip_test('Can not find installed "swig", skipping test.\n')
-_python_ = test.get_quoted_platform_python()
+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 = '_'
-python_include_dir = test.get_python_inc()
-
-python_frameworks_flags = test.get_python_frameworks_flags()
-
test.write("dependency.i", """\
%module dependency
""")
@@ -68,14 +68,16 @@ test.write("dependent.i", """\
test.write('SConstruct', """
foo = Environment(SWIGFLAGS=['-python', '-noproxy'],
- CPPPATH='%(python_include_dir)s',
+ CPPPATH=[r'%(python_include)s'],
LDMODULEPREFIX='%(ldmodule_prefix)s',
LDMODULESUFFIX='%(_dll)s',
- FRAMEWORKS='%(python_frameworks_flags)s',
+ SWIG=[r'%(swig)s'],
+ LIBPATH=[r'%(python_libpath)s'],
+ LIBS='%(python_lib)s',
)
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.CFile(target = 'dependent', source = ['dependent.i'])
""" % locals())
diff --git a/test/SWIG/remove-modules.py b/test/SWIG/remove-modules.py
index e0e91da..8ed24ef 100644
--- a/test/SWIG/remove-modules.py
+++ b/test/SWIG/remove-modules.py
@@ -39,29 +39,23 @@ import TestSCons
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')
-
+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 = '_'
-python_include_dir = test.get_python_inc()
-
-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)
-
-python_frameworks_flags = test.get_python_frameworks_flags()
-
test.write("module.i", """\
%module modulename
@@ -69,11 +63,12 @@ test.write("module.i", """\
test.write('SConstruct', """
foo = Environment(SWIGFLAGS='-python',
- CPPPATH='%(python_include_dir)s',
+ CPPPATH=['%(python_include)s'],
LDMODULEPREFIX='%(ldmodule_prefix)s',
LDMODULESUFFIX='%(_dll)s',
- FRAMEWORKS='%(python_frameworks_flags)s',
- SWIG=r'%(swig)s',
+ SWIG=[r'%(swig)s'],
+ LIBPATH=[r'%(python_libpath)s'],
+ LIBS='%(python_lib)s',
)
import sys
diff --git a/test/SWIG/subdir.py b/test/SWIG/subdir.py
index 6a746f3..d4798f6 100644
--- a/test/SWIG/subdir.py
+++ b/test/SWIG/subdir.py
@@ -46,32 +46,26 @@ test = TestSCons.TestSCons()
test.subdir('sub')
swig = test.where_is('swig')
-
if not swig:
test.skip_test('Can not find installed "swig", skipping test.\n')
-python = test.get_platform_python()
-_python_ = test.get_quoted_platform_python()
-
-# handle testing on other platforms:
-ldmodule_prefix = '_'
-
-python_include_dir = test.get_python_inc()
-
-Python_h = os.path.join(python_include_dir, 'Python.h')
-
+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)
-python_frameworks_flags = test.get_python_frameworks_flags()
+# handle testing on other platforms:
+ldmodule_prefix = '_'
test.write('SConstruct', """
env = Environment(SWIGFLAGS='-python',
- CPPPATH='%(python_include_dir)s/',
+ CPPPATH=['%(python_include)s/'],
LDMODULEPREFIX='%(ldmodule_prefix)s',
LDMODULESUFFIX='%(_dll)s',
- FRAMEWORKS='%(python_frameworks_flags)s',
SWIG=r'%(swig)s',
+ LIBPATH=[r'%(python_libpath)s'],
+ LIBS='%(python_lib)s',
)
import sys