def finish(defaultTargets=DEFAULT_TARGETS, subDirList=None, ignoreRegex=None): if ignoreRegex is None: ignoreRegex = r"(~$|\.pyc$|^\.svn$|\.o|\.os$)" if subDirList is None: subDirList = [] for path in os.listdir("."): if os.path.isdir(path) and not path.startswith("."): subDirList.append(path) install = state.env.InstallLSST(state.env["prefix"], [subDir for subDir in subDirList], ignoreRegex=ignoreRegex) for name, target in state.targets.items(): state.env.Requires(install, target) state.env.Alias(name, target) state.env.Requires(state.targets["python"], state.targets["version"]) declarer = state.env.Declare() state.env.Requires(declarer, install) # Ensure declaration fires after installation available # shebang should be in the list if bin.src exists but the location matters # so we can not append it afterwards. state.env.Default([t for t in defaultTargets if os.path.exists(t) or (t == "shebang" and os.path.exists("bin.src"))]) if "version" in state.targets: state.env.Default(state.targets["version"]) state.env.Requires(state.targets["tests"], state.targets["version"]) state.env.Decider("MD5-timestamp") # if timestamps haven't changed, don't do MD5 checks # # Check if any of the tests failed by looking for *.failed files. # Perform this test just before scons exits # # N.b. the test is written in sh not python as then we can use @ to suppress output # if "tests" in [str(t) for t in BUILD_TARGETS]: testsDir = pipes.quote(os.path.join(os.getcwd(), "tests", ".tests")) checkTestStatus_command = state.env.Command('checkTestStatus', [], """ @ if [ -d {0} ]; then \ nfail=`find {0} -name "*.failed" | wc -l | sed -e 's/ //g'`; \ if [ $$nfail -gt 0 ]; then \ echo "Failed test output:" >&2; \ for f in `find {0} -name "*.failed"`; do \ case "$$f" in \ *.xml.failed) \ echo "Global pytest output is in $$f" >&2; \ ;; \ *.failed) \ cat $$f >&2; \ ;; \ esac; \ done; \ echo "The following tests failed:" >&2;\ find {0} -name "*.failed" >&2; \ echo "$$nfail tests failed" >&2; exit 1; \ fi; \ fi; \ """.format(testsDir)) state.env.Depends(checkTestStatus_command, BUILD_TARGETS) # this is why the check runs last BUILD_TARGETS.extend(checkTestStatus_command) state.env.AlwaysBuild(checkTestStatus_command)
def finish(defaultTargets=DEFAULT_TARGETS, subDirList=None, ignoreRegex=None): """Convenience function to replace standard SConstruct boilerplate (step 2). This function: - Sets up installation paths. - Tells SCons to only do MD5 checks when timestamps have changed. - Sets the "include", "lib", "python", and "tests" targets as the defaults to be built when scons is run with no target arguments. Parameters ---------- subDirList : `list` An explicit list of subdirectories that should be installed. By default, all non-hidden subdirectories will be installed. defaultTargets : `list` A sequence of targets (see `lsst.sconsUtils.state.targets`) that should be built when scons is run with no arguments. ignoreRegex : `str` Regular expression that matches files that should not be installed. Returns ------- env : `lsst.sconsUtils.env` A SCons Environment. """ if ignoreRegex is None: ignoreRegex = r"(~$|\.pyc$|^\.svn$|\.o|\.os$)" if subDirList is None: subDirList = [] for path in os.listdir("."): if os.path.isdir(path) and not path.startswith("."): subDirList.append(path) install = state.env.InstallLSST(state.env["prefix"], [subDir for subDir in subDirList], ignoreRegex=ignoreRegex) for name, target in state.targets.items(): state.env.Requires(install, target) state.env.Alias(name, target) state.env.Requires(state.targets["python"], state.targets["version"]) declarer = state.env.Declare() state.env.Requires(declarer, install) # Ensure declaration fires after installation available # shebang should be in the list if bin.src exists but the location # matters so we can not append it afterwards. state.env.Default([t for t in defaultTargets if os.path.exists(t) or (t == "shebang" and os.path.exists("bin.src"))]) if "version" in state.targets: state.env.Default(state.targets["version"]) state.env.Requires(state.targets["tests"], state.targets["version"]) state.env.Decider("MD5-timestamp") # if timestamps haven't changed, don't do MD5 checks # # Check if any of the tests failed by looking for *.failed files. # Perform this test just before scons exits # # N.b. the test is written in sh not python as then we can use @ to # suppress output # if "tests" in [str(t) for t in BUILD_TARGETS]: testsDir = pipes.quote(os.path.join(os.getcwd(), "tests", ".tests")) checkTestStatus_command = state.env.Command('checkTestStatus', [], """ @ if [ -d {0} ]; then \ nfail=`find {0} -name "*.failed" | wc -l | sed -e 's/ //g'`; \ if [ $$nfail -gt 0 ]; then \ echo "Failed test output:" >&2; \ for f in `find {0} -name "*.failed"`; do \ case "$$f" in \ *.xml.failed) \ echo "Global pytest output is in $$f" >&2; \ ;; \ *.failed) \ cat $$f >&2; \ ;; \ esac; \ done; \ echo "The following tests failed:" >&2;\ find {0} -name "*.failed" >&2; \ echo "$$nfail tests failed" >&2; exit 1; \ fi; \ fi; \ """.format(testsDir)) state.env.Depends(checkTestStatus_command, BUILD_TARGETS) # this is why the check runs last BUILD_TARGETS.extend(checkTestStatus_command) state.env.AlwaysBuild(checkTestStatus_command)
def finish(defaultTargets=DEFAULT_TARGETS, subDirList=None, ignoreRegex=None): """Convenience function to replace standard SConstruct boilerplate (step 2). This function: - Sets up installation paths. - Tells SCons to only do MD5 checks when timestamps have changed. - Sets the "include", "lib", "python", and "tests" targets as the defaults to be built when scons is run with no target arguments. Parameters ---------- subDirList : `list` An explicit list of subdirectories that should be installed. By default, all non-hidden subdirectories will be installed. defaultTargets : `list` A sequence of targets (see `lsst.sconsUtils.state.targets`) that should be built when scons is run with no arguments. ignoreRegex : `str` Regular expression that matches files that should not be installed. Returns ------- env : `lsst.sconsUtils.env` A SCons Environment. """ if ignoreRegex is None: ignoreRegex = r"(~$|\.pyc$|^\.svn$|\.o|\.os$)" if subDirList is None: subDirList = [] for path in os.listdir("."): if os.path.isdir(path) and not path.startswith("."): subDirList.append(path) if "bin.src" in subDirList and "shebang" in state.targets and state.targets[ "shebang"]: # shebang makes a directory that should be installed subDirList += ["bin"] install = state.env.InstallLSST(state.env["prefix"], [subDir for subDir in subDirList], ignoreRegex=ignoreRegex) for name, target in state.targets.items(): state.env.Requires(install, target) state.env.Alias(name, target) state.env.Requires(state.targets["python"], state.targets["version"]) declarer = state.env.Declare() state.env.Requires( declarer, install) # Ensure declaration fires after installation available # shebang should be in the list if bin.src exists but the location # matters so we can not append it afterwards. state.env.Default([ t for t in defaultTargets if os.path.exists(t) or ( t == "shebang" and os.path.exists("bin.src")) ]) if "version" in state.targets: state.env.Default(state.targets["version"]) state.env.Requires(state.targets["tests"], state.targets["version"]) state.env.Decider( "MD5-timestamp" ) # if timestamps haven't changed, don't do MD5 checks # # Check if any of the tests failed by looking for *.failed files. # Perform this test just before scons exits # # N.b. the test is written in sh not python as then we can use @ to # suppress output # if "tests" in [str(t) for t in BUILD_TARGETS]: testsDir = pipes.quote(os.path.join(os.getcwd(), "tests", ".tests")) checkTestStatus_command = state.env.Command( 'checkTestStatus', [], """ @ if [ -d {0} ]; then \ nfail=`find {0} -name "*.failed" | wc -l | sed -e 's/ //g'`; \ if [ $$nfail -gt 0 ]; then \ echo "Failed test output:" >&2; \ for f in `find {0} -name "*.failed"`; do \ case "$$f" in \ *.xml.failed) \ echo "Global pytest output is in $$f" >&2; \ ;; \ *.failed) \ cat $$f >&2; \ ;; \ esac; \ done; \ echo "The following tests failed:" >&2;\ find {0} -name "*.failed" >&2; \ echo "$$nfail tests failed" >&2; exit 1; \ fi; \ fi; \ """.format(testsDir)) state.env.Depends(checkTestStatus_command, BUILD_TARGETS) # this is why the check runs last BUILD_TARGETS.extend(checkTestStatus_command) state.env.AlwaysBuild(checkTestStatus_command)