From cf156d9524cdb1140c57ef376ff6a05f06c79534 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Tue, 12 May 2020 11:37:19 -0600 Subject: Some more fixups for project directory moves Signed-off-by: Mats Wichmann --- README.rst | 80 ++++++++++++++++++----------------- bin/scons-time.py | 6 ++- test/Interactive/configure.py | 11 ++--- test/scons-time/run/config/targets.py | 14 +++--- test/scons-time/run/option/quiet.py | 27 +++--------- test/scons-time/run/option/verbose.py | 16 +++---- testing/framework/TestRuntest.py | 16 +++---- 7 files changed, 82 insertions(+), 88 deletions(-) diff --git a/README.rst b/README.rst index a8432fd..a0c947a 100755 --- a/README.rst +++ b/README.rst @@ -63,7 +63,7 @@ information: Latest Version ============== -Before going further, you can check that this package you have is the latest +Before going further, you can check that the package you have is the latest version at the SCons download page: http://www.scons.org/pages/download.html @@ -72,13 +72,14 @@ version at the SCons download page: Execution Requirements ====================== -Running SCons requires Python 3.5 or higher. -There should be no other dependencies or requirements to run SCons. +Running SCons requires Python 3.5 or higher. There should be no other +dependencies or requirements to run scons, although the pywin32 Python +package is strongly recommended if running on Windows systems. The default SCons configuration assumes use of the Microsoft Visual C++ -compiler suite on WIN32 systems, and assumes a C compiler named 'cc', a C++ -compiler named 'c++', and a Fortran compiler named 'g77' (such as found in the -GNU C compiler suite) on any other type of system. You may, of course, +compiler suite on Win32 systems, and assumes a C compiler named 'cc', a C++ +compiler named 'c++', and a Fortran compiler named 'gfortran' (such as found +in the GNU C compiler suite) on any other type of system. You may, of course, override these default values by appropriate configuration of Environment construction variables. @@ -97,29 +98,29 @@ Nothing special. Executing SCons Without Installing ================================== -You can execute the local SCons directly from the src/ subdirectory by first -setting the SCONS_LIB_DIR environment variable to the local src/engine -subdirectory, and then executing the local src/script/scons.py script to +You can execute the local SCons directly from the SCons subdirectory by first +setting the SCONS_LIB_DIR environment variable to the local SCons +subdirectory, and then executing the local scripts/scons.py script to populate the build/scons/ subdirectory. You would do this as follows on a Linux or UNIX system (using sh or a derivative like bash or ksh):: $ setenv MYSCONS=`pwd` - $ python $MYSCONS/script/scons.py [arguments] + $ python $MYSCONS/scripts/scons.py [arguments] Or on Windows:: - C:\scons>set MYSCONS=%cd%\src - C:\scons>python %MYSCONS%\script\scons.py [arguments] + C:\scons>set MYSCONS=%cd% + C:\scons>python %MYSCONS%\scripts\scons.py [arguments] An alternative approach is to skip the above and use:: - $ python script/scons.py [arguments] + $ python scripts/scons.py [arguments] You can use the -C option to have SCons change directory to another location where you already have a build configuration set up:: - $ python script/scons.py -C /some/other/location [arguments] + $ python scripts/scons.py -C /some/other/location [arguments] For simplicity in the following examples, we will only show the bootstrap.py approach. @@ -171,23 +172,22 @@ Because SCons is implemented in a scripting language, you don't need to build it in order to make changes and test them. Virtually all of the SCons functionality exists in the "build engine," the -src/engine/SCons subdirectory hierarchy that contains all of the modules that -make up SCons. The script/scons.py wrapper script exists mainly to find +SCons subdirectory hierarchy that contains all of the modules that +make up SCons. The scripts/scons.py wrapper script exists mainly to find the appropriate build engine library and then execute it. In order to make your own changes locally and test them by hand, simply edit -modules in the local src/engine/SCons subdirectory tree and use the local -bootstrap.py script (see the section above about `Executing SCons Without -Installing`_):: +modules in the local SCons subdirectory tree and then running +(see the section above about `Executing SCons Without Installing`_):: - $ python script/scons.py [arguments] + $ python scripts/scons.py [arguments] If you want to be able to just execute your modified version of SCons from the command line, you can make it executable and add its directory to your $PATH like so:: - $ chmod 755 script/scons.py - $ export PATH=$PATH:`pwd`/script + $ chmod 755 scripts/scons.py + $ export PATH=$PATH:`pwd`/scripts You should then be able to run this version of SCons by just typing "scons.py" at your UNIX or Linux command line. @@ -207,13 +207,13 @@ Python comes with a good interactive debugger. When debugging changes by hand of the Python debugger by specifying the --debug=pdb option:: $ scons --debug=pdb [arguments] - > /home/knight/SCons/src/engine/SCons/Script/Main.py(927)_main() + > /home/knight/scons/SCons/Script/Main.py(927)_main() -> default_warnings = [ SCons.Warnings.CorruptSConsignWarning, (Pdb) Once in the debugger, you can set breakpoints at lines in files in the build engine modules by providing the path name of the file relative to the -src/engine subdirectory (that is, including the SCons/ as the first directory +top directory (that is, including the SCons/ as the first directory component):: (Pdb) b SCons/Tool/msvc.py:158 @@ -230,9 +230,11 @@ call within a test script. The most effective technique for debugging problems that occur during an automated test is to use the good old tried-and-true technique of adding statements to print tracing information. But note that you can't just use -"print" statement, or even "sys.stdout.write()" because those change the +the "print" function, or even "sys.stdout.write()" because those change the SCons output, and the automated tests usually look for matches of specific -output strings to decide if a given SCons invocations passes the test. +output strings to decide if a given SCons invocation passes the test - +so these additions may cause apparent failures different than the one you +are trying to debug. To deal with this, SCons supports a Trace() function that (by default) will print messages to your console screen ("/dev/tty" on UNIX or Linux, "con" on @@ -266,8 +268,8 @@ Tests are run by the runtest.py script in this directory. There are two types of tests in this package: -1. Unit tests for individual SCons modules live underneath the src/engine/ - subdirectory and are the same base name as the module with "Tests.py" +1. Unit tests for individual SCons modules live underneath the SCons + subdirectory and have the same base name as the module with "Tests.py" appended--for example, the unit test for the Builder.py module is the BuilderTests.py script. @@ -275,7 +277,7 @@ There are two types of tests in this package: You may specifically list one or more tests to be run:: - $ python runtest.py src/engine/SCons/BuilderTests.py + $ python runtest.py SCons/BuilderTests.py $ python runtest.py test/option-j.py test/Program.py @@ -302,7 +304,7 @@ many tests passed, failed, or yielded no result, and lists any unsuccessful tests. The above invocations all test directly the files underneath the SCons/ -subdirectory, and do not require that a build be performed first. +subdirectory, and do not require that a build be performed first. Development Workflow ==================== @@ -330,21 +332,21 @@ platform, Windows users can translate as appropriate)): - Confirm that the bug still exists in this version of SCons by using the -C option to run the broken build:: - $ python script/scons.py -C /home/me/broken_project . + $ python scripts/scons.py -C /home/me/broken_project . - Fix the bug in SCons by editing appropriate module files underneath SCons. - Confirm that you've fixed the bug affecting your project:: - $ python script/scons.py -C /home/me/broken_project . + $ python scripts/scons.py -C /home/me/broken_project . - Test to see if your fix had any unintended side effects that break existing functionality:: $ python runtest.py -a -o test.log - Be patient, there are more than 700 test scripts in the whole suite. If you + Be patient, there are more than 1100 test scripts in the whole suite. If you are on UNIX/Linux, you can use:: $ python runtest.py -a | tee test.log @@ -354,7 +356,9 @@ platform, Windows users can translate as appropriate)): If any test scripts fail, they will be listed in a summary at the end of the log file. Some test scripts may also report NO RESULT because (for example) your local system is the wrong type or doesn't have some installed utilities - necessary to run the script. In general, you can ignore the NO RESULT list. + necessary to run the script. In general, you can ignore the NO RESULT list, + beyond having checked once that the tests that matter to your change are + actually being executed on your test system! - Cut-and-paste the list of failed tests into a file:: @@ -381,7 +385,7 @@ platform, Windows users can translate as appropriate)): the tests to pass didn't break the fix you originally put in, and didn't introduce any *additional* unintended side effects that broke other tests:: - $ python script/scons.py -C /home/me/broken_project . + $ python scripts/scons.py -C /home/me/broken_project . $ python runtest.py -a -o test.log If you find any newly-broken tests, add them to your "failed.txt" file and @@ -407,7 +411,7 @@ If you don't have SCons already installed on your system, you can use the supplied bootstrap.py script (see the section above about `Executing SCons Without Installing`_):: - $ python script/scons.py build/scons + $ python scripts/scons.py build/scons Depending on the utilities installed on your system, any or all of the following packages will be built:: @@ -525,8 +529,8 @@ testing/ Documentation ============= -See the src/RELEASE.txt file for notes about this specific release, including -known problems. See the src/CHANGES.txt file for a list of changes since the +See the RELEASE.txt file for notes about this specific release, including +known problems. See the CHANGES.txt file for a list of changes since the previous release. The doc/man/scons.1 man page is included in this package, and contains a diff --git a/bin/scons-time.py b/bin/scons-time.py index 693b254..f4decc9 100644 --- a/bin/scons-time.py +++ b/bin/scons-time.py @@ -1246,7 +1246,11 @@ class SConsTimer(object): return os.path.join(dir, 'scripts', 'scons.py') def scons_lib_dir_path(self, dir): - return os.path.join(dir, 'src', 'engine') + """build the path to the engine. + + this used to join src/engine, but no longer. + """ + return dir def prep_subversion_run(self, commands, removals): self.svn_tmpdir = tempfile.mkdtemp(prefix=self.name + '-svn-') diff --git a/test/Interactive/configure.py b/test/Interactive/configure.py index 9c7ef49..44a53eb 100644 --- a/test/Interactive/configure.py +++ b/test/Interactive/configure.py @@ -21,7 +21,6 @@ # 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 basic operation of the --interactive command line option to build @@ -30,6 +29,8 @@ a target, while using a Configure context within the environment. Also tests that "b" can be used as a synonym for "build". """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import TestSCons _python_ = TestSCons._python_ @@ -118,15 +119,15 @@ test.finish(scons, stdout = expect_stdout, match=TestSCons.match_re) test.pass_test() + +# not used: just record here to help debugging the expect_stdout pattern actual_output_to_be_handled=""" -Actual output -python3.6 ~/devel/scons/hg/scons/src/script/scons.py -Q --interactive scons>>> build foo.obj -/opt/local/bin/python3.6 mycc.py foo.obj foo.cpp +/usr/bin/python3 mycc.py foo.obj foo.cpp scons>>> build foo.obj scons: `foo.obj' is up to date. scons>>> b foo.obj -/opt/local/bin/python3.6 mycc.py foo.obj foo.cpp +/usr/bin/python3 mycc.py foo.obj foo.cpp scons>>> build foo.obj scons: `foo.obj' is up to date. scons>>> diff --git a/test/scons-time/run/config/targets.py b/test/scons-time/run/config/targets.py index 1712b32..5770713 100644 --- a/test/scons-time/run/config/targets.py +++ b/test/scons-time/run/config/targets.py @@ -22,18 +22,18 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - """ Verify specifying a list of targets through a config file. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import os import re import TestSCons_time -test = TestSCons_time.TestSCons_time(match = TestSCons_time.match_re) +test = TestSCons_time.TestSCons_time(match=TestSCons_time.match_re) test.write_fake_scons_py() @@ -46,12 +46,12 @@ targets = 'target1 target2' test.run(arguments = 'run -f config foo.tar.gz') scons_py = re.escape(test.workpath('scripts', 'scons.py')) -src_engine = re.escape(test.workpath('src', 'engine')) +src_engine = re.escape(test.workpath()) -prof1 = re.escape(test.workpath('foo-000-1.prof')) -prof2 = re.escape(test.workpath('foo-000-2.prof')) +prof1 = re.escape(test.workpath('foo-000-1.prof')) +prof2 = re.escape(test.workpath('foo-000-2.prof')) -sep = re.escape(os.sep) +sep = re.escape(os.sep) expect = """\ %(scons_py)s diff --git a/test/scons-time/run/option/quiet.py b/test/scons-time/run/option/quiet.py index 0f6c22b..f3f2a27 100644 --- a/test/scons-time/run/option/quiet.py +++ b/test/scons-time/run/option/quiet.py @@ -22,23 +22,23 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - """ Verify that the run -q and --quiet options suppress build output. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import re import TestSCons_time python = TestSCons_time.python -test = TestSCons_time.TestSCons_time(match = TestSCons_time.match_re, - diff = TestSCons_time.diff_re) +test = TestSCons_time.TestSCons_time(match=TestSCons_time.match_re, + diff=TestSCons_time.diff_re) scons_py = re.escape(test.workpath('scripts', 'scons.py')) -src_engine = re.escape(test.workpath('src', 'engine')) +src_engine = re.escape(test.workpath()) tmp_scons_time = test.tempdir_re() tmp_scons_time_foo = test.tempdir_re('foo') @@ -55,7 +55,7 @@ SCONS_LIB_DIR = %(src_engine)s SConstruct file directory: %(tmp_scons_time_foo)s """ % locals() -test.run(arguments = 'run -q foo.tar.gz', stdout = expect) +test.run(arguments='run -q foo.tar.gz', stdout=expect) test.must_exist('foo-000-0.log', 'foo-000-0.prof', @@ -64,20 +64,7 @@ test.must_exist('foo-000-0.log', 'foo-000-2.log', 'foo-000-2.prof') -scons_py = test.workpath('src/script/scons.py') - -src_engine = test.workpath('src/engine') - -test.run(arguments = 'run -q foo.tar.gz', stdout = expect) - -test.must_exist('foo-001-0.log', - 'foo-001-0.prof', - 'foo-001-1.log', - 'foo-001-1.prof', - 'foo-001-2.log', - 'foo-001-2.prof') - -test.run(arguments = 'run --quiet foo.tar.gz', stdout = expect) +test.run(arguments='run --quiet foo.tar.gz', stdout=expect) test.pass_test() diff --git a/test/scons-time/run/option/verbose.py b/test/scons-time/run/option/verbose.py index 9c4e7e8..bf8d48f 100644 --- a/test/scons-time/run/option/verbose.py +++ b/test/scons-time/run/option/verbose.py @@ -22,12 +22,12 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - """ Verify that the run -v and --verbose options display command output. """ +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + import sys import re import os @@ -36,11 +36,11 @@ import TestSCons_time _python_ = re.escape('"' + sys.executable + '"') -test = TestSCons_time.TestSCons_time(match = TestSCons_time.match_re, - diff = TestSCons_time.diff_re) +test = TestSCons_time.TestSCons_time(match=TestSCons_time.match_re, + diff=TestSCons_time.diff_re) scons_py = re.escape(test.workpath('scripts', 'scons.py')) -src_engine = re.escape(test.workpath('src', 'engine')) +src_engine = re.escape(test.workpath()) tmp_scons_time = test.tempdir_re() tmp_scons_time_foo = test.tempdir_re('foo') @@ -57,7 +57,7 @@ SCONS_LIB_DIR = %(src_engine)s SConstruct file directory: %(tmp_scons_time_foo)s """ % locals() -test.run(arguments = 'run -q foo.tar.gz', stdout = expect) +test.run(arguments='run -q foo.tar.gz', stdout=expect) test.must_exist('foo-000-0.log', 'foo-000-0.prof', @@ -126,7 +126,7 @@ prof0 = re.escape(test.workpath('foo-001-0.prof')) prof1 = re.escape(test.workpath('foo-001-1.prof')) prof2 = re.escape(test.workpath('foo-001-2.prof')) -test.run(arguments = 'run -v foo.tar.gz', stdout = expect % locals()) +test.run(arguments='run -v foo.tar.gz', stdout=expect % locals()) test.must_exist('foo-001-0.log', 'foo-001-0.prof', @@ -143,7 +143,7 @@ prof0 = re.escape(test.workpath('foo-002-0.prof')) prof1 = re.escape(test.workpath('foo-002-1.prof')) prof2 = re.escape(test.workpath('foo-002-2.prof')) -test.run(arguments = 'run --verbose foo.tar.gz', stdout = expect % locals()) +test.run(arguments='run --verbose foo.tar.gz', stdout=expect % locals()) test.pass_test() diff --git a/testing/framework/TestRuntest.py b/testing/framework/TestRuntest.py index a752161..801f710 100644 --- a/testing/framework/TestRuntest.py +++ b/testing/framework/TestRuntest.py @@ -147,15 +147,13 @@ class TestRuntest(TestCommon): os.environ['PYTHONPATH'] = '' def write_fake_scons_source_tree(self): - os.mkdir('src') - os.mkdir('src/script') - self.write('src/script/scons.py', fake_scons_py) - - os.mkdir('src/engine') - os.mkdir('src/engine/SCons') - self.write('src/engine/SCons/__init__.py', fake___init___py) - os.mkdir('src/engine/SCons/Script') - self.write('src/engine/SCons/Script/__init__.py', fake___init___py) + os.mkdir('scripts') + self.write('scripts/scons.py', fake_scons_py) + + os.mkdir('SCons') + self.write('SCons/__init__.py', fake___init___py) + os.mkdir('SCons/Script') + self.write('SCons/Script/__init__.py', fake___init___py) def write_failing_test(self, name): self.write(name, failing_test_template) -- cgit v0.12 From 235be1e824086979de4748ed07c6f3f34d947c18 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Tue, 12 May 2020 13:01:57 -0600 Subject: [PR 3648] fixups from review comments README-SF.rst now matches README.rst again Incorrectly dropped part of scons-time tests restored. Signed-off-by: Mats Wichmann --- README-SF.rst | 89 +++++++++++++++++++------------------ test/scons-time/run/option/quiet.py | 9 ++++ 2 files changed, 55 insertions(+), 43 deletions(-) diff --git a/README-SF.rst b/README-SF.rst index 9a51d87..2fa9acd 100755 --- a/README-SF.rst +++ b/README-SF.rst @@ -38,7 +38,7 @@ information: Latest Version ============== -Before going further, you can check that this package you have is the latest +Before going further, you can check that the package you have is the latest version at the SCons download page: http://www.scons.org/pages/download.html @@ -47,13 +47,14 @@ version at the SCons download page: Execution Requirements ====================== -Running SCons requires Python 3.5 or higher. -There should be no other dependencies or requirements to run SCons. +Running SCons requires Python 3.5 or higher. There should be no other +dependencies or requirements to run scons, although the pywin32 Python +package is strongly recommended if running on Windows systems. The default SCons configuration assumes use of the Microsoft Visual C++ -compiler suite on WIN32 systems, and assumes a C compiler named 'cc', a C++ -compiler named 'c++', and a Fortran compiler named 'g77' (such as found in the -GNU C compiler suite) on any other type of system. You may, of course, +compiler suite on Win32 systems, and assumes a C compiler named 'cc', a C++ +compiler named 'c++', and a Fortran compiler named 'gfortran' (such as found +in the GNU C compiler suite) on any other type of system. You may, of course, override these default values by appropriate configuration of Environment construction variables. @@ -72,29 +73,29 @@ Nothing special. Executing SCons Without Installing ================================== -You can execute the local SCons directly from the src/ subdirectory by first -setting the SCONS_LIB_DIR environment variable to the local src/engine -subdirectory, and then executing the local src/script/scons.py script to +You can execute the local SCons directly from the SCons subdirectory by first +setting the SCONS_LIB_DIR environment variable to the local SCons +subdirectory, and then executing the local scripts/scons.py script to populate the build/scons/ subdirectory. You would do this as follows on a Linux or UNIX system (using sh or a derivative like bash or ksh):: $ setenv MYSCONS=`pwd` - $ python $MYSCONS/script/scons.py [arguments] + $ python $MYSCONS/scripts/scons.py [arguments] Or on Windows:: - C:\scons>set MYSCONS=%cd%\src - C:\scons>python %MYSCONS%\script\scons.py [arguments] + C:\scons>set MYSCONS=%cd% + C:\scons>python %MYSCONS%\scripts\scons.py [arguments] An alternative approach is to skip the above and use:: - $ python script/scons.py [arguments] + $ python scripts/scons.py [arguments] You can use the -C option to have SCons change directory to another location where you already have a build configuration set up:: - $ python script/scons.py -C /some/other/location [arguments] + $ python scripts/scons.py -C /some/other/location [arguments] For simplicity in the following examples, we will only show the bootstrap.py approach. @@ -146,23 +147,22 @@ Because SCons is implemented in a scripting language, you don't need to build it in order to make changes and test them. Virtually all of the SCons functionality exists in the "build engine," the -src/engine/SCons subdirectory hierarchy that contains all of the modules that -make up SCons. The script/scons.py wrapper script exists mainly to find +SCons subdirectory hierarchy that contains all of the modules that +make up SCons. The scripts/scons.py wrapper script exists mainly to find the appropriate build engine library and then execute it. In order to make your own changes locally and test them by hand, simply edit -modules in the local src/engine/SCons subdirectory tree and use the local -bootstrap.py script (see the section above about `Executing SCons Without -Installing`_):: +modules in the local SCons subdirectory tree and then running +(see the section above about `Executing SCons Without Installing`_):: - $ python script/scons.py [arguments] + $ python scripts/scons.py [arguments] If you want to be able to just execute your modified version of SCons from the command line, you can make it executable and add its directory to your $PATH like so:: - $ chmod 755 script/scons.py - $ export PATH=$PATH:`pwd`/script + $ chmod 755 scripts/scons.py + $ export PATH=$PATH:`pwd`/scripts You should then be able to run this version of SCons by just typing "scons.py" at your UNIX or Linux command line. @@ -182,13 +182,13 @@ Python comes with a good interactive debugger. When debugging changes by hand of the Python debugger by specifying the --debug=pdb option:: $ scons --debug=pdb [arguments] - > /home/knight/SCons/src/engine/SCons/Script/Main.py(927)_main() + > /home/knight/scons/SCons/Script/Main.py(927)_main() -> default_warnings = [ SCons.Warnings.CorruptSConsignWarning, (Pdb) Once in the debugger, you can set breakpoints at lines in files in the build engine modules by providing the path name of the file relative to the -src/engine subdirectory (that is, including the SCons/ as the first directory +top directory (that is, including the SCons/ as the first directory component):: (Pdb) b SCons/Tool/msvc.py:158 @@ -205,9 +205,11 @@ call within a test script. The most effective technique for debugging problems that occur during an automated test is to use the good old tried-and-true technique of adding statements to print tracing information. But note that you can't just use -"print" statement, or even "sys.stdout.write()" because those change the +the "print" function, or even "sys.stdout.write()" because those change the SCons output, and the automated tests usually look for matches of specific -output strings to decide if a given SCons invocations passes the test. +output strings to decide if a given SCons invocation passes the test - +so these additions may cause apparent failures different than the one you +are trying to debug. To deal with this, SCons supports a Trace() function that (by default) will print messages to your console screen ("/dev/tty" on UNIX or Linux, "con" on @@ -241,8 +243,8 @@ Tests are run by the runtest.py script in this directory. There are two types of tests in this package: -1. Unit tests for individual SCons modules live underneath the src/engine/ - subdirectory and are the same base name as the module with "Tests.py" +1. Unit tests for individual SCons modules live underneath the SCons + subdirectory and have the same base name as the module with "Tests.py" appended--for example, the unit test for the Builder.py module is the BuilderTests.py script. @@ -250,7 +252,7 @@ There are two types of tests in this package: You may specifically list one or more tests to be run:: - $ python runtest.py src/engine/SCons/BuilderTests.py + $ python runtest.py SCons/BuilderTests.py $ python runtest.py test/option-j.py test/Program.py @@ -276,10 +278,9 @@ If more than one test is run, the runtest.py script prints a summary of how many tests passed, failed, or yielded no result, and lists any unsuccessful tests. -The above invocations all test directly the files underneath the src/ +The above invocations all test directly the files underneath the SCons/ subdirectory, and do not require that a build be performed first. - Development Workflow ==================== @@ -306,21 +307,21 @@ platform, Windows users can translate as appropriate)): - Confirm that the bug still exists in this version of SCons by using the -C option to run the broken build:: - $ python script/scons.py -C /home/me/broken_project . + $ python scripts/scons.py -C /home/me/broken_project . - Fix the bug in SCons by editing appropriate module files underneath - src/engine/SCons. + SCons. - Confirm that you've fixed the bug affecting your project:: - $ python script/scons.py -C /home/me/broken_project . + $ python scripts/scons.py -C /home/me/broken_project . - Test to see if your fix had any unintended side effects that break existing functionality:: $ python runtest.py -a -o test.log - Be patient, there are more than 700 test scripts in the whole suite. If you + Be patient, there are more than 1100 test scripts in the whole suite. If you are on UNIX/Linux, you can use:: $ python runtest.py -a | tee test.log @@ -330,7 +331,9 @@ platform, Windows users can translate as appropriate)): If any test scripts fail, they will be listed in a summary at the end of the log file. Some test scripts may also report NO RESULT because (for example) your local system is the wrong type or doesn't have some installed utilities - necessary to run the script. In general, you can ignore the NO RESULT list. + necessary to run the script. In general, you can ignore the NO RESULT list, + beyond having checked once that the tests that matter to your change are + actually being executed on your test system! - Cut-and-paste the list of failed tests into a file:: @@ -357,7 +360,7 @@ platform, Windows users can translate as appropriate)): the tests to pass didn't break the fix you originally put in, and didn't introduce any *additional* unintended side effects that broke other tests:: - $ python script/scons.py -C /home/me/broken_project . + $ python scripts/scons.py -C /home/me/broken_project . $ python runtest.py -a -o test.log If you find any newly-broken tests, add them to your "failed.txt" file and @@ -383,7 +386,7 @@ If you don't have SCons already installed on your system, you can use the supplied bootstrap.py script (see the section above about `Executing SCons Without Installing`_):: - $ python script/scons.py build/scons + $ python scripts/scons.py build/scons Depending on the utilities installed on your system, any or all of the following packages will be built:: @@ -473,7 +476,7 @@ README-local runtest.py Script for running SCons tests. By default, this will run a test against - the code in the local src/ tree, so you don't have to do a build before + the code in the local SCons tree, so you don't have to do a build before testing your changes. SConstruct @@ -487,13 +490,13 @@ SConstruct this file for an example of how easy it is to use SCons to build "normal" software.) -src/ +SCons/ Where the actual source code is kept, of course. test/ End-to-end tests of the SCons utility itself. These are separate from the individual module unit tests, which live side-by-side with the modules - under src/. + under SCons. testing/ SCons testing framework. @@ -501,8 +504,8 @@ testing/ Documentation ============= -See the src/RELEASE.txt file for notes about this specific release, including -known problems. See the src/CHANGES.txt file for a list of changes since the +See the RELEASE.txt file for notes about this specific release, including +known problems. See the CHANGES.txt file for a list of changes since the previous release. The doc/man/scons.1 man page is included in this package, and contains a diff --git a/test/scons-time/run/option/quiet.py b/test/scons-time/run/option/quiet.py index f3f2a27..d3e0eda 100644 --- a/test/scons-time/run/option/quiet.py +++ b/test/scons-time/run/option/quiet.py @@ -64,6 +64,15 @@ test.must_exist('foo-000-0.log', 'foo-000-2.log', 'foo-000-2.prof') +test.run(arguments='run -q foo.tar.gz', stdout=expect) + +test.must_exist('foo-001-0.log', + 'foo-001-0.prof', + 'foo-001-1.log', + 'foo-001-1.prof', + 'foo-001-2.log', + 'foo-001-2.prof') + test.run(arguments='run --quiet foo.tar.gz', stdout=expect) test.pass_test() -- cgit v0.12 From 968c617c8dd60f183046747ea8f202bf49fe33c2 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 12 May 2020 12:07:47 -0700 Subject: [ci skip] Adding requirements.txt for packages needed for development, packaging, upload, but not for running SCons --- requirements.txt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..5608edf --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +# Packages needed for development, packaging, and distribution, but not for running SCons + +# This will check if the README.rst will render o.k. on pypi and not block an upload +# Can be used with twinecheck +# See: https://github.com/pypa/readme_renderer +readme-renderer -- cgit v0.12 From e4adb7000dd9cf3688771fd32d0bf52df4f9d58e Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Wed, 13 May 2020 11:08:23 -0600 Subject: Eliminate Py2-compat with_metaclass jig SCons has used a wrapper trick because the way a class declares it uses a metaclass differs between Py2 and Py3. Drop this usage and list the metaclass the Py3 way. Along the way, stop reusing the type class name as a parameter, as it might be confusing (SCons and packaging). Signed-off-by: Mats Wichmann --- SCons/Executor.py | 6 +++--- SCons/Node/__init__.py | 4 ++-- SCons/SConf.py | 4 ++-- SCons/Tool/packaging/__init__.py | 6 +++--- SCons/compat/__init__.py | 42 +++------------------------------------- 5 files changed, 13 insertions(+), 49 deletions(-) diff --git a/SCons/Executor.py b/SCons/Executor.py index fb2224f..e012ab6 100644 --- a/SCons/Executor.py +++ b/SCons/Executor.py @@ -35,7 +35,7 @@ from SCons.Debug import logInstanceCreation import SCons.Errors import SCons.Memoize import SCons.Util -from SCons.compat import with_metaclass, NoSlotsPyPy +from SCons.compat import NoSlotsPyPy class Batch(object): """Remembers exact association between targets @@ -154,7 +154,7 @@ _execute_str_map = {0 : execute_null_str, 1 : execute_actions_str} -class Executor(object, with_metaclass(NoSlotsPyPy)): +class Executor(object, metaclass=NoSlotsPyPy): """A class for controlling instances of executing an action. This largely exists to hold a single association of an action, @@ -587,7 +587,7 @@ def get_NullEnvironment(): nullenv = NullEnvironment() return nullenv -class Null(object, with_metaclass(NoSlotsPyPy)): +class Null(object, metaclass=NoSlotsPyPy): """A null Executor, with a null build Environment, that does nothing when the rest of the methods call it. diff --git a/SCons/Node/__init__.py b/SCons/Node/__init__.py index c3565bf..c1bb822 100644 --- a/SCons/Node/__init__.py +++ b/SCons/Node/__init__.py @@ -62,7 +62,7 @@ from SCons.Util import MD5signature from SCons.Debug import Trace -from SCons.compat import with_metaclass, NoSlotsPyPy +from SCons.compat import NoSlotsPyPy print_duplicate = 0 @@ -511,7 +511,7 @@ class BuildInfoBase(object): setattr(self, key, value) -class Node(object, with_metaclass(NoSlotsPyPy)): +class Node(object, metaclass=NoSlotsPyPy): """The base Node class, for entities that we know how to build, or use to build other Nodes. """ diff --git a/SCons/SConf.py b/SCons/SConf.py index e0e492b..eac4fb0 100644 --- a/SCons/SConf.py +++ b/SCons/SConf.py @@ -64,9 +64,9 @@ SCons.Conftest.LogErrorMessages = 0 build_type = None build_types = ['clean', 'help'] -def SetBuildType(type): +def SetBuildType(buildtype): global build_type - build_type = type + build_type = buildtype # to be set, if we are in dry-run mode dryrun = 0 diff --git a/SCons/Tool/packaging/__init__.py b/SCons/Tool/packaging/__init__.py index b6dd42e..6ac244c 100644 --- a/SCons/Tool/packaging/__init__.py +++ b/SCons/Tool/packaging/__init__.py @@ -121,12 +121,12 @@ def Package(env, target=None, source=None, **kw): PACKAGETYPE=PACKAGETYPE.split(',') # load the needed packagers. - def load_packager(type): + def load_packager(pkgtype): try: # the specific packager is a relative import - return importlib.import_module("." + type, __name__) + return importlib.import_module("." + pkgtype, __name__) except ImportError as e: - raise SConsEnvironmentError("packager %s not available: %s" % (type, str(e))) + raise SConsEnvironmentError("packager %s not available: %s" % (pkgtype, str(e))) packagers = list(map(load_packager, PACKAGETYPE)) diff --git a/SCons/compat/__init__.py b/SCons/compat/__init__.py index 18bef48..abf663d 100644 --- a/SCons/compat/__init__.py +++ b/SCons/compat/__init__.py @@ -96,47 +96,11 @@ except AttributeError: shutil.SameFileError = SameFileError -def with_metaclass(meta, *bases): - """ - Function from jinja2/_compat.py. License: BSD. - - Use it like this:: - - class BaseForm(object): - pass - - class FormType(type): - pass - - class Form(with_metaclass(FormType, BaseForm)): - pass - - This requires a bit of explanation: the basic idea is to make a - dummy metaclass for one level of class instantiation that replaces - itself with the actual metaclass. Because of internal type checks - we also need to make sure that we downgrade the custom metaclass - for one level to something closer to type (that's why __call__ and - __init__ comes back from type etc.). - - This has the advantage over six.with_metaclass of not introducing - dummy classes into the final MRO. - """ - - class metaclass(meta): - __call__ = type.__call__ - __init__ = type.__init__ - - def __new__(cls, name, this_bases, d): - if this_bases is None: - return type.__new__(cls, name, (), d) - return meta(name, bases, d) - - return metaclass('temporary_class', None, {}) - class NoSlotsPyPy(type): - """ - Workaround for PyPy not working well with __slots__ and __class__ assignment. + """ Metaclass for PyPy compatitbility. + + PyPy does not work well with __slots__ and __class__ assignment. """ def __new__(meta, name, bases, dct): -- cgit v0.12 From e1d822fbe1d5b1399d1d2eb14ed29e4c5c42c46b Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Wed, 13 May 2020 22:26:21 -0500 Subject: clean up travis and fix coverage --- .travis.yml | 96 +++++++++++++++---------------------------------------------- 1 file changed, 23 insertions(+), 73 deletions(-) diff --git a/.travis.yml b/.travis.yml index b941f4c..e0f4340 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,11 +19,6 @@ install: # do the rest of the image setup - ./.travis/install.sh -# run coverage first as its still useful to collect -stages: - - Coverage - - Test - # Note: Travis does not provide a way to specify the order of # jobs within a Stage, which are "run in parallel", but with # limitations: from observation four or five are kicked @@ -41,106 +36,61 @@ jobs: # allow coverage to fail, so we can still do testing for all platforms allow_failures: - python: pypy3 - - stage: Coverage + include: - &test_job - stage: Test script: python runtest.py -a -t -j 2 || if [[ $? == 2 ]]; then true; else false; fi before_script: skip after_success: skip python: pypy3 - env: - - PYVER=pypy3 - - PYTHON=pypy3 - <<: *test_job python: 3.5 - env: - - PYVER=35 - - PYTHON=3.5 - <<: *test_job python: 3.6 - env: - - PYVER=36 - - PYTHON=3.6 - + - <<: *test_job python: 3.7 - env: - - PYVER=37 - - PYTHON=3.7 dist: xenial # required for Python >= 3.7 - <<: *test_job python: 3.8 - env: - - PYVER=38 - - PYTHON=3.8 dist: bionic # required for Python >= 3.8 - - &coverage_jobs - stage: Coverage dist: bionic python: 3.7 before_script: - # install our own python so we can modify usercustomize.py -# - deactivate -# - sudo add-apt-repository -y ppa:deadsnakes/ppa -# - sudo apt-get update || true -# - sudo apt-get -y install python$PYTHON -# - wget https://bootstrap.pypa.io/get-pip.py -# - sudo -H python$PYTHON get-pip.py - - which python - - python --version - python -m pip install -U coverage codecov - # set this ensure user sites are available - - export PYTHONNOUSERSITE= - # attempt to get a location where we can store the usercustomize.py file - python -m site -# - export PYSITEDIR=$(python -m site --user-site) + # setup sitecustomize so we can make all subprocess start coverage - export PYSITEDIR=$(python -c "import sys; print(sys.path[-1])") - - mkdir -p $PYSITEDIR - - export COVERAGE_FILE=$PWD/.coverage - # write the usercustomize.py file so all python processes use coverage and know where the config file is - - echo "import os" | tee --append ${PYSITEDIR}/sitecustomize.py - - echo "os.environ['COVERAGE_PROCESS_START'] = '$PWD/.coveragerc'" | tee --append ${PYSITEDIR}/sitecustomize.py - - echo "import coverage" | tee --append ${PYSITEDIR}/sitecustomize.py - - echo "coverage.process_startup()" | tee --append ${PYSITEDIR}/sitecustomize.py + - export COVERAGE_PROCESS_START="$PWD/.coveragerc" + - mkdir -p "$PYSITEDIR" + - echo "$PYSITEDIR" + - touch "${PYSITEDIR}/sitecustomize.py" + - echo "import os" | tee --append "${PYSITEDIR}/sitecustomize.py" + - echo "os.environ['COVERAGE_PROCESS_START'] = '$PWD/.coveragerc'" | tee --append "${PYSITEDIR}/sitecustomize.py" + - echo "import coverage" | tee --append "${PYSITEDIR}/sitecustomize.py" + - echo "coverage.process_startup()" | tee --append "${PYSITEDIR}/sitecustomize.py" + - cat "${PYSITEDIR}/sitecustomize.py" + # write the coverage config file + - echo "[run]" >> "$PWD/.coveragerc" + - echo "source = $PWD/SCons" >> "$PWD/.coveragerc" + - echo "parallel = True" >> "$PWD/.coveragerc" + - printf "omit =\n\t*Tests.py\n\tsrc/test_*\n\tsrc/setup.py\n\n" >> "$PWD/.coveragerc" + - echo "[path]" >> "$PWD/.coveragerc" + - echo "source = $PWD" >> "$PWD/.coveragerc" + - echo "[report]" >> "$PWD/.coveragerc" + - printf "omit =\n\t*Tests.py\n\tsrc/test_*\n\tsrc/setup.py\n\n" >> "$PWD/.coveragerc" + - cat "$PWD/.coveragerc" script: - - export TOTAL_BUILD_JOBS=1 - # write the coverage config file - - export COVERAGE_PROCESS_START=$PWD/.coveragerc - - echo "[run]" >> .coveragerc - - echo "source = $PWD/src" >> .coveragerc - - echo "parallel = True" >> .coveragerc - - printf "omit =\n\t*Tests.py\n\tsrc/test_*\n\tsrc/setup.py\n\n" >> .coveragerc - - echo "[path]" >> .coveragerc - - echo "source = $PWD" >> .coveragerc - - echo "[report]" >> .coveragerc - - printf "omit =\n\t*Tests.py\n\tsrc/test_*\n\tsrc/setup.py\n\n" >> .coveragerc - # get a list of all the tests to split them up - - python runtest.py -l -a > all_tests - - let "start = ($(wc -l < all_tests) / ${TOTAL_BUILD_JOBS}) * (${BUILD_JOB_NUM} - 1)"; true; - - let "end = ($(wc -l < all_tests) / ${TOTAL_BUILD_JOBS}) * ${BUILD_JOB_NUM}" - - if (( ${BUILD_JOB_NUM} == ${TOTAL_BUILD_JOBS} )); then end=$(wc -l < all_tests); fi - - if (( ${start} == 0 )); then start=1; fi - - sed -n ${start},${end}p all_tests > build_tests - - coverage run -p --rcfile=$PWD/.coveragerc runtest.py -f build_tests -j 2 || if [[ $? == 2 ]]; then true; else false; fi + - coverage run -p --rcfile="$PWD/.coveragerc" runtest.py -a -j 2 || if [[ $? == 2 ]]; then true; else false; fi after_script: - coverage combine - coverage report - coverage xml -o coverage_xml.xml - codecov -X gcov --file coverage_xml.xml - # not using coveralls but leaving it commented to - # make it easy to re-enable - #- python$PYTHON -m pip install --user -U coveralls - #- coveralls --rcfile=$PWD/.coveragerc - - env: - - PYVER=37 - - PYTHON=3.7 - - BUILD_JOB_NUM=1 -- cgit v0.12 From 4ccb6e88d4d8b25a43f230b21794168457f332f1 Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Wed, 13 May 2020 22:56:30 -0500 Subject: give coverage a name --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index e0f4340..1a632d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -61,6 +61,7 @@ jobs: - &coverage_jobs dist: bionic python: 3.7 + name: coverage before_script: - python -m pip install -U coverage codecov - python -m site -- cgit v0.12 From 186dea47a09857884c1447379326d304f0ff97cd Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Wed, 13 May 2020 23:12:31 -0500 Subject: clean up coveragerc file --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1a632d1..d2f06be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -80,11 +80,11 @@ jobs: - echo "[run]" >> "$PWD/.coveragerc" - echo "source = $PWD/SCons" >> "$PWD/.coveragerc" - echo "parallel = True" >> "$PWD/.coveragerc" - - printf "omit =\n\t*Tests.py\n\tsrc/test_*\n\tsrc/setup.py\n\n" >> "$PWD/.coveragerc" + - echo "omit = *Tests.py" >> "$PWD/.coveragerc" - echo "[path]" >> "$PWD/.coveragerc" - echo "source = $PWD" >> "$PWD/.coveragerc" - echo "[report]" >> "$PWD/.coveragerc" - - printf "omit =\n\t*Tests.py\n\tsrc/test_*\n\tsrc/setup.py\n\n" >> "$PWD/.coveragerc" + - echo "omit = *Tests.py" >> "$PWD/.coveragerc" - cat "$PWD/.coveragerc" script: -- cgit v0.12 From 9996381c139d5d69c4a66edad8a7560a1d337976 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Thu, 14 May 2020 09:05:58 -0600 Subject: [PR #3651] sider complaints led to packaging init cleanup Signed-off-by: Mats Wichmann --- CHANGES.txt | 2 + SCons/Tool/packaging/__init__.py | 171 ++++++++++++++++++++------------------- 2 files changed, 92 insertions(+), 81 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index f336170..431ecc1 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -142,6 +142,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER has different function. - Update xml files in SCons to reflect changed relative paths after code restructuring (src/engine/SCons -> SCons) + - Drop the with_metaclass jig which was designed to let class + definitions using a metaclass be written the same for Py2/Py3. diff --git a/SCons/Tool/packaging/__init__.py b/SCons/Tool/packaging/__init__.py index 6ac244c..e029bcc 100644 --- a/SCons/Tool/packaging/__init__.py +++ b/SCons/Tool/packaging/__init__.py @@ -1,8 +1,3 @@ -"""SCons.Tool.Packaging - -SCons Packaging Tool. -""" - # # __COPYRIGHT__ # @@ -25,6 +20,11 @@ SCons Packaging Tool. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +"""SCons.Tool.Packaging + +SCons Packaging Tool. +""" + __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import importlib @@ -32,9 +32,10 @@ from inspect import getfullargspec import SCons.Defaults import SCons.Environment -from SCons.Variables import * -from SCons.Errors import * +from SCons.Errors import UserError, SConsEnvironmentError +from SCons.Script import AddOption, GetOption from SCons.Util import is_List, make_path_relative +from SCons.Variables import * from SCons.Warnings import warn, Warning @@ -48,21 +49,22 @@ __all__ = [ # Utility and Builder function # def Tag(env, target, source, *more_tags, **kw_tags): - """ Tag a file with the given arguments, just sets the accordingly named - attribute on the file object. + """ Tag a file with the given arguments. + + Just sets the accordingly named attribute on the file object. TODO: FIXME """ if not target: - target=source - first_tag=None + target = source + first_tag = None else: - first_tag=source + first_tag = source if first_tag: kw_tags[first_tag[0]] = '' - if len(kw_tags) == 0 and len(more_tags) == 0: + if not kw_tags and not more_tags: raise UserError("No tags given.") # XXX: sanity checks @@ -70,55 +72,56 @@ def Tag(env, target, source, *more_tags, **kw_tags): kw_tags[x] = '' if not SCons.Util.is_List(target): - target=[target] + target = [target] else: - # hmm, sometimes the target list, is a list of a list + # hmm, sometimes the target list is a list of a list # make sure it is flattened prior to processing. # TODO: perhaps some bug ?!? - target=env.Flatten(target) + target = env.Flatten(target) for t in target: - for (k,v) in kw_tags.items(): + for k, v in kw_tags.items(): # all file tags have to start with PACKAGING_, so we can later # differentiate between "normal" object attributes and the # packaging attributes. As the user should not be bothered with # that, the prefix will be added here if missing. - if k[:10] != 'PACKAGING_': - k='PACKAGING_'+k + if not k.startswith('PACKAGING_'): + k = 'PACKAGING_' + k t.Tag(k, v) def Package(env, target=None, source=None, **kw): """ Entry point for the package tool. """ - # check if we need to find the source files ourself + # check if we need to find the source files ourselves if not source: source = env.FindInstalledFiles() - if len(source)==0: + if not source: raise UserError("No source for Package() given") # decide which types of packages shall be built. Can be defined through # four mechanisms: command line argument, keyword argument, - # environment argument and default selection( zip or tar.gz ) in that + # environment argument and default selection (zip or tar.gz) in that # order. - try: kw['PACKAGETYPE']=env['PACKAGETYPE'] - except KeyError: pass + try: + kw['PACKAGETYPE'] = env['PACKAGETYPE'] + except KeyError: + pass if not kw.get('PACKAGETYPE'): - from SCons.Script import GetOption kw['PACKAGETYPE'] = GetOption('package_type') if kw['PACKAGETYPE'] is None: if 'Tar' in env['BUILDERS']: - kw['PACKAGETYPE']='targz' + kw['PACKAGETYPE'] = 'targz' elif 'Zip' in env['BUILDERS']: - kw['PACKAGETYPE']='zip' + kw['PACKAGETYPE'] = 'zip' else: raise UserError("No type for Package() given") - PACKAGETYPE=kw['PACKAGETYPE'] - if not is_List(PACKAGETYPE): - PACKAGETYPE=PACKAGETYPE.split(',') + packagetype = kw['PACKAGETYPE'] + if not is_List(packagetype): + packagetype = packagetype.split(',') # load the needed packagers. def load_packager(pkgtype): @@ -126,46 +129,48 @@ def Package(env, target=None, source=None, **kw): # the specific packager is a relative import return importlib.import_module("." + pkgtype, __name__) except ImportError as e: - raise SConsEnvironmentError("packager %s not available: %s" % (pkgtype, str(e))) + raise SConsEnvironmentError("packager %s not available: %s" + % (pkgtype, str(e))) - packagers = list(map(load_packager, PACKAGETYPE)) + packagers = [load_packager(p) for p in packagetype] # set up targets and the PACKAGEROOT try: - # fill up the target list with a default target name until the PACKAGETYPE - # list is of the same size as the target list. - if not target: target = [] + # fill up the target list with a default target name until the + # PACKAGETYPE list is of the same size as the target list. + if not target: + target = [] - size_diff = len(PACKAGETYPE)-len(target) - default_name = "%(NAME)s-%(VERSION)s" + size_diff = len(packagetype) - len(target) + default_name = "%(NAME)s-%(VERSION)s" - if size_diff>0: - default_target = default_name%kw - target.extend( [default_target]*size_diff ) + if size_diff > 0: + default_target = default_name % kw + target.extend([default_target] * size_diff) if 'PACKAGEROOT' not in kw: - kw['PACKAGEROOT'] = default_name%kw + kw['PACKAGEROOT'] = default_name % kw except KeyError as e: - raise SCons.Errors.UserError( "Missing Packagetag '%s'"%e.args[0] ) + raise UserError("Missing Packagetag '%s'" % e.args[0]) # setup the source files - source=env.arg2nodes(source, env.fs.Entry) + source = env.arg2nodes(source, env.fs.Entry) # call the packager to setup the dependencies. - targets=[] + targets = [] try: for packager in packagers: - t=[target.pop(0)] - t=packager.package(env,t,source, **kw) + t = [target.pop(0)] + t = packager.package(env, t, source, **kw) targets.extend(t) - assert( len(target) == 0 ) + assert len(target) == 0 except KeyError as e: - raise SCons.Errors.UserError( "Missing Packagetag '%s' for %s packager"\ - % (e.args[0],packager.__name__) ) - except TypeError as e: + raise UserError("Missing Packagetag '%s' for %s packager" + % (e.args[0], packager.__name__)) + except TypeError: # this exception means that a needed argument for the packager is # missing. As our packagers get their "tags" as named function # arguments we need to find out which one is missing. @@ -180,30 +185,28 @@ def Package(env, target=None, source=None, **kw): # now remove any args for which we have a value in kw. args = [x for x in args if x not in kw] - if len(args)==0: - raise # must be a different error, so re-raise - elif len(args)==1: - raise SCons.Errors.UserError( "Missing Packagetag '%s' for %s packager"\ - % (args[0],packager.__name__) ) - else: - raise SCons.Errors.UserError( "Missing Packagetags '%s' for %s packager"\ - % (", ".join(args),packager.__name__) ) - - target=env.arg2nodes(target, env.fs.Entry) - targets.extend(env.Alias( 'package', targets )) + if not args: + raise # must be a different error, so re-raise + elif len(args) == 1: + raise UserError("Missing Packagetag '%s' for %s packager" + % (args[0], packager.__name__)) + raise UserError("Missing Packagetags '%s' for %s packager" + % (", ".join(args), packager.__name__)) + + target = env.arg2nodes(target, env.fs.Entry) + #XXX: target set above unused... what was the intent? + targets.extend(env.Alias('package', targets)) return targets # # SCons tool initialization functions # - -added = None +added = False def generate(env): - from SCons.Script import AddOption global added if not added: - added = 1 + added = True AddOption('--package-type', dest='package_type', default=None, @@ -224,11 +227,11 @@ def exists(env): # XXX def options(opts): opts.AddVariables( - EnumVariable( 'PACKAGETYPE', + EnumVariable('PACKAGETYPE', 'the type of package to create.', None, allowed_values=list(map( str, __all__ )), ignorecase=2 - ) + ) ) # @@ -238,9 +241,12 @@ def options(opts): def copy_attr(f1, f2): """ copies the special packaging file attributes from f1 to f2. """ - copyit = lambda x: not hasattr(f2, x) and x[:10] == 'PACKAGING_' if f1._tags: - pattrs = [tag for tag in f1._tags if copyit(tag)] + pattrs = [ + tag + for tag in f1._tags + if lambda tag: not hasattr(f2, tag) and tag.startswith('PACKAGING_') + ] for attr in pattrs: f2.Tag(attr, f1.GetTag(attr)) @@ -258,28 +264,32 @@ def putintopackageroot(target, source, env, pkgroot, honor_install_location=1): All attributes of the source file will be copied to the new file. """ # make sure the packageroot is a Dir object. - if SCons.Util.is_String(pkgroot): pkgroot=env.Dir(pkgroot) - if not SCons.Util.is_List(source): source=[source] + if SCons.Util.is_String(pkgroot): + pkgroot = env.Dir(pkgroot) + if not SCons.Util.is_List(source): + source = [source] new_source = [] for file in source: - if SCons.Util.is_String(file): file = env.File(file) + if SCons.Util.is_String(file): + file = env.File(file) if file.is_under(pkgroot): new_source.append(file) else: - if file.GetTag('PACKAGING_INSTALL_LOCATION') and\ + if file.GetTag('PACKAGING_INSTALL_LOCATION') and \ honor_install_location: - new_name=make_path_relative(file.GetTag('PACKAGING_INSTALL_LOCATION')) + new_name = make_path_relative(file.GetTag('PACKAGING_INSTALL_LOCATION')) else: - new_name=make_path_relative(file.get_path()) + new_name = make_path_relative(file.get_path()) - new_file=pkgroot.File(new_name) - new_file=env.CopyAs(new_file, file)[0] + new_file = pkgroot.File(new_name) + new_file = env.CopyAs(new_file, file)[0] copy_attr(file, new_file) new_source.append(new_file) - return (target, new_source) + return target, new_source + def stripinstallbuilder(target, source, env): """ Strips the install builder action from the source list and stores @@ -293,12 +303,11 @@ def stripinstallbuilder(target, source, env): return not (file.has_builder() and hasattr(file.builder, 'name') and file.builder.name in ["InstallBuilder", "InstallAsBuilder"]) - if len([src for src in source if has_no_install_location(src)]): warn(Warning, "there are files to package which have no\ InstallBuilder attached, this might lead to irreproducible packages") - n_source=[] + n_source = [] for s in source: if has_no_install_location(s): n_source.append(s) @@ -308,7 +317,7 @@ def stripinstallbuilder(target, source, env): copy_attr(s, ss) ss.Tag('PACKAGING_INSTALL_LOCATION', s.get_path()) - return (target, n_source) + return target, n_source # Local Variables: # tab-width:4 -- cgit v0.12 From d23ad6d7d3403fb36fbca8eb781dea12a995b715 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Sat, 16 May 2020 12:08:49 -0600 Subject: Bump unsupported/deperecated Py versions Signed-off-by: Mats Wichmann --- CHANGES.txt | 2 ++ SCons/Script/Main.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 431ecc1..fbcc2e8 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -144,6 +144,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER code restructuring (src/engine/SCons -> SCons) - Drop the with_metaclass jig which was designed to let class definitions using a metaclass be written the same for Py2/Py3. + - Bump python_version_unsupported (and deprecated) to indicate 3.5 + is lowest supported Python. diff --git a/SCons/Script/Main.py b/SCons/Script/Main.py index 62cd908..4673d6d 100644 --- a/SCons/Script/Main.py +++ b/SCons/Script/Main.py @@ -10,8 +10,8 @@ some other module. If it's specific to the "scons" script invocation, it goes here. """ -unsupported_python_version = (2, 6, 0) -deprecated_python_version = (2, 7, 0) +unsupported_python_version = (3, 4, 0) +deprecated_python_version = (3, 4, 0) # __COPYRIGHT__ -- cgit v0.12