[英]Installing selected packages from requirements.txt
I have a requirements.txt file on my development machine. 我的开发机器上有一个requirements.txt文件。 I have pushed it into a git repo and cloned it on a server. 我已经将其推入git repo并将其克隆到服务器上。
The way I push changes to the server is as follows: 我将更改推送到服务器的方式如下:
I freeze the file on my development machine, then I add the file to git and pull it on the server and do pip install -r requirements.txt. 我将文件冻结在开发机器上,然后将文件添加到git并将其拉到服务器上,然后执行pip install -r requirements.txt。
But doing this is installing all the packages again and again and I dont want that. 但是这样做是一次又一次地安装所有软件包,我不希望那样。 I only want those packages to be installed which are not installed on the server. 我只希望安装那些未安装在服务器上的软件包。
Whats the best way of doing this? 最好的方法是什么? I would also like to know other efficient methods of pushing development code to server. 我还想知道将开发代码推送到服务器的其他有效方法。
Use buildout , this is other method. 使用buildout ,这是另一种方法。 Buildout checks for packages before installing, so it will not reinstall unneeded packages. Buildout在安装之前会检查软件包,因此不会重新安装不需要的软件包。
It is very powerfull tool. 这是非常强大的工具。 When you deploy, you just need to make git push
, then on the production server you do: 部署时,只需执行git push
,然后在生产服务器上执行以下操作:
git pull
bin/buildout
That's it. 而已。 You can read an article about Buildout and pip+virtualenv differences 您可以阅读有关Buildout和pip + virtualenv差异的文章
EDIT: 编辑:
You can set PIP_DOWNLOAD_CACHE
path in settings.py
to tell pip store all downloaded packages in some directory(' packages
' for example), so it won't download them again: 您可以在settings.py
设置PIP_DOWNLOAD_CACHE
路径,以告诉pip将所有下载的软件包存储在某个目录中(例如“ packages
”),这样就不会再次下载它们:
import os.path
PROJECT_ROOT = os.path.normpath(os.path.dirname(__file__))
PIP_DOWNLOAD_CACHE = os.path.abspath(PROJECT_ROOT+'/packages/'),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.