[cig-commits] r7556 - cs/buildbot/trunk/buildbot

leif at geodynamics.org leif at geodynamics.org
Thu Jun 28 17:35:47 PDT 2007


Author: leif
Date: 2007-06-28 17:35:47 -0700 (Thu, 28 Jun 2007)
New Revision: 7556

Modified:
   cs/buildbot/trunk/buildbot/config.py
   cs/buildbot/trunk/buildbot/lines.py
Log:
Added PETSc's 'bin' directory to PATH, so that DLLs can be found on
Windows.  Added class 'Environment' in order to make the necessary
"environment composition" possible.


Modified: cs/buildbot/trunk/buildbot/config.py
===================================================================
--- cs/buildbot/trunk/buildbot/config.py	2007-06-28 22:21:00 UTC (rev 7555)
+++ cs/buildbot/trunk/buildbot/config.py	2007-06-29 00:35:47 UTC (rev 7556)
@@ -1,5 +1,32 @@
 
 
+import os
+
+
+class Environment(dict):
+    
+    def update(self, other):
+
+        # Concatenate things like PATH, PYTHONPATH, ...
+        paths = {}
+        for var in self.keys():
+            if var.find('PATH') != -1 and other.has_key(var):
+                path = self[var]
+                opath = other[var]
+                if isinstance(path, basestring):
+                    path = filter(None, path.split(os.pathsep))
+                if isinstance(opath, basestring):
+                    opath = filter(None, opath.split(os.pathsep))
+                # The slave automatically converts sequences back into
+                # strings.
+                paths[var] = opath + path
+                
+        dict.update(self, other)
+        dict.update(self, paths)
+        
+        return
+
+
 class BuildConfig(object):
 
     def __init__(self, name, env, tag=None, slaves=None, configureArgs=None, basedir=None,
@@ -97,19 +124,15 @@
 
     def getEnv(self, config):
         prefix = config.basedir + "/install/" + self.configFilename(config)
-        env = {
+        env = Environment({
             "HOME": "%(HOME)s", # expanded by the slave
             "WORKDIR": "%(WORKDIR)s", # expanded by the slave
             "PREFIX": prefix,
-            }
+            })
         env.update(config.env)
-        bin = lambda p: p + "/bin"
-        sp = lambda p: p + "/lib/" + env['PYTHON'] + "/site-packages"
-        PATH = env.get("PATH", "")
-        PYTHONPATH = env.get("PYTHONPATH", "")
         env.update({
-            "PATH": bin(prefix) + ":" + PATH,
-            "PYTHONPATH": sp(prefix) + ":" + PYTHONPATH,
+            "PATH": prefix + "/bin",
+            "PYTHONPATH": prefix + "/lib/" + env['PYTHON'] + "/site-packages",
             })
         return env
 
@@ -201,7 +224,6 @@
                         continue
                     builder['slavenames'] = [slave.name for slave in slaves]
 
-                    import os
                     from os.path import isdir, expanduser
                     builddir = expanduser("~/master/" + builder['builddir'])
                     if not isdir(builddir):

Modified: cs/buildbot/trunk/buildbot/lines.py
===================================================================
--- cs/buildbot/trunk/buildbot/lines.py	2007-06-28 22:21:00 UTC (rev 7555)
+++ cs/buildbot/trunk/buildbot/lines.py	2007-06-29 00:35:47 UTC (rev 7556)
@@ -1,6 +1,7 @@
 
 
 from buildbot.categories import Category
+from buildbot.config import Environment
 from buildbot.process.factory import BuildFactory
 from buildbot.scheduler import Nightly, Dependent
 import weakref
@@ -14,7 +15,7 @@
 
         # weakref causes a problem with pickling:
         ## cPickle.UnpickleableError: Cannot pickle <type 'weakproxy'> objects
-        # now pickling is disabled, but weakref also breaks Categories...
+        # weakref also breaks Categories...
         self.project = project #weakref.proxy(project)
         # here's another cycle
         self.category = Category(project = self.project.name,
@@ -25,8 +26,10 @@
         self.env = {}
         
         self.dependencies = []
-        # Builds which depend upon me pull configure args from here.
+        # Builds which depend upon me pull configure args and
+        # environment variables from here.
         self.dependentConfigureArgs = {}
+        self.dependentEnv = {}
         self.isDependency = False
 
         self.builderNames = []
@@ -48,6 +51,16 @@
         return args
 
 
+    def dependencyEnv(self):
+        # If I depend upon a package installed in a non-standard
+        # location, I might need extra things added to my PATH,
+        # PYTHONPATH, etc.  This method handles that.
+        env = Environment()
+        for dep in self.dependencies:
+            env.update(dep.dependentEnv)
+        return env
+
+
     def generate(self, builderNames, schedulerKwds):
         
         # Save the list of builders that build me.
@@ -113,6 +126,7 @@
     def newBuildFactory(self, buildEnv, buildConfig):
         
         env = buildEnv.getEnv(buildConfig)
+        env.update(self.dependencyEnv())
         env.update(self.env)
         
         steps = []



More information about the cig-commits mailing list