summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Gedminas <marius@gedmin.as>2014-11-06 09:19:10 +0200
committerMarius Gedminas <marius@gedmin.as>2014-11-06 09:19:10 +0200
commit4f596d9cd7d6fcb5df98b603c9fcd4ca6282d420 (patch)
tree96ec87e8c0e26bd3b7e405174c519416182d452f
parent007f4ffc3fb7dee3deeb7fbd88926fb07a0848a5 (diff)
downloadzope-security-4f596d9cd7d6fcb5df98b603c9fcd4ca6282d420.tar.gz
Update to latest bootstrap.py
Downloaded from http://downloads.buildout.org/2/bootstrap.py
-rw-r--r--bootstrap.py60
1 files changed, 34 insertions, 26 deletions
diff --git a/bootstrap.py b/bootstrap.py
index 1b28969..ed57894 100644
--- a/bootstrap.py
+++ b/bootstrap.py
@@ -56,6 +56,9 @@ parser.add_option("-c", "--config-file",
"file to be used."))
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"))
options, args = parser.parse_args()
@@ -63,32 +66,38 @@ options, args = parser.parse_args()
######################################################################
# load/install setuptools
-to_reload = False
try:
- import pkg_resources
- import setuptools
+ if options.allow_site_packages:
+ import setuptools
+ import pkg_resources
+ from urllib.request import urlopen
except ImportError:
- ez = {}
-
- try:
- from urllib.request import urlopen
- except ImportError:
- from urllib2 import urlopen
-
- # XXX use a more permanent ez_setup.py URL when available.
- exec(urlopen('https://bitbucket.org/pypa/setuptools/raw/0.7.2/ez_setup.py'
- ).read(), ez)
- setup_args = dict(to_dir=tmpeggs, download_delay=0)
- ez['use_setuptools'](**setup_args)
-
- 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)
+ from urllib2 import urlopen
+
+ez = {}
+exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez)
+
+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]
+
+setup_args = dict(to_dir=tmpeggs, download_delay=0)
+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)
######################################################################
# Install buildout
@@ -149,8 +158,7 @@ cmd.append(requirement)
import subprocess
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])
######################################################################
# Import and run buildout