LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Member Functions | Static Public Member Functions | Static Private Attributes | List of all members
lsst.sconsUtils.scripts.BasicSConstruct Class Reference

A scope-only class for SConstruct-replacement convenience functions. More...

Inheritance diagram for lsst.sconsUtils.scripts.BasicSConstruct:

Public Member Functions

def __new__
 Convenience function to replace standard SConstruct boilerplate. More...
 
def initialize
 Convenience function to replace standard SConstruct boilerplate (step 1). More...
 

Static Public Member Functions

def finish
 Convenience function to replace standard SConstruct boilerplate (step 2). More...
 

Static Private Attributes

 _initializing = False
 

Detailed Description

A scope-only class for SConstruct-replacement convenience functions.

The boilerplate for a standard LSST SConstruct file is replaced by two static methods: initialize() and finish(). The former configures dependencies, sets up package-dependent environment variables, and calls any SConscript files found in subdirectories, while the latter sets up installation paths, default targets, and explicit dependencies.

Calling BasicSConstruct as a function invokes its new method, which calls both initialize() and finish(), and should be used when the SConstruct file doesn't need to do anything other than what they provide.

Definition at line 36 of file scripts.py.

Member Function Documentation

def lsst.sconsUtils.scripts.BasicSConstruct.__new__ (   cls,
  packageName,
  versionString = None,
  eupsProduct = None,
  eupsProductPath = None,
  cleanExt = None,
  defaultTargets = ("lib", "python",
  tests,
  examples,
  doc,
  subDirList = None,
  ignoreRegex = None,
  versionModuleName = "python/lsst/%s/version.py",
  noCfgFile = False 
)

Convenience function to replace standard SConstruct boilerplate.

This is a shortcut for

1 BasicSConstruct.initialize(...)
2 BasicSConstruct.finalize(...)

This returns the sconsUtils.env Environment object rather than a BasicSConstruct instance (which would be useless).

Definition at line 55 of file scripts.py.

55 
56  versionModuleName="python/lsst/%s/version.py", noCfgFile=False):
57  cls.initialize(packageName, versionString, eupsProduct, eupsProductPath, cleanExt,
58  versionModuleName, noCfgFile=noCfgFile)
59  cls.finish(defaultTargets, subDirList, ignoreRegex)
60  return state.env
def lsst.sconsUtils.scripts.BasicSConstruct.finish (   defaultTargets = ("lib", "python",
  tests,
  examples,
  doc,
  subDirList = None,
  ignoreRegex = None 
)
static

Convenience function to replace standard SConstruct boilerplate (step 2).

This function:

Parameters
subDirListAn explicit list of subdirectories that should be installed. By default, all non-hidden subdirectories will be installed.
defaultTargetsA sequence of targets (see state.targets) that should be built when scons is run with no arguments.
ignoreRegexRegular expression that matches files that should not be installed.
Returns
an SCons Environment object (which is also available as lsst.sconsUtils.env).

Definition at line 130 of file scripts.py.

131  subDirList=None, ignoreRegex=None):
132  if ignoreRegex is None:
133  ignoreRegex = r"(~$|\.pyc$|^\.svn$|\.o|\.os$)"
134  if subDirList is None:
135  subDirList = []
136  for path in os.listdir("."):
137  if os.path.isdir(path) and not path.startswith("."):
138  subDirList.append(path)
139  install = state.env.InstallLSST(state.env["prefix"],
140  [subDir for subDir in subDirList],
141  ignoreRegex=ignoreRegex)
142  for name, target in state.targets.items():
143  state.env.Requires(install, target)
144  state.env.Alias(name, target)
145  state.env.Requires(state.targets["python"], state.targets["version"])
146  declarer = state.env.Declare()
147  state.env.Requires(declarer, install) # Ensure declaration fires after installation available
148  state.env.Default([t for t in defaultTargets if os.path.exists(t)])
149  if "version" in state.targets:
150  state.env.Default(state.targets["version"])
151  state.env.Requires(state.targets["tests"], state.targets["version"])
152  state.env.Decider("MD5-timestamp") # if timestamps haven't changed, don't do MD5 checks
153  #
154  # Check if any of the tests failed by looking for *.failed files.
155  # Perform this test just before scons exits
156  #
157  # N.b. the test is written in sh not python as then we can use @ to suppress output
158  #
159  if "tests" in [str(t) for t in BUILD_TARGETS]:
160  testsDir = os.path.join(os.getcwd(), "tests", ".tests")
161  checkTestStatus_command = state.env.Command('checkTestStatus', [], """
162  @ if [ -d %s ]; then \
163  nfail=`find %s -name \*.failed | wc -l | sed -e 's/ //g'`; \
164  if [ $$nfail -gt 0 ]; then \
165  echo "$$nfail tests failed" >&2; exit 1; \
166  fi; \
167  fi; \
168  """ % (testsDir, testsDir))
169 
170  state.env.Depends(checkTestStatus_command, BUILD_TARGETS) # this is why the check runs last
171  BUILD_TARGETS.extend(checkTestStatus_command)
172  state.env.AlwaysBuild(checkTestStatus_command)
def lsst.sconsUtils.scripts.BasicSConstruct.initialize (   cls,
  packageName,
  versionString = None,
  eupsProduct = None,
  eupsProductPath = None,
  cleanExt = None,
  versionModuleName = "python/lsst/%s/version.py",
  noCfgFile = False 
)

Convenience function to replace standard SConstruct boilerplate (step 1).

This function:

Parameters
packageNameName of the package being built; must correspond to a .cfg file in ups/.
versionStringVersion-control system string to be parsed for version information ($HeadURL$ for SVN). Defaults to "git" if not set or None.
eupsProductName of the EUPS product being built. Defaults to and is almost always the name of the package.
eupsProductPathAn alternate directory where the package should be installed.
cleanExtWhitespace delimited sequence of globs for files to remove with –clean.
versionModuleNameIf non-None, builds a version.py module as this file; 's' is replaced with the name of the package.
noCfgFileIf True, this package has no .cfg file
Returns
an SCons Environment object (which is also available as lsst.sconsUtils.env).

Definition at line 84 of file scripts.py.

84 
85  cleanExt=None, versionModuleName="python/lsst/%s/version.py", noCfgFile=False):
86  if cls._initializing:
87  state.log.fail("Recursion detected; an SConscript file should not call BasicSConstruct.")
88  cls._initializing = True
89  if cleanExt is None:
90  cleanExt = r"*~ core *.so *.os *.o *.pyc *.pkgc"
91  dependencies.configure(packageName, versionString, eupsProduct, eupsProductPath, noCfgFile)
92  state.env.BuildETags()
93  state.env.CleanTree(cleanExt)
94  if versionModuleName is not None:
95  try:
96  versionModuleName = versionModuleName % "/".join(packageName.split("_"))
97  except TypeError:
98  pass
99  state.targets["version"] = state.env.VersionModule(versionModuleName)
100  for root, dirs, files in os.walk("."):
101  if "SConstruct" in files and root != ".":
102  dirs[:] = []
103  continue
104  dirs[:] = [d for d in dirs if (not d.startswith('.'))]
105  dirs.sort() # happy coincidence that include < libs < python < tests
106  if "SConscript" in files:
107  state.log.info("Using Sconscript at %s/SConscript" % root)
108  SCons.Script.SConscript(os.path.join(root, "SConscript"))
109  cls._initializing = False
110  return state.env

Member Data Documentation

lsst.sconsUtils.scripts.BasicSConstruct._initializing = False
staticprivate

Definition at line 38 of file scripts.py.


The documentation for this class was generated from the following file: