summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMats Wichmann <mats@linux.com>2018-08-15 14:16:11 (GMT)
committerMats Wichmann <mats@linux.com>2018-08-15 14:16:11 (GMT)
commit52ecb92eb30698b67de2662a892e20be3f1fda20 (patch)
tree4f93ce6501a5fa057005b5e5a72b4e819d9343de
parent2a39eb278ecca56f66011f2d602e12b924ad0e2c (diff)
downloadSCons-52ecb92eb30698b67de2662a892e20be3f1fda20.zip
SCons-52ecb92eb30698b67de2662a892e20be3f1fda20.tar.gz
SCons-52ecb92eb30698b67de2662a892e20be3f1fda20.tar.bz2
Move checking for python header to common location
A previous change added a check for Python.h in one SWIG test which did not have it which turns that test into a skip instead of a fail if the header is not installed. It was pointed out that having 12 tests check for the same thing might be optimised by putting the check in the routine which returns info about the python development environment, so this change makes that modification. Signed-off-by: Mats Wichmann <mats@linux.com>
-rw-r--r--test/SWIG/SWIGOUTDIR-python.py6
-rw-r--r--test/SWIG/build-dir.py6
-rw-r--r--test/SWIG/generated_swigfile.py6
-rw-r--r--test/SWIG/live.py11
-rw-r--r--test/SWIG/module-deduced-name.py6
-rw-r--r--test/SWIG/module-parens.py6
-rw-r--r--test/SWIG/module-quoted.py6
-rw-r--r--test/SWIG/module-spaces.py6
-rw-r--r--test/SWIG/noproxy.py6
-rw-r--r--test/SWIG/recursive-includes-cpp.py7
-rw-r--r--test/SWIG/remove-modules.py6
-rw-r--r--test/SWIG/subdir.py6
-rw-r--r--testing/framework/TestSCons.py55
13 files changed, 53 insertions, 80 deletions
diff --git a/test/SWIG/SWIGOUTDIR-python.py b/test/SWIG/SWIGOUTDIR-python.py
index db0cc95..53b5bdf 100644
--- a/test/SWIG/SWIGOUTDIR-python.py
+++ b/test/SWIG/SWIGOUTDIR-python.py
@@ -30,7 +30,6 @@ that Python files are created in the specified output directory.
"""
import TestSCons
-import os
import sys
test = TestSCons.TestSCons()
@@ -39,11 +38,8 @@ 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 = \
+python, python_include, python_libpath, python_lib, python_h = \
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)
# On Windows, build a 32-bit exe if on 32-bit python.
if sys.platform == 'win32' and sys.maxsize <= 2**32:
diff --git a/test/SWIG/build-dir.py b/test/SWIG/build-dir.py
index eba3fea..b203abe 100644
--- a/test/SWIG/build-dir.py
+++ b/test/SWIG/build-dir.py
@@ -29,7 +29,6 @@ Make sure SWIG works when a VariantDir (or variant_dir) is used.
Test case courtesy Joe Maruszewski.
"""
-import os.path
import sys
import TestSCons
@@ -49,11 +48,8 @@ else:
test.subdir(['source'])
-python, python_include, python_libpath, python_lib = \
+python, python_include, python_libpath, python_lib, python_h = \
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)
if sys.platform == 'win32' and sys.maxsize <= 2**32:
swig_arch_var="TARGET_ARCH='x86',"
diff --git a/test/SWIG/generated_swigfile.py b/test/SWIG/generated_swigfile.py
index d09b473..4686dae 100644
--- a/test/SWIG/generated_swigfile.py
+++ b/test/SWIG/generated_swigfile.py
@@ -29,7 +29,6 @@ Verify that SCons realizes the -noproxy option means no .py file will
be created.
"""
-import os
import sys
import TestSCons
@@ -54,11 +53,8 @@ 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 = \
+python, python_include, python_libpath, python_lib, python_h = \
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 = '_'
diff --git a/test/SWIG/live.py b/test/SWIG/live.py
index 7c4bdce..f0cf1d5 100644
--- a/test/SWIG/live.py
+++ b/test/SWIG/live.py
@@ -28,7 +28,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
Test SWIG behavior with a live, installed SWIG.
"""
-import os.path
+import os
import sys
import TestSCons
@@ -46,12 +46,9 @@ 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 = \
+python, python_include, python_libpath, python_lib, python_h = \
test.get_platform_python_info()
-Python_h = python_include + '/Python.h'
-if not os.path.exists(Python_h):
- test.skip_test('Can not find %s, skipping test.\n' % Python_h)
+
swig = swig.replace('\\','/')
python = python.replace('\\','/')
python_include = python_include.replace('\\','/')
@@ -170,4 +167,4 @@ test.pass_test()
# tab-width:4
# indent-tabs-mode:nil
# End:
-# vim: set expandtab tabstop=4 shiftwidth=4: \ No newline at end of file
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/SWIG/module-deduced-name.py b/test/SWIG/module-deduced-name.py
index bdaef4f..6b4d6d9 100644
--- a/test/SWIG/module-deduced-name.py
+++ b/test/SWIG/module-deduced-name.py
@@ -31,7 +31,6 @@ emitter should return the basename of the module only.
"""
import TestSCons
-import os
import sys
test = TestSCons.TestSCons()
@@ -40,11 +39,8 @@ swig = test.where_is('swig')
if not swig:
test.skip_test('Cannot find installed "swig", skipping test.\n')
-python, python_include, python_libpath, python_lib = \
+python, python_include, python_libpath, python_lib, python_h = \
test.get_platform_python_info()
-Python_h = os.path.join(python_include, 'Python.h')
-if not os.path.exists(Python_h):
- test.skip_test('Cannot find %s, skipping test.\n' % Python_h)
# On Windows, build a 32-bit exe if on 32-bit python.
if sys.platform == 'win32' and sys.maxsize <= 2**32:
diff --git a/test/SWIG/module-parens.py b/test/SWIG/module-parens.py
index d8c1744..040ef28 100644
--- a/test/SWIG/module-parens.py
+++ b/test/SWIG/module-parens.py
@@ -29,7 +29,6 @@ Verify that we handle %module(directors="1") statements, both with and
without white space before the opening parenthesis.
"""
-import os.path
import sys
import TestSCons
@@ -39,11 +38,8 @@ 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 = \
+python, python_include, python_libpath, python_lib, python_h = \
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)
# swig-python expects specific filenames.
# the platform specific suffix won't necessarily work.
diff --git a/test/SWIG/module-quoted.py b/test/SWIG/module-quoted.py
index 6f4b891..8bf9e86 100644
--- a/test/SWIG/module-quoted.py
+++ b/test/SWIG/module-quoted.py
@@ -29,7 +29,6 @@ Verify that we correctly parse quoted module names; e.g. %module "test"
(SWIG permits double-quoted names but not single-quoted ones.)
"""
-import os.path
import sys
import TestSCons
@@ -39,11 +38,8 @@ 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 = \
+python, python_include, python_libpath, python_lib, python_h = \
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)
# swig-python expects specific filenames.
# the platform specific suffix won't necessarily work.
diff --git a/test/SWIG/module-spaces.py b/test/SWIG/module-spaces.py
index 2833dff..ce16497 100644
--- a/test/SWIG/module-spaces.py
+++ b/test/SWIG/module-spaces.py
@@ -29,7 +29,6 @@ Verify that we correctly parse module names with spaces on the line after
the module name ; e.g. "%module test "
"""
-import os.path
import sys
import TestSCons
@@ -39,11 +38,8 @@ 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 = \
+python, python_include, python_libpath, python_lib, python_h = \
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)
# swig-python expects specific filenames.
# the platform specific suffix won't necessarily work.
diff --git a/test/SWIG/noproxy.py b/test/SWIG/noproxy.py
index 1aaeb08..b4abbc3 100644
--- a/test/SWIG/noproxy.py
+++ b/test/SWIG/noproxy.py
@@ -29,7 +29,6 @@ Verify that SCons realizes the -noproxy option means no .py file will
be created.
"""
-import os
import sys
import TestSCons
@@ -47,11 +46,8 @@ 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 = \
+python, python_include, python_libpath, python_lib, python_h = \
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 = '_'
diff --git a/test/SWIG/recursive-includes-cpp.py b/test/SWIG/recursive-includes-cpp.py
index 34c7d6e..4cb8fe5 100644
--- a/test/SWIG/recursive-includes-cpp.py
+++ b/test/SWIG/recursive-includes-cpp.py
@@ -44,11 +44,8 @@ for pre_req in ['swig', 'python']:
if not test.where_is(pre_req):
test.skip_test('Can not find installed "' + pre_req + '", skipping test.%s' % os.linesep)
-# file generated by swig will #include <Python.h>, make sure we have one
-python, py_include, py_libpath, py_lib = test.get_platform_python_info()
-Python_h = os.path.join(py_include, 'Python.h')
-if not os.path.exists(Python_h):
- test.skip_test('Can not find %s, skipping test.\n' % Python_h)
+python, python_include, python_libpath, python_lib, python_h = \
+ test.get_platform_python_info()
if sys.platform == 'win32':
python_lib = os.path.dirname(sys.executable) + "/libs/" + ('python%d%d'%(sys.version_info[0],sys.version_info[1])) + '.lib'
diff --git a/test/SWIG/remove-modules.py b/test/SWIG/remove-modules.py
index f5ce60d..ecbc19c 100644
--- a/test/SWIG/remove-modules.py
+++ b/test/SWIG/remove-modules.py
@@ -29,7 +29,6 @@ Verify that swig-generated modules are removed.
The %module directive specifies the module name.
"""
-import os.path
import sys
import TestSCons
@@ -47,11 +46,8 @@ 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 = \
+python, python_include, python_libpath, python_lib, python_h = \
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 = '_'
diff --git a/test/SWIG/subdir.py b/test/SWIG/subdir.py
index e23b858..062f8dc 100644
--- a/test/SWIG/subdir.py
+++ b/test/SWIG/subdir.py
@@ -29,7 +29,6 @@ Verify that we expect the .py file created by the -python flag to be in
the same subdirectory as the taget.
"""
-import os
import sys
import TestSCons
@@ -49,11 +48,8 @@ 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 = \
+python, python_include, python_libpath, python_lib, python_h = \
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 = '_'
diff --git a/testing/framework/TestSCons.py b/testing/framework/TestSCons.py
index 50942ab..14a8fcc 100644
--- a/testing/framework/TestSCons.py
+++ b/testing/framework/TestSCons.py
@@ -564,7 +564,7 @@ class TestSCons(TestCommon):
Returns a Python error line for output comparisons.
The exec of the traceback line gives us the correct format for
- this version of Python.
+ this version of Python.
File "<string>", line 1, <module>
@@ -607,7 +607,7 @@ class TestSCons(TestCommon):
pattern = to_bytes(pattern)
repl = to_bytes(repl)
return re.sub(pattern, repl, str, count, flags)
-
+
def normalize_pdf(self, s):
s = self.to_bytes_re_sub(r'/(Creation|Mod)Date \(D:[^)]*\)',
r'/\1Date (D:XXXX)', s)
@@ -811,7 +811,7 @@ class TestSCons(TestCommon):
where_jar = self.where_is('jar', ENV['PATH'])
if not where_jar:
self.skip_test("Could not find Java jar, skipping test(s).\n")
- elif sys.platform == "darwin":
+ elif sys.platform == "darwin":
self.java_mac_check(where_jar, 'jar')
return where_jar
@@ -885,7 +885,7 @@ class TestSCons(TestCommon):
self.skip_test("Could not find Java rmic, skipping non-simulated test(s).\n")
return where_rmic
-
+
def java_get_class_files(self, dir):
result = []
for dirpath, dirnames, filenames in os.walk(dir):
@@ -1078,7 +1078,7 @@ SConscript( sconscript )
doCheckLog=True, doCheckStdout=True):
"""
Used to verify the expected output from using Configure()
- via the contents of one or both of stdout or config.log file.
+ via the contents of one or both of stdout or config.log file.
The checks, results, cached parameters all are zipped together
for use in comparing results.
@@ -1160,19 +1160,19 @@ SConscript( sconscript )
sconstruct = sconstruct
log = r'file\ \S*%s\,line \d+:' % re.escape(sconstruct) + ls
- if doCheckLog:
+ if doCheckLog:
lastEnd = matchPart(log, logfile, lastEnd)
log = "\t" + re.escape("Configure(confdir = %s)" % sconf_dir) + ls
- if doCheckLog:
+ if doCheckLog:
lastEnd = matchPart(log, logfile, lastEnd)
-
+
rdstr = ""
cnt = 0
for check,result,cache_desc in zip(checks, results, cached):
log = re.escape("scons: Configure: " + check) + ls
- if doCheckLog:
+ if doCheckLog:
lastEnd = matchPart(log, logfile, lastEnd)
log = ""
@@ -1217,7 +1217,7 @@ SConscript( sconscript )
rdstr = rdstr + re.escape(check) + re.escape(result) + "\n"
log=log + re.escape("scons: Configure: " + result) + ls + ls
- if doCheckLog:
+ if doCheckLog:
lastEnd = matchPart(log, logfile, lastEnd)
log = ""
@@ -1260,9 +1260,12 @@ SConscript( sconscript )
"""
Returns a path to a Python executable suitable for testing on
this platform and its associated include path, library path,
- and library name.
+ library name, and the path to the Python.h header if found.
+ If the Python executable or Python header is not found,
+ the test is skipped.
+
Returns:
- (path to python, include path, library path, library name)
+ (path to python, include path, library path, library name, header path)
"""
python = os.environ.get('python_executable', self.where_is('python'))
if not python:
@@ -1279,28 +1282,44 @@ except AttributeError:
try:
import distutils.sysconfig
exec_prefix = distutils.sysconfig.EXEC_PREFIX
- print(distutils.sysconfig.get_python_inc())
+ include = distutils.sysconfig.get_python_inc()
+ print(include)
lib_path = os.path.join(exec_prefix, 'libs')
if not os.path.exists(lib_path):
lib_path = os.path.join(exec_prefix, 'lib')
print(lib_path)
except:
- print(os.path.join(sys.prefix, 'include', py_ver))
+ include = os.path.join(sys.prefix, 'include', py_ver)
+ print(include)
print(os.path.join(sys.prefix, 'lib', py_ver, 'config'))
print(py_ver)
- """)
+Python_h = os.path.join(include, "Python.h")
+if os.path.exists(Python_h):
+ print(Python_h)
+else:
+ print("False")
+""")
else:
self.run(program=python, stdin="""\
-import sys, sysconfig
-print(sysconfig.get_config_var("INCLUDEPY"))
+import sys, sysconfig, os.path
+include = sysconfig.get_config_var("INCLUDEPY")
+print(include)
print(sysconfig.get_config_var("LIBDIR"))
py_library_ver = sysconfig.get_config_var("LDVERSION")
if not py_library_ver:
py_library_ver = '%d.%d' % sys.version_info[:2]
print("python"+py_library_ver)
+Python_h = os.path.join(include, "Python.h")
+if os.path.exists(Python_h):
+ print(Python_h)
+else:
+ print("False")
""")
+ detected = self.stdout().strip().split('\n')
+ if detected[3] == "False":
+ self.skip_test('Can not find required "Python.h", skipping test.\n')
- return [python] + self.stdout().strip().split('\n')
+ return [python] + detected
def start(self, *args, **kw):
"""