← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~gary/launchpad/buildout1.5.0 into lp:launchpad/devel

 

Gary Poster has proposed merging lp:~gary/launchpad/buildout1.5.0 into lp:launchpad/devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)


This branch moves to using a final release of zc.buildout, zc.recipe.egg, and z3c.recipe.scripts, each of which I released today.

The changes to the bootstrap script are merely copied over from the new zc.buildout's version: the file might be included from an external source if bzr had that feature.

The changes to the packages themselves were reviewed by flacoste over several branches.

Thanks

Gary
-- 
https://code.launchpad.net/~gary/launchpad/buildout1.5.0/+merge/33410
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~gary/launchpad/buildout1.5.0 into lp:launchpad/devel.
=== modified file 'bootstrap.py'
--- bootstrap.py	2010-03-20 01:13:25 +0000
+++ bootstrap.py	2010-08-23 16:12:51 +0000
@@ -1,6 +1,6 @@
 ##############################################################################
 #
-# Copyright (c) 2006 Zope Corporation and Contributors.
+# Copyright (c) 2006 Zope Foundation and Contributors.
 # All Rights Reserved.
 #
 # This software is subject to the provisions of the Zope Public License,
@@ -16,11 +16,9 @@
 Simply run this script in a directory containing a buildout.cfg.
 The script accepts buildout command-line options, so you can
 use the -c option to specify an alternate configuration file.
-
-$Id$
 """
 
-import os, shutil, sys, tempfile, textwrap, urllib, urllib2
+import os, shutil, sys, tempfile, textwrap, urllib, urllib2, subprocess
 from optparse import OptionParser
 
 if sys.platform == 'win32':
@@ -32,11 +30,23 @@
 else:
     quote = str
 
+# See zc.buildout.easy_install._has_broken_dash_S for motivation and comments.
+stdout, stderr = subprocess.Popen(
+    [sys.executable, '-Sc',
+     'try:\n'
+     '    import ConfigParser\n'
+     'except ImportError:\n'
+     '    print 1\n'
+     'else:\n'
+     '    print 0\n'],
+    stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
+has_broken_dash_S = bool(int(stdout.strip()))
+
 # In order to be more robust in the face of system Pythons, we want to
 # run without site-packages loaded.  This is somewhat tricky, in
 # particular because Python 2.6's distutils imports site, so starting
 # with the -S flag is not sufficient.  However, we'll start with that:
-if 'site' in sys.modules:
+if not has_broken_dash_S and 'site' in sys.modules:
     # We will restart with python -S.
     args = sys.argv[:]
     args[0:0] = [sys.executable, '-S']
@@ -109,13 +119,22 @@
                   help=("Specify a directory for storing eggs.  Defaults to "
                         "a temporary directory that is deleted when the "
                         "bootstrap script completes."))
+parser.add_option("-t", "--accept-buildout-test-releases",
+                  dest='accept_buildout_test_releases',
+                  action="store_true", default=False,
+                  help=("Normally, if you do not specify a --version, the "
+                        "bootstrap script and buildout gets the newest "
+                        "*final* versions of zc.buildout and its recipes and "
+                        "extensions for you.  If you use this flag, "
+                        "bootstrap and buildout will get the newest releases "
+                        "even if they are alphas or betas."))
 parser.add_option("-c", None, action="store", dest="config_file",
                    help=("Specify the path to the buildout configuration "
                          "file to be used."))
 
 options, args = parser.parse_args()
 
-# if -c was provided, we push it back into args for buildout' main function
+# if -c was provided, we push it back into args for buildout's main function
 if options.config_file is not None:
     args += ['-c', options.config_file]
 
@@ -130,16 +149,15 @@
     else:
         options.setup_source = setuptools_source
 
-args = args + ['bootstrap']
-
+if options.accept_buildout_test_releases:
+    args.append('buildout:accept-buildout-test-releases=true')
+args.append('bootstrap')
 
 try:
-    to_reload = False
     import pkg_resources
-    to_reload = True
+    import setuptools # A flag.  Sometimes pkg_resources is installed alone.
     if not hasattr(pkg_resources, '_distribute'):
         raise ImportError
-    import setuptools # A flag.  Sometimes pkg_resources is installed alone.
 except ImportError:
     ez_code = urllib2.urlopen(
         options.setup_source).read().replace('\r\n', '\n')
@@ -151,10 +169,8 @@
     if options.use_distribute:
         setup_args['no_fake'] = True
     ez['use_setuptools'](**setup_args)
-    if to_reload:
-        reload(pkg_resources)
-    else:
-        import pkg_resources
+    reload(sys.modules['pkg_resources'])
+    import pkg_resources
     # This does not (always?) update the default working set.  We will
     # do it.
     for path in sys.path:
@@ -167,23 +183,59 @@
        '-mqNxd',
        quote(eggs_dir)]
 
-if options.download_base:
-    cmd.extend(['-f', quote(options.download_base)])
+if not has_broken_dash_S:
+    cmd.insert(1, '-S')
 
-requirement = 'zc.buildout'
-if options.version:
-    requirement = '=='.join((requirement, options.version))
-cmd.append(requirement)
+find_links = options.download_base
+if not find_links:
+    find_links = os.environ.get('bootstrap-testing-find-links')
+if find_links:
+    cmd.extend(['-f', quote(find_links)])
 
 if options.use_distribute:
     setup_requirement = 'distribute'
 else:
     setup_requirement = 'setuptools'
 ws = pkg_resources.working_set
+setup_requirement_path = ws.find(
+    pkg_resources.Requirement.parse(setup_requirement)).location
 env = dict(
     os.environ,
-    PYTHONPATH=ws.find(
-        pkg_resources.Requirement.parse(setup_requirement)).location)
+    PYTHONPATH=setup_requirement_path)
+
+requirement = 'zc.buildout'
+version = options.version
+if version is None and not options.accept_buildout_test_releases:
+    # Figure out the most recent final version of zc.buildout.
+    import setuptools.package_index
+    _final_parts = '*final-', '*final'
+    def _final_version(parsed_version):
+        for part in parsed_version:
+            if (part[:1] == '*') and (part not in _final_parts):
+                return False
+        return True
+    index = setuptools.package_index.PackageIndex(
+        search_path=[setup_requirement_path])
+    if find_links:
+        index.add_find_links((find_links,))
+    req = pkg_resources.Requirement.parse(requirement)
+    if index.obtain(req) is not None:
+        best = []
+        bestv = None
+        for dist in index[req.project_name]:
+            distv = dist.parsed_version
+            if _final_version(distv):
+                if bestv is None or distv > bestv:
+                    best = [dist]
+                    bestv = distv
+                elif distv == bestv:
+                    best.append(dist)
+        if best:
+            best.sort()
+            version = best[-1].version
+if version:
+    requirement = '=='.join((requirement, version))
+cmd.append(requirement)
 
 if is_jython:
     import subprocess
@@ -193,7 +245,7 @@
 if exitcode != 0:
     sys.stdout.flush()
     sys.stderr.flush()
-    print ("An error occured when trying to install zc.buildout. "
+    print ("An error occurred when trying to install zc.buildout. "
            "Look above this message for any errors that "
            "were output by easy_install.")
     sys.exit(exitcode)

=== modified file 'versions.cfg'
--- versions.cfg	2010-08-18 19:41:20 +0000
+++ versions.cfg	2010-08-23 16:12:51 +0000
@@ -101,7 +101,7 @@
 z3c.ptcompat = 0.5.3
 z3c.recipe.filetemplate = 2.1.0
 z3c.recipe.i18n = 0.5.3
-z3c.recipe.scripts = 1.0.0dev-gary-r110068
+z3c.recipe.scripts = 1.0.0
 z3c.recipe.tag = 0.2.0
 z3c.rml = 0.7.3
 z3c.skin.pagelet = 1.0.2
@@ -111,12 +111,12 @@
 z3c.viewlet = 1.0.0
 z3c.viewtemplate = 0.3.2
 z3c.zrtresource = 1.0.1
-zc.buildout = 1.5.0dev-gary-r111190
+zc.buildout = 1.5.0
 zc.catalog = 1.2.0
 zc.datetimewidget = 0.5.2
 zc.i18n = 0.5.2
 zc.lockfile = 1.0.0
-zc.recipe.egg = 1.2.3dev-gary-r110068
+zc.recipe.egg = 1.3.0
 zc.zservertracelog = 1.1.5
 ZConfig = 2.7.1
 zdaemon = 2.0.4