Index: /main/waeup.ikoba/trunk/CHANGES.txt
===================================================================
--- /main/waeup.ikoba/trunk/CHANGES.txt	(revision 12454)
+++ /main/waeup.ikoba/trunk/CHANGES.txt	(revision 12455)
@@ -4,4 +4,6 @@
 0.2dev (unreleased)
 ===================
+
+* Update bootstrap.py and dependent package versions.
 
 * Add products, documents and customers modules and tons of components.
Index: /main/waeup.ikoba/trunk/bootstrap.py
===================================================================
--- /main/waeup.ikoba/trunk/bootstrap.py	(revision 12454)
+++ /main/waeup.ikoba/trunk/bootstrap.py	(revision 12455)
@@ -36,5 +36,5 @@
 Python that you want bin/buildout to use.
 
-Note that by using --find-links to point to local resources, you can keep 
+Note that by using --find-links to point to local resources, you can keep
 this script from going over the network.
 '''
@@ -57,4 +57,9 @@
 parser.add_option("-f", "--find-links",
                   help=("Specify a URL to search for buildout releases"))
+parser.add_option("--allow-site-packages",
+                  action="store_true", default=False,
+                  help=("Let bootstrap.py use existing site packages"))
+parser.add_option("--setuptools-version",
+                  help="use a specific setuptools version")
 
 
@@ -62,34 +67,42 @@
 
 ######################################################################
-# load/install distribute
+# load/install setuptools
 
-to_reload = False
 try:
-    import pkg_resources
-    import setuptools
-    if not hasattr(pkg_resources, '_distribute'):
-        to_reload = True
-        raise ImportError
+    if options.allow_site_packages:
+        import setuptools
+        import pkg_resources
+    from urllib.request import urlopen
 except ImportError:
-    ez = {}
+    from urllib2 import urlopen
 
-    try:
-        from urllib.request import urlopen
-    except ImportError:
-        from urllib2 import urlopen
+ez = {}
+exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez)
 
-    exec(urlopen(
-        'http://downloads.buildout.org/2.1/distribute_setup.py').read(), ez)
-    setup_args = dict(to_dir=tmpeggs, download_delay=0, no_fake=True)
-    ez['use_setuptools'](**setup_args)
+if not options.allow_site_packages:
+    # ez_setup imports site, which adds site packages
+    # this will remove them from the path to ensure that incompatible versions
+    # of setuptools are not in the path
+    import site
+    # inside a virtualenv, there is no 'getsitepackages'.
+    # We can't remove these reliably
+    if hasattr(site, 'getsitepackages'):
+        for sitepackage_path in site.getsitepackages():
+            sys.path[:] = [x for x in sys.path if sitepackage_path not in x]
 
-    if to_reload:
-        reload(pkg_resources)
-    import pkg_resources
-    # This does not (always?) update the default working set.  We will
-    # do it.
-    for path in sys.path:
-        if path not in pkg_resources.working_set.entries:
-            pkg_resources.working_set.add_entry(path)
+setup_args = dict(to_dir=tmpeggs, download_delay=0)
+
+if options.setuptools_version is not None:
+    setup_args['version'] = options.setuptools_version
+
+ez['use_setuptools'](**setup_args)
+import setuptools
+import pkg_resources
+
+# This does not (always?) update the default working set.  We will
+# do it.
+for path in sys.path:
+    if path not in pkg_resources.working_set.entries:
+        pkg_resources.working_set.add_entry(path)
 
 ######################################################################
@@ -111,6 +124,6 @@
     cmd.extend(['-f', find_links])
 
-distribute_path = ws.find(
-    pkg_resources.Requirement.parse('distribute')).location
+setuptools_path = ws.find(
+    pkg_resources.Requirement.parse('setuptools')).location
 
 requirement = 'zc.buildout'
@@ -122,10 +135,15 @@
 
     def _final_version(parsed_version):
-        for part in parsed_version:
-            if (part[:1] == '*') and (part not in _final_parts):
-                return False
-        return True
+        try:
+            return not parsed_version.is_prerelease
+        except AttributeError:
+            # Older setuptools
+            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=[distribute_path])
+        search_path=[setuptools_path])
     if find_links:
         index.add_find_links((find_links,))
@@ -150,8 +168,7 @@
 
 import subprocess
-if subprocess.call(cmd, env=dict(os.environ, PYTHONPATH=distribute_path)) != 0:
+if subprocess.call(cmd, env=dict(os.environ, PYTHONPATH=setuptools_path)) != 0:
     raise Exception(
-        "Failed to execute command:\n%s",
-        repr(cmd)[1:-1])
+        "Failed to execute command:\n%s" % repr(cmd)[1:-1])
 
 ######################################################################
Index: /main/waeup.ikoba/trunk/versions.cfg
===================================================================
--- /main/waeup.ikoba/trunk/versions.cfg	(revision 12454)
+++ /main/waeup.ikoba/trunk/versions.cfg	(revision 12455)
@@ -19,5 +19,5 @@
 transaction = 1.1.0
 z3c.testsetup = 0.6.1
-zc.buildout = 2.1.0
+zc.buildout = 2.2.5
 zc.recipe.egg = 2.0.0a3
 zc.recipe.testrunner = 2.0.0
