Commit 9e7af28e authored by Marius Gedminas's avatar Marius Gedminas

Update to latest bootstrap.py

Downloaded from http://downloads.buildout.org/2/bootstrap.py
parent adf92861
...@@ -56,6 +56,9 @@ parser.add_option("-c", "--config-file", ...@@ -56,6 +56,9 @@ parser.add_option("-c", "--config-file",
"file to be used.")) "file to be used."))
parser.add_option("-f", "--find-links", parser.add_option("-f", "--find-links",
help=("Specify a URL to search for buildout releases")) 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() options, args = parser.parse_args()
...@@ -63,30 +66,36 @@ options, args = parser.parse_args() ...@@ -63,30 +66,36 @@ options, args = parser.parse_args()
###################################################################### ######################################################################
# load/install setuptools # load/install setuptools
to_reload = False
try: try:
import pkg_resources if options.allow_site_packages:
import setuptools import setuptools
except ImportError: import pkg_resources
ez = {}
try:
from urllib.request import urlopen from urllib.request import urlopen
except ImportError: except ImportError:
from urllib2 import urlopen from urllib2 import urlopen
# XXX use a more permanent ez_setup.py URL when available. ez = {}
exec(urlopen('https://bitbucket.org/pypa/setuptools/raw/0.7.2/ez_setup.py' exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez)
).read(), ez)
setup_args = dict(to_dir=tmpeggs, download_delay=0) if not options.allow_site_packages:
ez['use_setuptools'](**setup_args) # ez_setup imports site, which adds site packages
# this will remove them from the path to ensure that incompatible versions
if to_reload: # of setuptools are not in the path
reload(pkg_resources) import site
import pkg_resources # inside a virtualenv, there is no 'getsitepackages'.
# This does not (always?) update the default working set. We will # We can't remove these reliably
# do it. if hasattr(site, 'getsitepackages'):
for path in sys.path: 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: if path not in pkg_resources.working_set.entries:
pkg_resources.working_set.add_entry(path) pkg_resources.working_set.add_entry(path)
...@@ -149,8 +158,7 @@ cmd.append(requirement) ...@@ -149,8 +158,7 @@ cmd.append(requirement)
import subprocess import subprocess
if subprocess.call(cmd, env=dict(os.environ, PYTHONPATH=setuptools_path)) != 0: if subprocess.call(cmd, env=dict(os.environ, PYTHONPATH=setuptools_path)) != 0:
raise Exception( raise Exception(
"Failed to execute command:\n%s", "Failed to execute command:\n%s" % repr(cmd)[1:-1])
repr(cmd)[1:-1])
###################################################################### ######################################################################
# Import and run buildout # Import and run buildout
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment