版本范围在buildout.cfg中

时间:2014-11-20 20:09:42

标签: python buildout

我有一个项目,我希望维护最新的Django 1.7稳定版本(目前为1.7.1,但可能会有所改变)。

setup.py中,我已经指定了这样的版本范围:

setup(
    # ...
    install_requires = ['setuptools',
        'django >= 1.7, < 1.8',
    ],
)

buildout.cfg中,我指定了相同的内容:

[versions]
django = >= 1.7, < 1.8
ipython = >= 2.3.1, < 3.0.0

对于ipython,这很有效,但不幸的是Django似乎不喜欢它:

Got Django 1.7.1.
Uninstalling ipython_section.
Installing python_section.
While:
  Installing python_section.

An internal error occurred due to a bug in either zc.buildout or in a
recipe being used:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/zc/buildout/buildout.py", line 1942, in main
    getattr(buildout, command)(args)
  File "/usr/local/lib/python2.7/dist-packages/zc/buildout/buildout.py", line 622, in install
    installed_files = self[part]._call(recipe.install)
  File "/usr/local/lib/python2.7/dist-packages/zc/buildout/buildout.py", line 1366, in _call
    return f()
  File "/home/tk/thunderdome/eggs/zc.recipe.egg-2.0.1-py2.7.egg/zc/recipe/egg/egg.py", line 126, in install
    reqs, ws = self.working_set()
  File "/home/tk/thunderdome/eggs/zc.recipe.egg-2.0.1-py2.7.egg/zc/recipe/egg/egg.py", line 84, in working_set
    allow_hosts=self.allow_hosts)
  File "/usr/local/lib/python2.7/dist-packages/zc/buildout/easy_install.py", line 812, in install
    return installer.install(specs, working_set)
  File "/usr/local/lib/python2.7/dist-packages/zc/buildout/easy_install.py", line 644, in install
    requirement = self._constrain(requirement)
  File "/usr/local/lib/python2.7/dist-packages/zc/buildout/easy_install.py", line 603, in _constrain
    requirement = _constrained_requirement(constraint, requirement)
  File "/usr/local/lib/python2.7/dist-packages/zc/buildout/easy_install.py", line 1400, in _constrained_requirement
    _constrained_requirement_constraint(constraint, requirement)
  File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 2786, in parse
    reqs = list(parse_requirements(s))
  File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 2714, in parse_requirements
    "version spec")
  File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 2679, in scan_list
    raise ValueError(msg, line, "at", line[p:])
ValueError: ('Expected version spec in', 'django[]>=1.7,,>=1.7,<1.8', 'at', ',>=1.7,<1.8')

为什么会失败,我该如何解决?

1 个答案:

答案 0 :(得分:3)

something = <= 1234的版本规范无效。 =<=都不是正确的语法。

我会以不同的方式对待问题。您已使用setup.py的{​​{1}}限制扩展版本介于1.7和1.8之间。 Buildout将尊重该要求,因此您无需在buildout配置中复制它。

buildout的版本固定版本恰恰是:固定到一个特定版本。要么让buildout选择它想要的东西,要么告诉它选择一个确切的版本。

我使用它的方法是在install_requires部分添加show-picked-versions = true选项。然后,Buildout将打印出它所选择的版本列表。然后我将该列表复制/粘贴到[buildout]。这样你就可以获得可重复的构建一个很好的速度提升,因为buildout不必再为这些版本搜索pypi。