我正在尝试将 buildout 用于 Python 包,该包在使用时依赖于 2 个扩展模块:dbus-python 和 pygobject。这两个模块都会导致构建失败:dbus-python 缺少 setup.py
文件,而 pygobject
有一个文件,但不鼓励使用 - 相反 < em>configure、make、make install 应该被使用。因此,构建无法在开发环境中设置这些依赖项。
这是我的 buildout.cfg
:
[buildout]
develop = .
parts = eggs
[python]
recipe = zc.recipe.eggs
interpreter = python
eggs = foobar
其中 foobar
包的 setup.py
包含:
install_requires=['dbus-python', 'pygobject'],
在寻找解决方案时,我偶然发现了配方 z3c.recipe.scripts
及其 能够利用系统范围内安装的 Egg。但是,当应用于我的 buildout.cfg
..
[python]
recipe = z3c.recipe.scripts
include-site-packages = true
allowed-eggs-from-site-packages = pygobject, dbus-python
interpreter = python
eggs = foobar
.. 时,它似乎没有效果(仍然失败),尽管两个包(dbus、gobject) 已安装在我的系统 Python 中。当我删除 allowed-eggs..
行时也是如此。
我的问题:我在概念层面上是否遇到了错误,或者我的 buildout.cfg
中是否存在错误?
我知道有 zc.recipe.cmmi
,使用configure、make、make install安装eggs的配方。然而,在我的例子中,简单地引用系统 Python Egg 就足够了。我不需要由构建生成的 100% 可重现的环境。此外,dbus-python 和 pygobject 默认安装在大多数 Linux 桌面系统上,这是 foobar
的使用环境。
I'm trying to use buildout for a Python package which, when used, depends on 2 extension modules: dbus-python and pygobject. Both modules make buildout fail: dbus-python lacks a setup.py
file, while pygobject
has one but whose usage is discouraged -- instead configure, make, make install should be used. So, buildout isn't able to setup these dependencies in the development environment.
Here's my buildout.cfg
:
[buildout]
develop = .
parts = eggs
[python]
recipe = zc.recipe.eggs
interpreter = python
eggs = foobar
where setup.py
for the foobar
package contains:
install_requires=['dbus-python', 'pygobject'],
While looking for a solution, I stumbled upon the recipe z3c.recipe.scripts
and its ability to utilize system-wide installed eggs. However, when applied to my buildout.cfg
..
[python]
recipe = z3c.recipe.scripts
include-site-packages = true
allowed-eggs-from-site-packages = pygobject, dbus-python
interpreter = python
eggs = foobar
.. it appears to have no effect (still fails), although both packages (dbus, gobject) are installed in my system Python. The same is true when I remove the allowed-eggs..
line.
My question: Did I got something wrong here on a conceptional level or is there an error in my buildout.cfg
?
I know there's zc.recipe.cmmi
, a recipe which installs eggs using configure, make, make install. However, simply referencing system Python eggs would be sufficient in my case. I do not need a 100% reproducible environment generated by buildout. Also, dbus-python and pygobject are installed by default on most Linux desktop systems, the environment where foobar
is intended to be used.
发布评论
评论(4)
我还没有获得最新的 1.5.x 构建来使用系统包。有一种方法:固定版本。这样,zc.buildout 1.5.x 就会选择它。
或者,我所做的,您可以使用旧的 1.4.4 构建(您需要一个特殊的 bootstrap.py,请谷歌搜索)与 osc.recipe.sysegg。
我个人会选择 osc.recipe.sysegg 解决方案,因为它很可靠。
I haven't gotten the latest 1.5.x buildouts to work with system packages, too. There is one way: pin the versions. That way, zc.buildout 1.5.x will pick it up.
Alternatively, what I do, you can use the old 1.4.4 buildout (you'll need a special bootstrap.py for that, google it) in combination with osc.recipe.sysegg.
I'd personally go for the osc.recipe.sysegg solution, as that's reliable.
您可能希望为每个表现不佳的 python 发行版使用 CMMI 部分,并为您的
python
部分使用extra-paths
选项,以确保 CMMI 部分包含在蟒蛇路径。You might want to use a CMMI part for each of those poorly behaving python distributions and use the
extra-paths
option for yourpython
part to make sure the CMMI parts are included in the python path.感谢@Rainout 的回答和评论,我找到了问题的实际根源。问题不在于构建或我的配置,而在于 DBus 和 Gobject 的 Python 绑定:这些包不是作为 Egg 分发的,而是作为普通包分发的。
因此,虽然这些包可以通过 PyPI 检索,但它们不能在任何期望 Python 包作为鸡蛋发布的基础设施中使用。实际上,这意味着这些包的依赖项不得在 setup.py 中列出,而是需要以其他方式处理(如果有的话)。
Thanks to @Rainout's answer and comments I found the actual source of my problem. The problem is not in buildout or my configuration but in the Python bindings for DBus and Gobject: these packages aren't distributed as eggs but as plain packages.
So while these packages can be retrieved via PyPI, they cannot be used in any infrastructure which expects Python packages to be shipped as eggs. In practice this means that the dependencies to these packages must not be listed in
setup.py
but need to be handled in some other way (if at all).我发现执行此操作的最佳方法是将 include-site-packages 设置为 true,然后使用 mockedeggs 配方 欺骗 setuptools 认为鸡蛋在安装过程中可用。唯一的缺点是您对站点包中使用的内容没有太多控制权;您可以将 allowed-eggs-from-site-packages 设置为空白以停止使用 Eggs,但所有包都可用。无论如何,这是我的构建的一个片段:
The best way I've found to do this is to set include-site-packages to true, then use the mockedeggs recipe to trick setuptools into thinking the eggs are available during installation. The only downside is you don't have much control over what gets used from site-packages; you can set allowed-eggs-from-site-packages to blank to stop eggs being used, but all packages will be available. Anyway, here's a snippet from my buildout: