[Checkins] SVN: grokproject/trunk/grokproject/ delegate bootstrapping the new project to the bootstrap of that project. by not using zc.buildout in the grokproject command anymore, we prevent version conflicts

Jan-Wijbrand Kolman janwijbrand at gmail.com
Tue Oct 19 09:15:45 EDT 2010


Log message for revision 117758:
  delegate bootstrapping the new project to the bootstrap of that project. by not using zc.buildout in the grokproject command anymore, we prevent version conflicts

Changed:
  U   grokproject/trunk/grokproject/main.py
  U   grokproject/trunk/grokproject/template/buildout.cfg_tmpl
  U   grokproject/trunk/grokproject/templates.py
  U   grokproject/trunk/grokproject/utils.py

-=-
Modified: grokproject/trunk/grokproject/main.py
===================================================================
--- grokproject/trunk/grokproject/main.py	2010-10-19 12:31:59 UTC (rev 117757)
+++ grokproject/trunk/grokproject/main.py	2010-10-19 13:15:45 UTC (rev 117758)
@@ -22,7 +22,7 @@
                       default=False, help="Be verbose.")
     parser.add_option('--version', action="store_true", dest="version",
                       default=False, help="Show grokproject version.")
-    
+
     # Options that override the interactive part of filling the templates.
     for var in GrokProject.vars:
         option_name = '--'+var.name.replace('_', '-')
@@ -32,7 +32,7 @@
                 help=var.description)
 
     options, args = parser.parse_args()
-    
+
     if options.version:
         print get_version()
         return 0
@@ -81,4 +81,3 @@
     if info.has_version and info.version:
         return info.version
     return 'Unknown'
-

Modified: grokproject/trunk/grokproject/template/buildout.cfg_tmpl
===================================================================
--- grokproject/trunk/grokproject/template/buildout.cfg_tmpl	2010-10-19 12:31:59 UTC (rev 117757)
+++ grokproject/trunk/grokproject/template/buildout.cfg_tmpl	2010-10-19 13:15:45 UTC (rev 117758)
@@ -97,13 +97,13 @@
   ${egg}
   zope.password
 entry-points =
-    zpasswd=zope.password.zpasswd:main
+  zpasswd=zope.password.zpasswd:main
 
 [interactive_debugger]
 recipe = z3c.recipe.scripts
 eggs = ${egg}
 entry-points =
-    interactive_debugger=grokcore.startup.startup:interactive_debug_prompt
+  interactive_debugger=grokcore.startup.startup:interactive_debug_prompt
 arguments = zope_conf="$${zope_conf:output}"
 
 # The [data] and [log] parts are still in here to instruct buildout to not

Modified: grokproject/trunk/grokproject/templates.py
===================================================================
--- grokproject/trunk/grokproject/templates.py	2010-10-19 12:31:59 UTC (rev 117757)
+++ grokproject/trunk/grokproject/templates.py	2010-10-19 13:15:45 UTC (rev 117758)
@@ -32,6 +32,10 @@
                 "After creating the project area, run the buildout.",
                 default=True, should_ask=False,
                 getter=get_boolean_value_for_option),
+        ask_var('use_distribute',
+                "Use Distribute instead of setuptools for this project.",
+                default=False, should_ask=False,
+                getter=get_boolean_value_for_option),
         ask_var('eggs_dir',
                 'Location where zc.buildout will look for and place packages',
                 default='', should_ask=False),
@@ -128,5 +132,5 @@
             return
         original_dir = os.getcwd()
         os.chdir(vars['project'])
-        run_buildout(command.verbose)
+        run_buildout(command.verbose, vars['use_distribute'])
         os.chdir(original_dir)

Modified: grokproject/trunk/grokproject/utils.py
===================================================================
--- grokproject/trunk/grokproject/utils.py	2010-10-19 12:31:59 UTC (rev 117757)
+++ grokproject/trunk/grokproject/utils.py	2010-10-19 13:15:45 UTC (rev 117758)
@@ -1,6 +1,7 @@
 from base64 import urlsafe_b64encode
 from paste.script.templates import var
 from random import randint
+import subprocess
 import codecs
 import logging
 import os
@@ -89,70 +90,20 @@
         value = option.default
     return value
 
-
 def exist_buildout_default_file():
     default_cfg = os.path.join(HOME, '.buildout', 'default.cfg')
     return os.path.isfile(default_cfg)
 
-
-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==1.5.1'])
-        setuptools.command.easy_install.main(
-            extra_args + ['-mNxd', tmpdir, 'setuptools==0.6c11'])
-
-        # 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')
-        ws.require('setuptools')
-
-        import zc.buildout.buildout
-        zc.buildout.buildout.main(extra_args + ['bootstrap'])
-        remove_old_logger_handlers()
-        shutil.rmtree(tmpdir)
-    else:
-        zc.buildout.buildout.main(extra_args + ['bootstrap'])
-        remove_old_logger_handlers()
-
-    print "Invoking zc.buildout..."
-
-    # Now do the rest of the install.
-    zc.buildout.buildout.main(extra_args + ['install'])
-    remove_old_logger_handlers()
-
-
-def remove_old_logger_handlers():
-    # zc.buildout installs a new log stream on every call of
-    # main(). We remove any leftover handlers to avoid multiple output
-    # of same content (doubled lines etc.)
-    root_logger = logging.getLogger()
-    if 'zc.buildout' in root_logger.manager.loggerDict.keys():
-        logger = logging.getLogger('zc.buildout')
-        for handler in logger.handlers:
-            logger.removeHandler(handler)
-    return
+def run_buildout(verbose=False, use_distribute=False):
+    # Run the project's bootstrap.
+    cmd = sys.executable + ' bootstrap.py'
+    if use_distribute:
+        cmd += ' --distribute'
+    print 'Running %s...' % cmd
+    subprocess.call(cmd, shell=True)
+    # Then, run the project's buildout.
+    cmd = os.path.join(os.getcwd(), 'bin', 'buildout')
+    if verbose:
+        cmd += ' -v'
+    print 'Running %s...' % cmd
+    subprocess.call(cmd, shell=True)



More information about the checkins mailing list