使用 zc.buildout 指定自定义 PYTHON_EGG_CACHE 目录?

发布于 2024-09-29 08:00:10 字数 297 浏览 1 评论 0原文

我们在尝试部署许多使用 zc.buildout 的项目时遇到了问题 - 具体来说,我们发现他们希望将 PYTHON_EGG_CACHE 目录放在整个节目中。我们希望以某种方式将此目录设置为与内置项目同一级别的目录,在其中可以找到 eggs

网上有人提到这可以为 Plone 项目完成,但是没有 Plone 是否可以做到这一点?

是否有一些方法可以设置环境变量,以便我们可以在 ./bin 中设置 PYTHON_EGG_CACHE 可执行文件?

We're having problems when trying to deploy a number of projects which use zc.buildout - specifically we're finding that they want to put their PYTHON_EGG_CACHE directories all over the show. We'd like to somehow set this directory to one at the same level as the built-out project, where eggs can be found.

There is some mention online that this can be done for Plone projects, but is it possible to do this without Plone?

Are there some recipes that can set up an environment variable so we can set the PYTHON_EGG_CACHE executable files in ./bin?

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

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

发布评论

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

评论(2

燕归巢 2024-10-06 08:00:10

PYTHON_EGG_CACHE 仅用于压缩鸡蛋,你最好的选择是让 zc.buildout 安装所有需要解压缩的鸡蛋:

[buildout]
...
unzip = true

如果你的系统 python 安装了压缩鸡蛋,但仍然需要解压缩才能访问资源,并且在脚本中设置 PYTHON_EGG_CACHE 是你唯一的选择选项(而不是为用户设置环境变量),您可以尝试使用 zc.recipe.egg 的 initialization 选项将任意 Python 代码添加到脚本中:

[a-part]
recipe = zc.recipe.egg
...
initialization = 
    import os
    os.environ['PYTHON_EGG_CACHE'] = '/tmp/python_eggs'

The PYTHON_EGG_CACHE is only used for zipped eggs, your best bet is to have zc.buildout install all required eggs unzipped:

[buildout]
...
unzip = true

If your system python has zipped eggs installed that still require unzipping for resource access, and setting the PYTHON_EGG_CACHE in your scripts is your only option (as opposed to setting the environment variable for your user), you could try to use the initialization option of zc.recipe.egg to add arbitrary Python code to your scripts:

[a-part]
recipe = zc.recipe.egg
...
initialization = 
    import os
    os.environ['PYTHON_EGG_CACHE'] = '/tmp/python_eggs'
八巷 2024-10-06 08:00:10

我不确定你的意思。您通常拥有的三个选项:

  • 默认情况下,Buildout 将 Eggs 存储在 buildout 目录内名为 eggs/ 的目录中。

  • 您可以将 buildout.cfg 的 [buildout] 部分中的 eggs-dir 变量设置为某个目录。只需告诉它把它们放在哪里即可。

  • 您还可以在主目录内的 .buildout/defaults.cfg 中设置相同的选项。这样您就可以为所有项目设置默认值。方便地将所有鸡蛋存储在一个地方:例如,这可以节省大量下载时间。

其中之一(尤其是最后一个)能实现您想要的吗?

并且:不要在生成的 bin/* 文件中乱扔鸡蛋。让buldout去摘蛋,这就是它的目的。

I'm not sure what you mean. Three options that you normally have:

  • Buildout, by default, stores the eggs in a directory called eggs/ inside your buildout directory.

  • You can set the eggs-dir variable inside your buildout.cfg's [buildout] section to some directory. Just tell it where to place them.

  • You can also set that very same option in .buildout/defaults.cfg inside your home directory. That way you can set a default for all your projects. Handy for storing all your eggs in one place: that can save a lot of download time, for instance.

Does one of those (especially the last one) accomplish what you want?

And: don't muck around with eggs in the generated bin/* files. Let buldout pick the eggs, that's its purpose.

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