Commit 9bcc9042 authored by Yusuke Tsutsumi's avatar Yusuke Tsutsumi

A bootstrap.py that no longer uses site-packages

parent 7dc7b399
...@@ -63,30 +63,33 @@ options, args = parser.parse_args() ...@@ -63,30 +63,33 @@ options, args = parser.parse_args()
###################################################################### ######################################################################
# load/install setuptools # load/install setuptools
to_reload = False
try: try:
import pkg_resources
import setuptools
except ImportError:
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' # XXX use a more permanent ez_setup.py URL when available.
exec(urlopen('https://bitbucket.org/pypa/setuptools/downloads/ez_setup.py'
).read(), ez) ).read(), ez)
setup_args = dict(to_dir=tmpeggs, download_delay=0) setup_args = dict(to_dir=tmpeggs, download_delay=0)
ez['use_setuptools'](**setup_args) ez['use_setuptools'](**setup_args)
import setuptools
if to_reload: # ez_setup imports site, which adds site packages
reload(pkg_resources)
import pkg_resources # this will remove them to ensure that incompataible versions
# This does not (always?) update the default working set. We will # of setuptools are not installed
# do it. import site
for path in sys.path: # 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]
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)
......
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