diff options
author | Mats Wichmann <mats@linux.com> | 2018-10-16 15:39:13 (GMT) |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2018-10-16 15:39:44 (GMT) |
commit | 4ff8514b2cfffeda032b657e1d59c5ec7988fe88 (patch) | |
tree | 70d673a0d9dc6f8a93d2dc59e2a277c17fa0ea7b | |
parent | e422f8fa002b9cbe6fb5785c301cfc63d8843a99 (diff) | |
download | SCons-4ff8514b2cfffeda032b657e1d59c5ec7988fe88.zip SCons-4ff8514b2cfffeda032b657e1d59c5ec7988fe88.tar.gz SCons-4ff8514b2cfffeda032b657e1d59c5ec7988fe88.tar.bz2 |
Additional fixes for SWIG tests
Two tests were missing the raw-string marker when defining
the Python include path.
TestSCons:get_platform_python_info needed some rework for Windows,
it was failing to find the python library if running in a virtual
environment. Also removed a try-block; sys.version_info is standard
since Python 2.0 and so does not need wrapping.
Signed-off-by: Mats Wichmann <mats@linux.com>
-rw-r--r-- | src/CHANGES.txt | 3 | ||||
-rw-r--r-- | test/SWIG/remove-modules.py | 2 | ||||
-rw-r--r-- | test/SWIG/subdir.py | 2 | ||||
-rw-r--r-- | testing/framework/TestSCons.py | 23 |
4 files changed, 20 insertions, 10 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index d5b9251..b413ac3 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -139,7 +139,8 @@ RELEASE 3.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE to the specfile without adding specific logic for each one to scons. - The test for Python.h needed by swig tests is moved to get_python_platform so it does not have to be repeated in every test; picks up one failure - which did not make the (previously needed) check. + which did not make the (previously needed) check. Windows version + of get_python_platform needed some rework in case running in virtualenv. - If test opens os.devnull, register with atexit so file opens do not leak. - Fix bugs in Win32 process spawn logic to handle OSError exception correctly. - Use time.perf_counter instead of time.clock if it exists. diff --git a/test/SWIG/remove-modules.py b/test/SWIG/remove-modules.py index a4d7b16..4ce8eab 100644 --- a/test/SWIG/remove-modules.py +++ b/test/SWIG/remove-modules.py @@ -65,7 +65,7 @@ test.write("module.i", """\ test.write('SConstruct', """ foo = Environment(SWIGFLAGS='-python', %(swig_arch_var)s - CPPPATH=['%(python_include)s'], + CPPPATH=[r'%(python_include)s'], LDMODULEPREFIX='%(ldmodule_prefix)s', LDMODULESUFFIX='%(_dll)s', SWIG=[r'%(swig)s'], diff --git a/test/SWIG/subdir.py b/test/SWIG/subdir.py index 6951753..9336f19 100644 --- a/test/SWIG/subdir.py +++ b/test/SWIG/subdir.py @@ -63,7 +63,7 @@ else: test.write('SConstruct', """ env = Environment(SWIGFLAGS='-python', %(swig_arch_var)s - CPPPATH=['%(python_include)s/'], + CPPPATH=[r'%(python_include)s/'], LDMODULEPREFIX='%(ldmodule_prefix)s', LDMODULESUFFIX='%(_dll)s', SWIG=r'%(swig)s', diff --git a/testing/framework/TestSCons.py b/testing/framework/TestSCons.py index feadef9..68641f0 100644 --- a/testing/framework/TestSCons.py +++ b/testing/framework/TestSCons.py @@ -861,7 +861,7 @@ class TestSCons(TestCommon): # Java 11 outputs this to stdout if not m: m = re.search(r'javac (\d\.*\d)', self.stdout()) - + if m: version = m.group(1) self.javac_is_gcj = False @@ -1286,11 +1286,9 @@ SConscript( sconscript ) if sys.platform == 'win32': self.run(program=python, stdin="""\ import sysconfig, sys, os.path -try: - py_ver = 'python%d%d' % sys.version_info[:2] -except AttributeError: - py_ver = 'python' + sys.version[:3] -# print include and lib path +py_ver = 'python%d%d' % sys.version_info[:2] +# use distutils to help find include and lib path +# TODO: PY3 fine to use sysconfig.get_config_var("INCLUDEPY") try: import distutils.sysconfig exec_prefix = distutils.sysconfig.EXEC_PREFIX @@ -1298,12 +1296,23 @@ try: print(include) lib_path = os.path.join(exec_prefix, 'libs') if not os.path.exists(lib_path): + # check for virtualenv path. + # this might not build anything different than first try. + def venv_path(): + if hasattr(sys, 'real_prefix'): + return sys.real_prefix + if hasattr(sys, 'base_prefix'): + return sys.base_prefix + lib_path = os.path.join(venv_path(), 'libs') + if not os.path.exists(lib_path): + # not clear this is useful: 'lib' does not contain linkable libs lib_path = os.path.join(exec_prefix, 'lib') print(lib_path) except: include = os.path.join(sys.prefix, 'include', py_ver) print(include) - print(os.path.join(sys.prefix, 'lib', py_ver, 'config')) + lib_path = os.path.join(sys.prefix, 'lib', py_ver, 'config') + print(lib_path) print(py_ver) Python_h = os.path.join(include, "Python.h") if os.path.exists(Python_h): |