LSSTApplications  1.1.2+25,10.0+13,10.0+132,10.0+133,10.0+224,10.0+41,10.0+8,10.0-1-g0f53050+14,10.0-1-g4b7b172+19,10.0-1-g61a5bae+98,10.0-1-g7408a83+3,10.0-1-gc1e0f5a+19,10.0-1-gdb4482e+14,10.0-11-g3947115+2,10.0-12-g8719d8b+2,10.0-15-ga3f480f+1,10.0-2-g4f67435,10.0-2-gcb4bc6c+26,10.0-28-gf7f57a9+1,10.0-3-g1bbe32c+14,10.0-3-g5b46d21,10.0-4-g027f45f+5,10.0-4-g86f66b5+2,10.0-4-gc4fccf3+24,10.0-40-g4349866+2,10.0-5-g766159b,10.0-5-gca2295e+25,10.0-6-g462a451+1
LSSTDataManagementBasePackage
Classes | Functions
lsst.sconsUtils.installation Namespace Reference

Classes

class  DirectoryInstaller
 SCons Action callable to recursively install a directory. More...
 

Functions

def makeProductPath
 return a path to use as the installation directory for a product More...
 
def determineVersion
 Set a version ID from env, or a version control ID string ($name$ or $HeadURL$) More...
 
def getFingerprint
 Return a unique fingerprint for a version (e.g. More...
 
def setPrefix
 Set a prefix based on the EUPS_PATH, the product name, and a versionString from cvs or svn. More...
 
def Declare
 Create current and declare targets for products. More...
 
def InstallDir
 Install the directory dir into prefix, (along with all its descendents if recursive is True). More...
 
def InstallEups
 Install a ups directory, setting absolute versions as appropriate (unless you're installing from the trunk, in which case no versions are expanded). More...
 
def InstallLSST
 Install directories in the usual LSST way, handling "ups" specially. More...
 

Function Documentation

def lsst.sconsUtils.installation.Declare (   self,
  products = None 
)

Create current and declare targets for products.

products may be a list of (product, version) tuples. If product is None it's taken to be self['eupsProduct']; if version is None it's taken to be self['version'].

Definition at line 129 of file installation.py.

130 def Declare(self, products=None):
131 
132  if "undeclare" in SCons.Script.COMMAND_LINE_TARGETS and not self.GetOption("silent"):
133  state.log.warn("'scons undeclare' is deprecated; please use 'scons declare -c' instead")
134 
135  acts = []
136  if \
137  "declare" in SCons.Script.COMMAND_LINE_TARGETS or \
138  "undeclare" in SCons.Script.COMMAND_LINE_TARGETS or \
139  ("install" in SCons.Script.COMMAND_LINE_TARGETS and self.GetOption("clean")) or \
140  "current" in SCons.Script.COMMAND_LINE_TARGETS:
141  current = []; declare = []; undeclare = []
142 
143  if not products:
144  products = [None]
145 
146  for prod in products:
147  if not prod or isinstance(prod, str): # i.e. no version
148  product = prod
149 
150  if self.has_key('version'):
151  version = self['version']
152  else:
153  version = None
154  else:
155  product, version = prod
156 
157  if not product:
158  product = self['eupsProduct']
159 
160  if "EUPS_DIR" in os.environ.keys():
161  self['ENV']['PATH'] += os.pathsep + "%s/bin" % (os.environ["EUPS_DIR"])
162  self["ENV"]["EUPS_LOCK_PID"] = os.environ.get("EUPS_LOCK_PID", "-1")
163  if "undeclare" in SCons.Script.COMMAND_LINE_TARGETS or self.GetOption("clean"):
164  if version:
165  command = "eups undeclare --flavor %s %s %s" % \
166  (self['eupsFlavor'], product, version)
167  if ("current" in SCons.Script.COMMAND_LINE_TARGETS
168  and not "declare" in SCons.Script.COMMAND_LINE_TARGETS):
169  command += " --current"
170 
171  if self.GetOption("clean"):
172  self.Execute(command)
173  else:
174  undeclare += [command]
175  else:
176  state.log.warn("I don't know your version; not undeclaring to eups")
177  else:
178  command = "eups declare --force --flavor %s --root %s" % \
179  (self['eupsFlavor'], self['prefix'])
180 
181  if self.has_key('eupsPath'):
182  command += " -Z %s" % self['eupsPath']
183 
184  if version:
185  command += " %s %s" % (product, version)
186 
187  current += [command + " --current"]
188 
189  if self.GetOption("tag"):
190  command += " --tag=%s" % self.GetOption("tag")
191 
192  declare += [command]
193 
194  if current:
195  acts += self.Command("current", "", action=current)
196  if declare:
197  if "current" in SCons.Script.COMMAND_LINE_TARGETS:
198  acts += self.Command("declare", "", action="") # current will declare it for us
199  else:
200  acts += self.Command("declare", "", action=declare)
201  if undeclare:
202  acts += self.Command("undeclare", "", action=undeclare)
203 
204  return acts
205 
206 #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
def Declare
Create current and declare targets for products.
def lsst.sconsUtils.installation.determineVersion (   env,
  versionString 
)

Set a version ID from env, or a version control ID string ($name$ or $HeadURL$)

Definition at line 46 of file installation.py.

46 
47 def determineVersion(env, versionString):
48  version = "unknown"
49  if env.has_key('version'):
50  version = env['version']
51  elif not versionString:
52  version = "unknown"
53  elif re.search(r"^[$]Name:\s+", versionString):
54  # CVS. Extract the tagname
55  version = re.search(r"^[$]Name:\s+([^ $]*)", versionString).group(1)
56  if version == "":
57  version = "cvs"
58  elif re.search(r"^[$]HeadURL:\s+", versionString):
59  # SVN. Guess the tagname from the last part of the directory
60  HeadURL = re.search(r"^[$]HeadURL:\s+(.*)", versionString).group(1)
61  HeadURL = os.path.split(HeadURL)[0]
62  version = svn.guessVersionName(HeadURL)
63  elif versionString.lower() in ("hg", "mercurial"):
64  # Mercurial (hg).
65  version = hg.guessVersionName()
66  elif versionString.lower() in ("git",):
67  # git.
68  version = git.guessVersionName()
69  return version.replace("/", "_")
70 
71 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
def determineVersion
Set a version ID from env, or a version control ID string ($name$ or $HeadURL$)
Definition: installation.py:46
def lsst.sconsUtils.installation.getFingerprint (   versionString)

Return a unique fingerprint for a version (e.g.

an SHA1); return None if unavailable

Definition at line 73 of file installation.py.

73 
74 def getFingerprint(versionString):
75  if versionString.lower() in ("hg", "mercurial"):
76  fingerprint, modified = hg.guessFingerprint()
77  elif versionString.lower() in ("git",):
78  fingerprint, modified = git.guessFingerprint()
79  else:
80  fingerprint, modified = None, False
81 
82  if fingerprint and modified:
83  fingerprint += " *"
84 
85  return fingerprint
def getFingerprint
Return a unique fingerprint for a version (e.g.
Definition: installation.py:73
def lsst.sconsUtils.installation.InstallDir (   self,
  prefix,
  dir,
  ignoreRegex = r"(~$|\.pyc$|\.os?$)",
  recursive = True 
)

Install the directory dir into prefix, (along with all its descendents if recursive is True).

Omit files and directories that match ignoreRegex

Definition at line 253 of file installation.py.

254 def InstallDir(self, prefix, dir, ignoreRegex=r"(~$|\.pyc$|\.os?$)", recursive=True):
255  if not self.installing:
256  return []
257  result = self.Command(target=os.path.join(self.Dir(prefix).abspath, dir), source=dir,
258  action=DirectoryInstaller(ignoreRegex, recursive))
259  self.AlwaysBuild(result)
260  return result
261 
262 #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
SCons Action callable to recursively install a directory.
def InstallDir
Install the directory dir into prefix, (along with all its descendents if recursive is True)...
def lsst.sconsUtils.installation.InstallEups (   env,
  dest,
  files = [],
  presetup = "" 
)

Install a ups directory, setting absolute versions as appropriate (unless you're installing from the trunk, in which case no versions are expanded).

Any build/table files present in "./ups" are automatically added to files.

If presetup is provided, it's expected to be a dictionary with keys product names and values the version that should be installed into the table files, overriding eups expandtable's usual behaviour. E.g. env.InstallEups(os.path.join(env['prefix'], "ups"), presetup={"sconsUtils" : env['version']})

Definition at line 275 of file installation.py.

276 def InstallEups(env, dest, files=[], presetup=""):
277 
278  acts = []
279  if not env.installing:
280  return acts
281 
282  if env.GetOption("clean"):
283  print >> sys.stderr, "Removing", dest
284  shutil.rmtree(dest, ignore_errors=True)
285  else:
286  presetupStr = []
287  for p in presetup:
288  presetupStr += ["--product %s=%s" % (p, presetup[p])]
289  presetup = " ".join(presetupStr)
290 
291  env = env.Clone(ENV = os.environ)
292  #
293  # Add any build/table/cfg files to the desired files
294  #
295  files = [str(f) for f in files] # in case the user used Glob not glob.glob
296  files += glob.glob(os.path.join("ups", "*.build")) + glob.glob(os.path.join("ups","*.table")) \
297  + glob.glob(os.path.join("ups", "*.cfg")) \
298  + glob.glob(os.path.join("ups", "eupspkg*"))
299  files = list(set(files)) # remove duplicates
300 
301  buildFiles = filter(lambda f: re.search(r"\.build$", f), files)
302  build_obj = env.Install(dest, buildFiles)
303  acts += build_obj
304 
305  tableFiles = filter(lambda f: re.search(r"\.table$", f), files)
306  table_obj = env.Install(dest, tableFiles)
307  acts += table_obj
308 
309  eupspkgFiles = filter(lambda f: re.search(r"^eupspkg", f), files)
310  eupspkg_obj = env.Install(dest, eupspkgFiles)
311  acts += eupspkg_obj
312 
313  miscFiles = filter(lambda f: not re.search(r"\.(build|table)$", f), files)
314  misc_obj = env.Install(dest, miscFiles)
315  acts += misc_obj
316 
317  try:
318  import eups.lock
319 
320  path = eups.Eups.setEupsPath()
321  if path:
322  locks = eups.lock.takeLocks("setup", path, eups.lock.LOCK_SH)
323  env["ENV"]["EUPS_LOCK_PID"] = os.environ.get("EUPS_LOCK_PID", "-1")
324  except ImportError:
325  state.log.warn("Unable to import eups; not locking")
326 
327  eupsTargets = []
328 
329  for i in build_obj:
330  env.AlwaysBuild(i)
331 
332  cmd = "eups expandbuild -i --version %s " % env['version']
333  if env.has_key('baseversion'):
334  cmd += " --repoversion %s " % env['baseversion']
335  cmd += str(i)
336  eupsTargets.extend(env.AddPostAction(build_obj, env.Action("%s" %(cmd), cmd)))
337 
338  for i in table_obj:
339  env.AlwaysBuild(i)
340 
341  cmd = "eups expandtable -i -W '^(?!LOCAL:)' " # version doesn't start "LOCAL:"
342  if presetup:
343  cmd += presetup + " "
344  cmd += str(i)
345 
346  act = env.Command("table", "", env.Action("%s" %(cmd), cmd))
347  eupsTargets.extend(act)
348  acts += act
349  env.Depends(act, i)
350 
351  # By declaring that all the Eups operations create a file called "eups" as a side-effect,
352  # even though they don't, SCons knows it can't run them in parallel (it thinks of the
353  # side-effect file as something like a log, and knows you shouldn't be appending to it
354  # in parallel). When Eups locking is working, we may be able to remove this.
355  env.SideEffect("eups", eupsTargets)
356 
357  return acts
358 
359 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
def InstallEups
Install a ups directory, setting absolute versions as appropriate (unless you're installing from the ...
def lsst.sconsUtils.installation.InstallLSST (   self,
  prefix,
  dirs,
  ignoreRegex = None 
)

Install directories in the usual LSST way, handling "ups" specially.

Definition at line 362 of file installation.py.

363 def InstallLSST(self, prefix, dirs, ignoreRegex=None):
364  results = []
365  for d in dirs:
366  if d == "ups":
367  t = self.InstallEups(os.path.join(prefix, "ups"))
368  else:
369  t = self.InstallDir(prefix, d, ignoreRegex=ignoreRegex)
370  self.Depends(t, d)
371  results.extend(t)
372  self.Alias("install", t)
373  self.Clean("install", prefix)
374  return results
def InstallLSST
Install directories in the usual LSST way, handling "ups" specially.
def lsst.sconsUtils.installation.makeProductPath (   env,
  pathFormat 
)

return a path to use as the installation directory for a product

Parameters
pathFormatthe format string to process
envthe scons environment
versionStringthe versionString passed to MakeEnv

Definition at line 30 of file installation.py.

30 
31 def makeProductPath(env, pathFormat):
32  pathFormat = re.sub(r"%(\w)", r"%(\1)s", pathFormat)
33 
34  eupsPath = os.environ['PWD']
35  if env.has_key('eupsProduct') and env['eupsPath']:
36  eupsPath = env['eupsPath']
37 
38  return pathFormat % { "P": eupsPath,
39  "f": env['eupsFlavor'],
40  "p": env['eupsProduct'],
41  "v": env['version'],
42  "c": os.environ['PWD'] }
43 
44 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
def makeProductPath
return a path to use as the installation directory for a product
Definition: installation.py:30
def lsst.sconsUtils.installation.setPrefix (   env,
  versionString,
  eupsProductPath = None 
)

Set a prefix based on the EUPS_PATH, the product name, and a versionString from cvs or svn.

Definition at line 87 of file installation.py.

87 
88 def setPrefix(env, versionString, eupsProductPath=None):
89  try:
90  env['version'] = determineVersion(env, versionString)
91  except RuntimeError as err:
92  env['version'] = "unknown"
93  if env.installing or env.declaring and not env['force']:
94  state.log.fail(
95  "%s\nFound problem with version number; update or specify force=True to proceed"
96  % err
97  )
98  if eupsProductPath:
99  eupsPrefix = makeProductPath(env, eupsProductPath)
100  elif env.has_key('eupsPath') and env['eupsPath']:
101  eupsPrefix = env['eupsPath']
102  flavor = env['eupsFlavor']
103  if not re.search("/" + flavor + "$", eupsPrefix):
104  eupsPrefix = os.path.join(eupsPrefix, flavor)
105  prodPath = env['eupsProduct']
106  if env.has_key('eupsProductPath') and env['eupsProductPath']:
107  prodPath = env['eupsProductPath']
108  eupsPrefix = os.path.join(eupsPrefix, prodPath, env["version"])
109  else:
110  eupsPrefix = None
111  if env.has_key('prefix'):
112  if env['version'] != "unknown" and eupsPrefix and eupsPrefix != env['prefix']:
113  print >> sys.stderr, "Ignoring prefix %s from EUPS_PATH" % eupsPrefix
114  return makeProductPath(env, env['prefix'])
115  elif env.has_key('eupsPath') and env['eupsPath']:
116  prefix = eupsPrefix
117  else:
118  prefix = "/usr/local"
119  return prefix
120 
121 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
def makeProductPath
return a path to use as the installation directory for a product
Definition: installation.py:30
def determineVersion
Set a version ID from env, or a version control ID string ($name$ or $HeadURL$)
Definition: installation.py:46
def setPrefix
Set a prefix based on the EUPS_PATH, the product name, and a versionString from cvs or svn...
Definition: installation.py:87