Version ranges in buildout.cfg

341 views Asked by At

I have a project for which I'd like to maintain the most recent stable version of Django 1.7 (presently at 1.7.1, but that may change).

In setup.py, I've specified the version range like this:

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

In buildout.cfg, I've specified the same:

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

For ipython, this works great, but unfortunately Django doesn't seem to like it:

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')

Why is it failing, and how can I fix it?

1

There are 1 answers

0
Reinout van Rees On BEST ANSWER

A version spec with something = <= 1234 is invalid. Both an = and a <= isn't the right syntax.

I'd treat the problem differently. You use your setup.py's install_requires already to restrict buildout a version between 1.7 and 1.8. Buildout will respect that requirement, so you don't need to duplicate it in the buildout config.

What buildout's version pinning is for is exactly that: pinning to one specific version. Either you let buildout pick what it wants or you tell it to pick an exact version.

The way I use it is to add a show-picked-versions = true option to the [buildout] part. Buildout will then print out a list of versions it picked. I then copy/paste that list to [versions]. That way you get a repeatable build and a nice speed improvement as buildout doesn't have to search pypi for those versions again.