【发布时间】:2011-12-03 19:10:51
【问题描述】:
我正在尝试创建一个 boostrap.py 脚本,该脚本将创建一个 virtualenv 并从 requirements.txt 文件安装要求。我项目的其他贡献者应该能够从 github 签出该项目并运行python bootstrap.py,然后运行source env/bin/activate 来安装我的应用程序。以下是我编写的脚本,使用此页面作为指南:http://pypi.python.org/pypi/virtualenv
import virtualenv, textwrap
output = virtualenv.create_bootstrap_script(textwrap.dedent("""
def after_install(options, home_dir):
if sys.platform == 'win32':
bin = 'Scripts'
else:
bin = 'bin'
subprocess.call([join(home_dir,bin,'pip'),'install -r requirements.txt'])
"""))
print output
以下是我为创建引导程序并运行它而运行的命令:
python create_bootstrap.py > bootstrap.py
python bootstrap.py env
下面是输出:
New python executable in env/bin/python
Installing setuptools............done.
Installing pip...............done.
Usage: pip COMMAND [OPTIONS]
pip: error: No command by the name pip install -r requirements.txt
(maybe you meant "pip install install -r requirements.txt")
requirements.txt 如下所示:
sqlalchemy==0.7
任何关于不同做法的建议或关于我做错了什么的提示都会有所帮助。非常感谢!
【问题讨论】:
标签: python virtualenv bootstrapping