diff --git a/CHANGES.txt b/CHANGES.txt index a527c0fd35..34c645cc6a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -58,6 +58,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Clean up Variables: more consistently call them variables (finish the old change from Options) in docstrings, etc.; some typing and other tweaks. Update manpage and user guide for Variables usage. + - Regularize internal usage of Python version strings and drop one + old Python 2-only code block in a test. RELEASE 4.7.0 - Sun, 17 Mar 2024 17:22:20 -0700 diff --git a/SCons/Action.py b/SCons/Action.py index 9f0de17c70..567f66cef4 100644 --- a/SCons/Action.py +++ b/SCons/Action.py @@ -892,10 +892,10 @@ def scons_subproc_run(scons_env, *args, **kwargs) -> subprocess.CompletedProcess kwargs['check'] = check # TODO: Python version-compat stuff: remap/remove too-new args if needed - if 'text' in kwargs and sys.version_info[:3] < (3, 7): + if 'text' in kwargs and sys.version_info < (3, 7): kwargs['universal_newlines'] = kwargs.pop('text') - if 'capture_output' in kwargs and sys.version_info[:3] < (3, 7): + if 'capture_output' in kwargs and sys.version_info < (3, 7): capture_output = kwargs.pop('capture_output') if capture_output: kwargs['stdout'] = kwargs['stderr'] = PIPE diff --git a/scripts/scons-configure-cache.py b/scripts/scons-configure-cache.py index 8f81d8aec5..2ae6b14aa5 100644 --- a/scripts/scons-configure-cache.py +++ b/scripts/scons-configure-cache.py @@ -51,7 +51,7 @@ # python compatibility check if sys.version_info < (3, 6, 0): msg = "scons: *** SCons version %s does not run under Python version %s.\n\ -Python >= 3.5 is required.\n" +Python >= 3.6.0 is required.\n" sys.stderr.write(msg % (__version__, sys.version.split()[0])) sys.exit(1) diff --git a/scripts/scons.py b/scripts/scons.py index 6a36ef7ad4..efafdef803 100755 --- a/scripts/scons.py +++ b/scripts/scons.py @@ -44,7 +44,7 @@ # Python compatibility check if sys.version_info < (3, 6, 0): msg = "scons: *** SCons version %s does not run under Python version %s.\n\ -Python >= 3.5 is required.\n" +Python >= 3.6.0 is required.\n" sys.stderr.write(msg % (__version__, sys.version.split()[0])) sys.exit(1) diff --git a/scripts/sconsign.py b/scripts/sconsign.py index 19e0c8208a..95a9b96e67 100644 --- a/scripts/sconsign.py +++ b/scripts/sconsign.py @@ -43,7 +43,7 @@ # python compatibility check if sys.version_info < (3, 6, 0): msg = "scons: *** SCons version %s does not run under Python version %s.\n\ -Python >= 3.5 is required.\n" +Python >= 3.6.0 is required.\n" sys.stderr.write(msg % (__version__, sys.version.split()[0])) sys.exit(1) diff --git a/test/Execute.py b/test/Execute.py index 693bce47ed..07b88dc832 100644 --- a/test/Execute.py +++ b/test/Execute.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -20,15 +22,13 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ Test the Execute() function for executing actions directly. """ import sys import TestSCons +from TestCmd import IS_WINDOWS _python_ = TestSCons._python_ @@ -83,7 +83,7 @@ test.write('l.in', "l.in\n") test.write('m.in', "m.in\n") -if sys.platform == 'win32' and sys.version_info[0] == 3: +if IS_WINDOWS: expect = r"""scons: \*\*\* Error 1 scons: \*\*\* Error 2 scons: \*\*\* nonexistent.in: (The system cannot find the path specified|Das System kann den angegebenen Pfad nicht finden)""" diff --git a/test/SWIG/recursive-includes-cpp.py b/test/SWIG/recursive-includes-cpp.py index fd896f9e79..77ba2d4e82 100644 --- a/test/SWIG/recursive-includes-cpp.py +++ b/test/SWIG/recursive-includes-cpp.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -20,9 +22,6 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ Verify that SWIG include directives produce the correct dependencies @@ -46,10 +45,9 @@ 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' - if not os.path.isfile(python_lib): - test.skip_test('Can not find python lib at "' + python_lib + '", skipping test.%s' % os.linesep) +if TestCmd.IS_WINDOWS: + if not os.path.isfile(os.path.join(python_libpath, python_lib)): + test.skip_test(f"Can not find python lib {python_libh!r}, skipping test.\n") test.write("recursive.h", """\ /* An empty header file. */ @@ -79,37 +77,28 @@ TARGET_ARCH = "TARGET_ARCH = 'x86'," else: TARGET_ARCH = "" -test.write('SConstruct', """\ -import sysconfig -import sys +test.write('SConstruct', f"""\ import os +import sys +import sysconfig +DefaultEnvironment() env = Environment( - """ + TARGET_ARCH + """ - SWIGFLAGS = [ - '-python' - ], - CPPPATH = [ - sysconfig.get_config_var("INCLUDEPY") - ], - SHLIBPREFIX = "", - tools = [ 'default', 'swig' ] + {TARGET_ARCH} + SWIGFLAGS=['-python'], + CPPPATH=[sysconfig.get_config_var("INCLUDEPY")], + SHLIBPREFIX="", + tools=['default', 'swig'], ) if sys.platform == 'darwin': - env['LIBS']=['python%d.%d'%(sys.version_info[0],sys.version_info[1])] + env['LIBS'] = [f'python{sys.version_info.major}.{sys.version_info.minor}'] env.Append(LIBPATH=[sysconfig.get_config_var("LIBDIR")]) elif sys.platform == 'win32': - env.Append(LIBS=['python%d%d'%(sys.version_info[0],sys.version_info[1])]) + env.Append(LIBS=[f'python{sys.version_info.major}{sys.version_info.minor}.lib']) env.Append(LIBPATH=[os.path.dirname(sys.executable) + "/libs"]) -env.SharedLibrary( - 'mod', - [ - "mod.i", - "main.c", - ] -) +env.SharedLibrary('mod', ["mod.i", "main.c"]) """) if sys.platform == 'win32': diff --git a/test/option/option-j.py b/test/option/option-j.py index 0b0078fe9d..96b4a75b52 100644 --- a/test/option/option-j.py +++ b/test/option/option-j.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -20,15 +22,12 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# """ This tests the -j command line option, and the num_jobs SConscript settable option. """ -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - import os.path import sys @@ -122,43 +121,6 @@ def RunTest(args, extra): # succeeds. test.run(arguments='-j 2 out') -if sys.platform != 'win32' and sys.version_info[0] == 2: - # Test breaks on win32 when using real subprocess is not the only - # package to import threading - # - # Test that we fall back and warn properly if there's no threading.py - # module (simulated), which is the case if this version of Python wasn't - # built with threading support. - - test.subdir('pythonlib') - - test.write(['pythonlib', 'threading.py'], "raise ImportError\n") - - save_pythonpath = os.environ.get('PYTHONPATH', '') - os.environ['PYTHONPATH'] = test.workpath('pythonlib') - - #start2, finish1 = RunTest('-j 2 f1, f2', "fifth") - - test.write('f1.in', 'f1.in pythonlib\n') - test.write('f2.in', 'f2.in pythonlib\n') - - test.run(arguments = "-j 2 f1 f2", stderr=None) - - warn = """scons: warning: parallel builds are unsupported by this version of Python; -\tignoring -j or num_jobs option.""" - test.must_contain_all_lines(test.stderr(), [warn]) - - str = test.read("f1", mode='r') - start1,finish1 = list(map(float, str.split("\n"))) - - str = test.read("f2", mode='r') - start2,finish2 = list(map(float, str.split("\n"))) - - test.fail_test(start2 < finish1) - - os.environ['PYTHONPATH'] = save_pythonpath - - # Test SetJobs() with no -j: test.write('SConstruct', """ DefaultEnvironment(tools=[]) diff --git a/testing/framework/TestRuntest.py b/testing/framework/TestRuntest.py index d2b3b706ab..5277690867 100644 --- a/testing/framework/TestRuntest.py +++ b/testing/framework/TestRuntest.py @@ -123,9 +123,6 @@ def __init__(self, **kw) -> None: kw['program'] = 'runtest.py' if 'interpreter' not in kw: kw['interpreter'] = [python,] - if sys.version_info[0] < 3: - kw['interpreter'].append('-tt') - if 'match' not in kw: kw['match'] = match_exact if 'workdir' not in kw: diff --git a/testing/framework/TestSCons.py b/testing/framework/TestSCons.py index f55c332aaa..e3b88dfd8b 100644 --- a/testing/framework/TestSCons.py +++ b/testing/framework/TestSCons.py @@ -752,17 +752,10 @@ def get_sconsignname(self): def unlink_sconsignfile(self, name: str='.sconsign.dblite') -> None: """Delete the sconsign file. - Note on python it seems to append .p3 to the file name so we take - care of that. - - TODO the above seems to not be an issue any more. - Args: name: expected name of sconsign file """ - if sys.version_info[0] == 3: - name += '.p3' - self.unlink(name) + return self.unlink(name) def java_ENV(self, version=None): """ Initialize JAVA SDK environment. @@ -1621,7 +1614,7 @@ def venv_path(): if python_h == "False" and python_h_required: self.skip_test('Can not find required "Python.h", skipping test.\n', from_fw=True) - return (python, incpath, libpath, libname) + return (python, incpath, libpath, libname + _lib) def start(self, *args, **kw): """