bootstrap.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. ##############################################################################
  2. #
  3. # Copyright (c) 2006 Zope Corporation and Contributors.
  4. # All Rights Reserved.
  5. #
  6. # This software is subject to the provisions of the Zope Public License,
  7. # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
  8. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
  9. # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  10. # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
  11. # FOR A PARTICULAR PURPOSE.
  12. #
  13. ##############################################################################
  14. """Bootstrap a buildout-based project
  15. Simply run this script in a directory containing a buildout.cfg.
  16. The script accepts buildout command-line options, so you can
  17. use the -c option to specify an alternate configuration file.
  18. $Id: bootstrap.py 72703 2007-02-20 11:49:26Z jim $
  19. """
  20. import os, shutil, sys, tempfile, urllib2
  21. tmpeggs = tempfile.mkdtemp()
  22. ez = {}
  23. exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
  24. ).read() in ez
  25. ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
  26. import pkg_resources
  27. is_jython = sys.platform.startswith('java')
  28. if is_jython:
  29. import subprocess
  30. cmd = 'from setuptools.command.easy_install import main; main()'
  31. if sys.platform == 'win32':
  32. cmd = '"%s"' % cmd # work around spawn lamosity on windows
  33. ws = pkg_resources.working_set
  34. if is_jython:
  35. assert subprocess.Popen([sys.executable] + ['-c', cmd, '-mqNxd', tmpeggs,
  36. 'zc.buildout'],
  37. env = dict(os.environ,
  38. PYTHONPATH=
  39. ws.find(pkg_resources.Requirement.parse('setuptools')).location
  40. ),
  41. ).wait() == 0
  42. else:
  43. assert os.spawnle(
  44. os.P_WAIT, sys.executable, sys.executable,
  45. '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
  46. dict(os.environ,
  47. PYTHONPATH=
  48. ws.find(pkg_resources.Requirement.parse('setuptools')).location
  49. ),
  50. ) == 0
  51. ws.add_entry(tmpeggs)
  52. ws.require('zc.buildout')
  53. import zc.buildout.buildout
  54. zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
  55. shutil.rmtree(tmpeggs)