buildout MercurialRecipe 在多次导入时出错

1 投票
1 回答
725 浏览
提问于 2025-04-16 10:49

我一直在尝试导入几个包,这些包其实是我正在构建的一个蛋(egg)的依赖项。因为这些蛋不在奶酪商店(cheese store)上,所以我不能在我的 setup.py 脚本中使用 install_requires = ['pack1', 'pack2']。所以我试着用以下方式把它们添加到我的 buildout 配置中:

  1 [buildout]
  2 develop = .
  3 parts = 
  4     python
  5     pack1
  6     pack2
  7 
  8 extra_paths = ${pack1:location}/src/
  9     ${pack2:location}/src/
 10 
 11 [python]
 12 recipe = zc.recipe.egg
 13 eggs = myegg
 14 extra-paths = 
 15     ${buildout:extra_paths}
 16 
 17 interpreter = python
 18 
 19 [pack1]
 20 recipe = mercurialrecipe
 21 repository = https://repo.xxx.com/hg/pack1/
 22 
 23 [pack2]
 24 recipe = mercurialrecipe
 25 repository = https://repo.xxx.com/hg/pack2/

我可能这样做不太对——我刚开始接触 buildout。当我运行我的 bin/buildout 时,出现了以下错误:

Updating python.
Updating pack1.
pack1: Pulling repository https://repo.xxx.com/hg/pack1/ and updating /home/martin/proj1/parts/pack1
pulling from https://repo.xxx.com/hg/pack1/
searching for changes
no changes found
Installing pack2.
pack2: Cloning repository https://repo.xxx.com/hg/pack2/ to /home/martin/proj1/parts/pack2
While:
  Installing pack2.

    An internal error occurred due to a bug in either zc.buildout or in a
    recipe being used:
    Traceback (most recent call last):
      File "/home/martin/proj1/eggs/zc.buildout-1.5.2-py2.6.egg/zc/buildout/buildout.py", line 1805, in main
        getattr(buildout, command)(args)
      File "/home/martin/proj1/eggs/zc.buildout-1.5.2-py2.6.egg/zc/buildout/buildout.py", line 584, in install
        installed_files = self[part]._call(recipe.install)
      File "/home/martin/proj1/eggs/zc.buildout-1.5.2-py2.6.egg/zc/buildout/buildout.py", line 1297, in _call
        return f()
      File "build/bdist.linux-x86_64/egg/mercurialrecipe/__init__.py", line 50, in install
        commands.clone(ui.ui(), get_repository(self.source), self.destination)
      File "build/bdist.linux-x86_64/egg/mercurialrecipe/__init__.py", line 18, in get_repository
        return hg.repository(ui.ui(), location)
      File "/usr/lib/python2.6/site-packages/mercurial-1.7.3-py2.6-linux-x86_64.egg/mercurial/hg.py", line 96, in repository
        repo = _lookup(path).instance(ui, path, create)
      File "/usr/lib/python2.6/site-packages/mercurial-1.7.3-py2.6-linux-x86_64.egg/mercurial/httprepo.py", line 203, in instance
        return statichttprepo.instance(ui, "static-" + path, create)
      File "/usr/lib/python2.6/site-packages/mercurial-1.7.3-py2.6-linux-x86_64.egg/mercurial/statichttprepo.py", line 146, in instance
        return statichttprepository(ui, path[7:])

如果我把 pack1 和 pack2 的顺序调换,那么 pack2 就会被安装。基本上它们两个都能正常工作,但一旦我尝试同时获取这两个包,就会出问题。

提前谢谢你们。
马丁

1 个回答

3

我建议你使用 mr.developer 来处理在 buildout 中的外部版本控制管理的依赖。mr.developer 让你可以从 Mercurial、Git、Bazaar、Darcs、Subversion 甚至 CVS 的仓库中拉取依赖(无论是 eggs 还是其他形式)。你可以把这些依赖当作开发用的 eggs,其他的 Python eggs 可以在 setup.py 中依赖它们。

要使用 mr.developer,你需要把它添加为 buildout 的扩展:

[buildout]
extensions = mr.developer

你可以通过一个 [sources] 部分来告诉 mr.developer 资源的信息:

[sources]
pack1 = hg https://repo.xxx.com/hg/pack1/
pack2 = hg https://repo.xxx.com/hg/pack2/

使用 mr.developer 后,你会得到一个命令行工具来管理这些仓库;你可以检出它们、更新它们,最重要的是,可以把它们构建成开发用的 eggs,以便在 buildout 中使用。

为了自动检出这些源并将它们构建为开发用的 eggs,你需要在 [buildout] 部分的 auto-checkout 选项中列出它们:

[buildout]
extensions = mr.developer
auto-checkout =
    pack1
    pack2

当你运行 buildout 时,pack1 和 pack2 会被自动检出,构建成 eggs,并在其他地方作为依赖使用。所以如果在某个 eggs 行中列出了 'pack1' 或 'pack2',或者作为其他 egg 在 setup.py 中的依赖,zc.buildout 会选择 mr.developer 检出的版本。

bin/developer 命令行工具让你可以完全控制这些选项,详细信息请查看 mr.developer 的 PyPI 页面

撰写回答