启动脚本范例

这有个具体的例子:

  1. import virtualenv, textwrap
  2. output = virtualenv.create_bootstrap_script(textwrap.dedent("""
  3. import os, subprocess
  4. def after_install(options, home_dir):
  5. etc = join(home_dir, 'etc')
  6. if not os.path.exists(etc):
  7. os.makedirs(etc)
  8. subprocess.call([join(home_dir, 'bin', 'easy_install'),
  9. 'BlogApplication'])
  10. subprocess.call([join(home_dir, 'bin', 'paster'),
  11. 'make-config', 'BlogApplication',
  12. join(etc, 'blog.ini')])
  13. subprocess.call([join(home_dir, 'bin', 'paster'),
  14. 'setup-app', join(etc, 'blog.ini')])
  15. """))
  16. f = open('blog-bootstrap.py', 'w').write(output)

这还有一个例子 点击