管理许多 Python 项目/virtualenv
在我的工作场所,我必须管理许多(目前有数十个,但最终可能有数百个)Python Web 应用程序,可能运行各种框架、库等(所有版本都不同)。到目前为止,Virtualenv 一直是管理这个问题的救星,但我仍然希望能够更好地管理事情,特别是在管理软件包升级方面。
我想到了几种方案
选项1: 使用 pip 在每个 virtualenv 中安装每个项目所需的所有模块,并根据需要单独升级每个模块。每次升级都需要大量的时间成本,并且需要额外的文档来跟踪事情。可能会通过一些管理脚本来促进。
选项2: 将任何应用程序使用的所有库安装在中央存储库中,使用符号链接轻松更改所有项目的版本。轻松升级和集中管理,但首先放弃了使用 virtualenv 的一些最好的好处。
选项 3: 以某种方式混合上述两个,集中最常见的库和/或可能需要升级的库,并将其余库本地安装到每个 virtualenv。
还有其他人有类似的情况吗?处理这个问题的最佳方法是什么?
In my workplace, I have to manage many (currently tens, but probably hundreds eventually) Python web applications, potentially running various frameworks, libraries, etc (all at various versions). Virtualenv has been a lifesaver in managing that so far, but I'd still like to be able to manage things better, particularly when it comes to managing package upgrades.
I've thought of a few scenarios
Option 1:
Install all required modules for each project in each virtualenv using pip, upgrade each individually as necessary. This would require a significant time cost for each upgrade and would require additional documentation to keep track of things. Might be facilitated by some management scripting.
Option 2:
Install all libraries used by any application in a central repository, use symlinks to easily change versions once for all projects. Easy upgrades and central management, but forgoes some of the nicest benefits of using virtualenv in the first place.
Option 3:
Hybridize the above two somehow, centralizing the most common libraries and/or those likely to need upgrades and installing the rest locally to each virtualenv.
Does anyone else have a similar situation? What's the best way to handle this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以考虑使用 zc.buildout。它的设置比普通的 pip/virtualenv 更烦人,但它为您提供了更多自动化的机会。如果磁盘空间使用不是问题,我建议您继续为每个项目使用单独的环境,这样您就可以一次升级它们。
You might consider using zc.buildout. It's more annoying to set up than plain pip/virtualenv, but it gives you more opportunities for automation. If the disk space usage isn't an issue, I'd suggest you just keep using individual environments for each project so you can upgrade them one at a time.
我们的项目根目录中有一个requirements.pip 文件,其中包含要安装的pip 包,因此自动升级相对容易。我不确定符号链接能否解决该问题 - 这将使升级项目的子集变得更加困难。如果磁盘空间不是问题,并且您可以编写一些简单的脚本来列出和升级软件包,我会坚持使用 virtualenv 原样。
We have a requirements.pip file at our project root that contains the packages for pip to install, so upgrading automatically is relatively easy. I'm not sure symlinking would solve the issue - it will make it harder to make upgrades to a subset of your projects. If diskspace isn't an issue, and you can write some simple scripts to list and upgrade packages, I'd stick with virtualenv as-is.