From 2a39eb278ecca56f66011f2d602e12b924ad0e2c Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Mon, 13 Aug 2018 10:40:42 -0600 Subject: SWIG recursive test checkes for Python.h The generated code will #include , so skip the test if the appropriate development support for Python is not installed, the test will FAIL otherwise. The other SWIG tests do this already. Signed-off-by: Mats Wichmann --- src/CHANGES.txt | 1 + test/SWIG/recursive-includes-cpp.py | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 6534f3a..be5a90a 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -120,6 +120,7 @@ RELEASE 3.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE - quiet py3 warning in UtilTests.py - fix tests specifying octal constants for py3 - fix must_contain tests for py3 + - one swig test now checks for Python.h instead of failing From Hao Wu - typo in customized decider example in user guide diff --git a/test/SWIG/recursive-includes-cpp.py b/test/SWIG/recursive-includes-cpp.py index b943406..34c7d6e 100644 --- a/test/SWIG/recursive-includes-cpp.py +++ b/test/SWIG/recursive-includes-cpp.py @@ -44,6 +44,12 @@ 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 , 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) + if sys.platform == 'win32': python_lib = os.path.dirname(sys.executable) + "/libs/" + ('python%d%d'%(sys.version_info[0],sys.version_info[1])) + '.lib' if( not os.path.isfile(python_lib)): @@ -150,4 +156,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: -- cgit v0.12 From 52ecb92eb30698b67de2662a892e20be3f1fda20 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Wed, 15 Aug 2018 08:16:11 -0600 Subject: 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 --- test/SWIG/SWIGOUTDIR-python.py | 6 +--- test/SWIG/build-dir.py | 6 +--- test/SWIG/generated_swigfile.py | 6 +--- test/SWIG/live.py | 11 +++----- test/SWIG/module-deduced-name.py | 6 +--- test/SWIG/module-parens.py | 6 +--- test/SWIG/module-quoted.py | 6 +--- test/SWIG/module-spaces.py | 6 +--- test/SWIG/noproxy.py | 6 +--- test/SWIG/recursive-includes-cpp.py | 7 ++--- test/SWIG/remove-modules.py | 6 +--- test/SWIG/subdir.py | 6 +--- testing/framework/TestSCons.py | 55 +++++++++++++++++++++++++------------ 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 , 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 "", line 1, @@ -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): """ -- cgit v0.12 From 8b47503f49fa423404cad0d95f070c1674dd8c5a Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Fri, 17 Aug 2018 09:04:31 -0600 Subject: get_platform_python_info fail on missing Python.h evolved the get_platform_python_info test method to fail only if a new flag python_h_required is True. Rolled back the previous change to have the method return the path to the Python.h, this was not really needed since the include path is already returned. Signed-off-by: Mats Wichmann --- test/SWIG/SWIGOUTDIR-python.py | 4 ++-- test/SWIG/build-dir.py | 4 ++-- test/SWIG/generated_swigfile.py | 4 ++-- test/SWIG/live.py | 4 ++-- test/SWIG/module-deduced-name.py | 4 ++-- test/SWIG/module-parens.py | 4 ++-- test/SWIG/module-quoted.py | 4 ++-- test/SWIG/module-spaces.py | 4 ++-- test/SWIG/noproxy.py | 4 ++-- test/SWIG/recursive-includes-cpp.py | 4 ++-- test/SWIG/remove-modules.py | 4 ++-- test/SWIG/subdir.py | 4 ++-- 12 files changed, 24 insertions(+), 24 deletions(-) diff --git a/test/SWIG/SWIGOUTDIR-python.py b/test/SWIG/SWIGOUTDIR-python.py index 53b5bdf..8d6703f 100644 --- a/test/SWIG/SWIGOUTDIR-python.py +++ b/test/SWIG/SWIGOUTDIR-python.py @@ -38,8 +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_h = \ - test.get_platform_python_info() +python, python_include, python_libpath, python_lib = \ + test.get_platform_python_info(python_h_required=True) # 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 b203abe..d268c87 100644 --- a/test/SWIG/build-dir.py +++ b/test/SWIG/build-dir.py @@ -48,8 +48,8 @@ else: test.subdir(['source']) -python, python_include, python_libpath, python_lib, python_h = \ - test.get_platform_python_info() +python, python_include, python_libpath, python_lib = \ + test.get_platform_python_info(python_h_required=True) 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 4686dae..145349b 100644 --- a/test/SWIG/generated_swigfile.py +++ b/test/SWIG/generated_swigfile.py @@ -53,8 +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_h = \ - test.get_platform_python_info() +python, python_include, python_libpath, python_lib = \ + test.get_platform_python_info(python_h_required=True) # handle testing on other platforms: ldmodule_prefix = '_' diff --git a/test/SWIG/live.py b/test/SWIG/live.py index f0cf1d5..a64defe 100644 --- a/test/SWIG/live.py +++ b/test/SWIG/live.py @@ -46,8 +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_h = \ - test.get_platform_python_info() +python, python_include, python_libpath, python_lib = \ + test.get_platform_python_info(python_h_required=True) swig = swig.replace('\\','/') python = python.replace('\\','/') diff --git a/test/SWIG/module-deduced-name.py b/test/SWIG/module-deduced-name.py index 6b4d6d9..14d23a2 100644 --- a/test/SWIG/module-deduced-name.py +++ b/test/SWIG/module-deduced-name.py @@ -39,8 +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_h = \ - test.get_platform_python_info() +python, python_include, python_libpath, python_lib = \ + test.get_platform_python_info(python_h_required=True) # 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 040ef28..4ce7511 100644 --- a/test/SWIG/module-parens.py +++ b/test/SWIG/module-parens.py @@ -38,8 +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_h = \ - test.get_platform_python_info() +python, python_include, python_libpath, python_lib = \ + test.get_platform_python_info(python_h_required=True) # 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 8bf9e86..60bc0b0 100644 --- a/test/SWIG/module-quoted.py +++ b/test/SWIG/module-quoted.py @@ -38,8 +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_h = \ - test.get_platform_python_info() +python, python_include, python_libpath, python_lib = \ + test.get_platform_python_info(python_h_required=True) # 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 ce16497..6a3f270 100644 --- a/test/SWIG/module-spaces.py +++ b/test/SWIG/module-spaces.py @@ -38,8 +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_h = \ - test.get_platform_python_info() +python, python_include, python_libpath, python_lib = \ + test.get_platform_python_info(python_h_required=True) # 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 b4abbc3..f94f553 100644 --- a/test/SWIG/noproxy.py +++ b/test/SWIG/noproxy.py @@ -46,8 +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_h = \ - test.get_platform_python_info() +python, python_include, python_libpath, python_lib = \ + test.get_platform_python_info(python_h_required=True) # handle testing on other platforms: ldmodule_prefix = '_' diff --git a/test/SWIG/recursive-includes-cpp.py b/test/SWIG/recursive-includes-cpp.py index 4cb8fe5..3999cc3 100644 --- a/test/SWIG/recursive-includes-cpp.py +++ b/test/SWIG/recursive-includes-cpp.py @@ -44,8 +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) -python, python_include, python_libpath, python_lib, python_h = \ - test.get_platform_python_info() +python, python_include, python_libpath, python_lib = \ + test.get_platform_python_info(python_h_required=True) 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 ecbc19c..a4d7b16 100644 --- a/test/SWIG/remove-modules.py +++ b/test/SWIG/remove-modules.py @@ -46,8 +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_h = \ - test.get_platform_python_info() +python, python_include, python_libpath, python_lib = \ + test.get_platform_python_info(python_h_required=True) # handle testing on other platforms: ldmodule_prefix = '_' diff --git a/test/SWIG/subdir.py b/test/SWIG/subdir.py index 062f8dc..6951753 100644 --- a/test/SWIG/subdir.py +++ b/test/SWIG/subdir.py @@ -48,8 +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_h = \ - test.get_platform_python_info() +python, python_include, python_libpath, python_lib = \ + test.get_platform_python_info(python_h_required=True) # handle testing on other platforms: ldmodule_prefix = '_' -- cgit v0.12 From bd27fe421c384dffebdcd3a1732a925480e2db1f Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Fri, 17 Aug 2018 09:14:03 -0600 Subject: add missed TestCmd.py changes Signed-off-by: Mats Wichmann --- testing/framework/TestSCons.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/testing/framework/TestSCons.py b/testing/framework/TestSCons.py index 14a8fcc..bf6aabb 100644 --- a/testing/framework/TestSCons.py +++ b/testing/framework/TestSCons.py @@ -1256,21 +1256,25 @@ SConscript( sconscript ) # see also sys.prefix documentation return python_minor_version_string() - def get_platform_python_info(self): + def get_platform_python_info(self, python_h_required=False): """ Returns a path to a Python executable suitable for testing on - this platform and its associated include path, library path, - 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. + this platform and its associated include path, library path and + library name. - Returns: - (path to python, include path, library path, library name, header path) + If the Python executable or Python header (if required) + is not found, the test is skipped. + + Returns a tuple: + (path to python, include path, library path, library name) """ python = os.environ.get('python_executable', self.where_is('python')) if not python: self.skip_test('Can not find installed "python", skipping test.\n') + # construct a program to run in the intended environment + # in order to fetch the characteristics of that Python. + # Windows Python doesn't store all the info in config vars. if sys.platform == 'win32': self.run(program=python, stdin="""\ import sysconfig, sys, os.path @@ -1315,11 +1319,11 @@ if os.path.exists(Python_h): else: print("False") """) - detected = self.stdout().strip().split('\n') - if detected[3] == "False": + incpath, libpath, libname, python_h = self.stdout().strip().split('\n') + if python_h == "False" and python_h_required: self.skip_test('Can not find required "Python.h", skipping test.\n') - return [python] + detected + return (python, incpath, libpath, libname) def start(self, *args, **kw): """ -- cgit v0.12