[Checkins] SVN: grokproject/trunk/ Copy the run_buildout function from zopeproject and put it in

Maurits van Rees m.van.rees at zestsoftware.nl
Fri May 2 12:22:54 EDT 2008


Log message for revision 86106:
  Copy the run_buildout function from zopeproject and put it in
  utils.py.  Call that in the post hook of our paste template.  In the
  grokproject command after calling paster just quit.
  

Changed:
  U   grokproject/trunk/CHANGES.txt
  U   grokproject/trunk/grokproject/__init__.py
  A   grokproject/trunk/grokproject/utils.py

-=-
Modified: grokproject/trunk/CHANGES.txt
===================================================================
--- grokproject/trunk/CHANGES.txt	2008-05-02 15:56:08 UTC (rev 86105)
+++ grokproject/trunk/CHANGES.txt	2008-05-02 16:22:53 UTC (rev 86106)
@@ -4,6 +4,10 @@
 0.8 (unreleased)
 ------------------
 
+* Copy the run_buildout function from zopeproject and put it in
+  utils.py.  Call that in the post hook of our paste template.  In the
+  grokproject command after calling paster just quit.
+
 * Do checks before asking questions.  Define getters for some vars.
   Move no_buildout from the command to run_buildout in the template.
   Use version_info_url in the template instead of renaming it to

Modified: grokproject/trunk/grokproject/__init__.py
===================================================================
--- grokproject/trunk/grokproject/__init__.py	2008-05-02 15:56:08 UTC (rev 86105)
+++ grokproject/trunk/grokproject/__init__.py	2008-05-02 16:22:53 UTC (rev 86106)
@@ -1,4 +1,5 @@
 import sys
+import os
 import os.path
 import optparse
 import shutil
@@ -9,6 +10,7 @@
 import xml.sax.saxutils
 from paste.script import templates, command
 from paste.script.templates import var, NoDefault
+from grokproject.utils import run_buildout
 
 VERSIONINFO_INFO_URL = 'http://grok.zope.org/releaseinfo/current'
 
@@ -105,7 +107,12 @@
         vars['app_class_name'] = vars['project'].capitalize()
         return vars
 
+    def post(self, command, output_dir, vars):
+        if vars['run_buildout']:
+            os.chdir(vars['project'])
+            run_buildout(command.options.verbose)
 
+
 def main():
     usage = "usage: %prog [options] PROJECT"
     parser = optparse.OptionParser(usage=usage)
@@ -154,40 +161,4 @@
 
     exit_code = runner.run(option_args + ['-t', 'grok', project]
                            + extra_args)
-    # TODO exit_code
-
-    os.chdir(project)
-
-    # TODO Handle buildout in post()
-
-    extra_args = []
-    if not options.verbose:
-        extra_args.append('-q')
-
-    try:
-        import zc.buildout.buildout
-    except ImportError:
-        print "Downloading zc.buildout..."
-
-        # Install buildout into a temporary location
-        import setuptools.command.easy_install
-        tmpdir = tempfile.mkdtemp()
-        sys.path.append(tmpdir)
-        setuptools.command.easy_install.main(extra_args +
-                                             ['-mNxd', tmpdir, 'zc.buildout'])
-
-        # Add downloaded buildout to PYTHONPATH by requiring it
-        # through setuptools (this dance is necessary because the
-        # temporary installation was done as multi-version).
-        ws = pkg_resources.working_set
-        ws.add_entry(tmpdir)
-        ws.require('zc.buildout')
-
-        import zc.buildout.buildout
-        zc.buildout.buildout.main(extra_args + ['bootstrap'])
-        shutil.rmtree(tmpdir)
-    else:
-        zc.buildout.buildout.main(extra_args + ['bootstrap'])
-
-    print "Invoking zc.buildout..."
-    zc.buildout.buildout.main(['-q', 'install'])
+    sys.exit(exit_code)

Added: grokproject/trunk/grokproject/utils.py
===================================================================
--- grokproject/trunk/grokproject/utils.py	                        (rev 0)
+++ grokproject/trunk/grokproject/utils.py	2008-05-02 16:22:53 UTC (rev 86106)
@@ -0,0 +1,47 @@
+import sys
+import shutil
+import tempfile
+import pkg_resources
+
+
+def run_buildout(verbose=False):
+    """Run a buildout.
+
+    This will download zc.buildout if it's not available. Then it will
+    bootstrap the buildout scripts and finally launch the buildout
+    installation routine.
+
+    Note that this function expects the buildout directory to be the
+    current working directory.
+    """
+    extra_args = []
+    if not verbose:
+        extra_args.append('-q')
+
+    try:
+        import zc.buildout.buildout
+    except ImportError:
+        print "Downloading zc.buildout..."
+
+        # Install buildout into a temporary location
+        import setuptools.command.easy_install
+        tmpdir = tempfile.mkdtemp()
+        sys.path.append(tmpdir)
+        setuptools.command.easy_install.main(extra_args +
+                                             ['-mNxd', tmpdir, 'zc.buildout'])
+
+        # Add downloaded buildout to PYTHONPATH by requiring it
+        # through setuptools (this dance is necessary because the
+        # temporary installation was done as multi-version).
+        ws = pkg_resources.working_set
+        ws.add_entry(tmpdir)
+        ws.require('zc.buildout')
+
+        import zc.buildout.buildout
+        zc.buildout.buildout.main(extra_args + ['bootstrap'])
+        shutil.rmtree(tmpdir)
+    else:
+        zc.buildout.buildout.main(extra_args + ['bootstrap'])
+
+    print "Invoking zc.buildout..."
+    zc.buildout.buildout.main(['-q', 'install'])


Property changes on: grokproject/trunk/grokproject/utils.py
___________________________________________________________________
Name: svn:eol-style
   + native



More information about the Checkins mailing list