Skip to content
This repository has been archived by the owner on Jan 25, 2019. It is now read-only.

Commit

Permalink
Update bootstrap to cope with system installed buildout
Browse files Browse the repository at this point in the history
  • Loading branch information
John Carr committed Jun 1, 2012
1 parent 3cfc713 commit fd25aa6
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ def _final_version(parsed_version):
cmd.append(requirement)

if is_jython:
import subprocess
exitcode = subprocess.Popen(cmd, env=env).wait()
else: # Windows prefers this, apparently; otherwise we would prefer subprocess
exitcode = os.spawnle(*([os.P_WAIT, sys.executable] + cmd + [env]))
Expand All @@ -256,8 +255,29 @@ def _final_version(parsed_version):
sys.exit(exitcode)

ws.add_entry(eggs_dir)
ws.require(requirement)
try:
ws.require(requirement)
except pkg_resources.DistributionNotFound, e:
if e.args[0].project_name == 'zc.buildout':
print "Couldn't install %s." % str(e.args[0])
print "This could be due to you having a system-installed " \
"python-zc.buildout package."
print "I'm going to attempt to bootstrap your project using the system buildout"

argstring = ",".join("'%s'" % a for a in args)
cmd = [sys.executable, "-c", "import zc.buildout.buildout; zc.buildout.buildout.main([%s])" % argstring]
print subprocess.list2cmdline(cmd)
exitcode = subprocess.Popen(cmd).wait()
if exitcode != 0:
sys.stdout.flush()
sys.stderr.flush()
print "An error occurred - i think you should remove the system installed buildout"
sys.exit(1)
sys.exit(0)
raise

import zc.buildout.buildout
zc.buildout.buildout.main(args)
if not options.eggs: # clean up temporary egg directory
shutil.rmtree(eggs_dir)

0 comments on commit fd25aa6

Please sign in to comment.