多个独立的python运行环境创建工具 VirtualEnv

fmms 13年前
     <p>VirtualEnv用于在一台机器上创建多个独立的python运行环境,VirtualEnvWrapper为前者提供了一些便利的命令行上的封装。</p>    <p>使用 VirtualEnv 的理由:</p>    <ul>     <li>隔离项目之间的第三方包依赖,如A项目依赖django1.2.5,B项目依赖django1.3。 </li>     <li>为部署应用提供方便,把开发环境的虚拟环境打包到生产环境即可,不需要在服务器上再折腾一翻。</li>    </ul> 项目地址:    <a href="/misc/goto?guid=4958186888415226162" target="_blank">http://www.virtualenv.org/en/latest/index.html</a>    <br /> 示例:    <pre class="brush:python; toolbar: true; auto-links: false;">import virtualenv, textwrap  output = virtualenv.create_bootstrap_script(textwrap.dedent("""  import os, subprocess  def after_install(options, home_dir):      etc = join(home_dir, 'etc')      if not os.path.exists(etc):          os.makedirs(etc)      subprocess.call([join(home_dir, 'bin', 'easy_install'),                       'BlogApplication'])      subprocess.call([join(home_dir, 'bin', 'paster'),                       'make-config', 'BlogApplication',                       join(etc, 'blog.ini')])      subprocess.call([join(home_dir, 'bin', 'paster'),                       'setup-app', join(etc, 'blog.ini')])  """))  f = open('blog-bootstrap.py', 'w').write(output)</pre>