1

具体来说,这是我遇到的情况:

我正在使用 zc.buildout 安装需要 pymssql 的应用程序。Pymssql 需要 Cython 才能正确安装。但是,我不想修改我的运行环境,所以我想做类似的事情:

  1. 安装 Cython
  2. 将 Cython 加载到构建中
  3. 安装 Pymssql。

我认为 Buildout 已经这样做了,但它看起来更像是检查 setup.cfg 以确保安装了任何明确声明为必要的内容。目前我的扩建看起来像:

[buildout]
  parts = required-eggs
  ...

[required-eggs]
  eggs = Cython
         pymssql

Cython 安装良好。不幸的是 pymssql 没有:

    return self.build_and_install(setup_script, setup_base)
  File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1101, in build_and_install
self.run_setup(setup_script, setup_base, args)
  File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1090,  in run_setup
run_setup(setup_script, args)
  File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 29, in run_setup
lambda: execfile(
  File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 70, in run
return func()
  File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 31, in <lambda>
{'__file__':setup_script, '__name__':'__main__'}
  File "setup.py", line 41, in <module>
ImportError: No module named Cython.Distutils

因此,我认为 Cython 是作为鸡蛋安装的,但没有加载到正在运行 buildout 的 python 进程中。buildout 中是否有一些配置可以让我这样做?

4

1 回答 1

2

pymssql包 alreade 将egg声明Cythonsetup_requires依赖项,但没有给distutils时间安装它。简单地列出它们setup_requires但仍然尝试在模块范围内导入它们(就像pymssql那样)是不够的。

setup.py必须重新构建模块以在解析该行并且那里列出的依赖项可用之前不导入依赖项Cythonsetup_requires基本上,它需要定义自己的build_cmd类,当实例化时,导入Cython依赖项并在当时而不是之前包装该类。

It may be that you could create a custom buildout recipe that uses Cython as a dependency that then can install the pymssql dependency with Cython installed by buildout as it executes your recipe, but that is a plaster on this wound that pymssql should deal with, really.

于 2012-02-25T11:50:55.613 回答