@@ -0,0 +1,2031 @@
+#!/usr/bin/env python%0Aimport os%0Aimport shutil%0Aimport sys%0Aimport subprocess%0Aimport tarfile%0Aimport urllib%0A%0Aclass Bootstrap:%0A%0A  def __init__(self,%0A               version=%2212.0.4%22,%0A               base='http://pypi.python.org/packages/source/v/virtualenv',%0A               python=%22python2%22,%0A               env=%22pyenv%22,%0A               requirements=%22requirements.txt%22):%0A    self.version = version%0A    self.base = base%0A    self.python = python%0A    self.env = env%0A    self.dirname = 'virtualenv-' + self.version%0A    self.tgz_file = self.dirname + '.tar.gz'%0A    self.venv_url = self.base + '/' + self.tgz_file%0A    self.requirements=requirements%0A%0A  def shellcmd(self,cmd,echo=False):%0A    %22%22%22 Run 'cmd' in the shell and return its standard out.%0A    %22%22%22%0A    if echo: print '%5Bcmd%5D %7B0%7D'.format(cmd)%0A    out = subprocess.check_output(cmd,stderr=sys.stderr,shell=True)%0A    if echo: print out%0A    return out%0A%0A  def download(self):%0A    %22%22%22 Fetch virtualenv from PyPI%0A    %22%22%22%0A    urllib.urlretrieve(self.venv_url,self.tgz_file)%0A%0A  def extract(self):%0A    %22%22%22 Untar%0A    %22%22%22%0A    tar = tarfile.open(self.tgz_file,%22r:gz%22)%0A    tar.extractall()%0A%0A  def create(self):%0A    %22%22%22 Create the initial env%0A    %22%22%22%0A    self.shellcmd('%7B0%7D %7B1%7D/virtualenv.py %7B2%7D'.format(self.python,self.dirname,self.env))%0A%0A  def install(self):%0A    %22%22%22Install the virtualenv package itself into the initial env%0A    %22%22%22%0A    self.shellcmd('%7B0%7D/bin/pip install %7B1%7D'.format(self.env,self.tgz_file))%0A%0A  def install_libs(self):%0A    %22%22%22Install the virtualenv package itself into the initial env%0A    %22%22%22%0A    self.shellcmd('%7B0%7D/bin/pip install -r %7B1%7D'.format(self.env,self.requirements))%0A%0A  def cleanup(self):%0A    %22%22%22 Cleanup%0A    %22%22%22%0A    os.remove(self.tgz_file)%0A    shutil.rmtree(self.dirname)%0A%0A  def setup(self):%0A    %22%22%22Bootraps a python environment%0A    %22%22%22%0A    self.download()%0A    self.extract()%0A    self.create()%0A    self.install()%0A    self.cleanup()%0A    if os.path.isfile(self.requirements):%0A      self.install_libs()%0A%0Aif __name__ == %22__main__%22:%0A  bootstrap = Bootstrap()%0A  bootstrap.setup()%0A

Check in script