在分发包中使用 virtualenv 部署 Django?

发布于 2024-09-30 14:01:59 字数 296 浏览 0 评论 0原文

我必须将 Django 应用程序部署到 SuSE Linux Enterprise 11 系统上。公司规则规定我只需要使用 RPM 进行部署。虽然我可以对每个依赖项使用 ./setup.py bdist_rpm ,但这并不是很明智,因为 RPM 尚未记录所有依赖项。因此,我在使用 RPM 方面没有真正的优势,并且手动管理依赖项有点麻烦,我想避免它。

现在我有了以下想法:在构建包时,我可以创建一个 virtualenv,通过 pip 安装所有依赖项,然后将其与其余代码一起打包转化为一个稳定的转速。

这种方法有多明智?

I have to deploy a Django application onto a SuSE Linux Enterprise 11 system. Corporate rules say I need to deploy using RPMs only. While I can use ./setup.py bdist_rpm for each dependency, it's not really sane, since RPM doesn't record all of the dependencies yet. Therefore I'd have no real advantage in using RPMs and managing dependencies manually is somewhat cumbersome and I would like to avoid it.

Now I had the following idea: While building a package, I could create a virtualenv, install all my dependencies via pip there and then package it up with the rest of the code into one solid RPM.

How sensible is this approach?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柒七 2024-10-07 14:01:59

我已经使用这种方法大约一年了,效果非常好。

一个问题是您需要检查写入 virtualenv 的 bin 目录的任何 python 脚本中的 bang 行。这些最终将成为构建环境中使用的完整路径名,这可能与您最终安装 virtualenv 的目录不同。因此,您可能需要在 RPM 的安装后添加一些 sed 调用来调整路径。

I've been using this approach for about a year now and it has worked out pretty well.

One gotcha is that you'll want to check out the bang lines in any python scripts written to the virtualenv's bin directory. These will end up being full path names used in your build environment, which probably won't be the same directory where you end up installing the virtualenv. So you may need to add some sed calls in your RPM's postinstall to adjust the paths.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文