aboutsummaryrefslogtreecommitdiffstats
path: root/97suifangqa/env/mk-virtual-env.py
blob: be51dea294c3c3382e92cc96da3c1fa7775dda53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python
#-*- coding: utf-8 -*-
'''
    用法:
    1. 安装:在mk-virtua-env.py文件所在目录下执行python mk-virtualenv-env.py以安装环境
    2. 运行:在terminal里面执行source <PROJ-DIR>/env/env/bin/activate, 然后启动web服务相关的进程
'''
import virtualenv, textwrap
import os,subprocess, tempfile
output = virtualenv.create_bootstrap_script(textwrap.dedent("""
import os, subprocess
def after_install(options, home_dir):
    subprocess.call([join(home_dir, 'bin', 'pip'),
                     'install',
                     '-r',
                     'requirements.pip'])
"""))
f = tempfile.NamedTemporaryFile()
f.write(output)
f.flush()

subprocess.call(['python', f.name, 'env'])