在Requirements.txt中为Virtualenv指定Python版本 [英] Specify Python Version for Virtualenv in Requirements.txt

查看:305
本文介绍了在Requirements.txt中为Virtualenv指定Python版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用virtualenv与团队一起开发django应用程序.我们要在其上部署的服务器正在运行python 2.6,但是我们的计算机的默认值为2.7.3.在代码库中,是否有任何方法可以在requirements.txt文件或类似文件中指定python版本?

I'm using virtualenv to develop a django application with a team. The server we're deploying on is running python 2.6, but the default for our machines is 2.7.3. Is there any way to specify python version in the requirements.txt file, or something similar, within the code base?

我知道requirements.txt是一个小问题,而python版本是virtualenv的事情,但是不必告诉每个加入团队的新手如何设置他们的virtualenv,这真的很方便.

I know requirements.txt is a pip thing, and python version is a virtualenv thing, but it would be really convenient not to have to tell every new person joining the team how to set up their virtualenv.

推荐答案

pip和virtualenv均未安装python(尽管

Neither pip nor virtualenv install python (though pip tries). They use whatever you specify.

您可以编写一个自述文件,其中提到所需的Python版本,或者提供一个可以部署到本地主机并指定版本的 fabric 脚本.那里.例如,有关安装virtualenv,pip,分发的说明.

You could write a README that mentions required Python version or provide a fabric script that can deploy to localhost and specify the version there. For example, instructions to install virtualenv, pip, distribute.

对于那些不阅读说明的人,可能会有一个CI系统( jenkins buildbot ),可以使用受支持的python版本(在提交之前/之后)运行单元测试.

For those people who don't read instructions there could be a CI system (jenkins, buildbot) that can run unit-tests using supported python versions (before/after commit).

要管理多个python安装,您可以使用 pythonz 之类的东西.

To manage multiple python installation you could use something like pythonz.

这篇关于在Requirements.txt中为Virtualenv指定Python版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆