Commit 93c61dd3 authored by Reinout van Rees's avatar Reinout van Rees

Added normalizing of distribution names in [versions]

The Python package index is case-insensitive. Both
http://pypi.python.org/simple/Django/ and
http://pypi.python.org/simple/dJaNgO/ work. And distributions aren't always
naming themselves consistently case-wise. So all version names are normalized
and case differences won't impact the pinning.
parent 1dc6e8e9
......@@ -171,7 +171,10 @@ class Installer:
self._index = _get_index(index, links, self._allow_hosts)
if versions is not None:
self._versions = versions
# Normalize all versions to lowercase. PyPI is case-insensitive
# and not all distributions are consistent in their own naming.
self._versions = dict([(k.lower(), v)
for (k, v) in versions.items()])
def _satisfied(self, req, source=None):
dists = [dist for dist in self._env[req.project_name] if dist in req]
......@@ -551,17 +554,9 @@ class Installer:
def _constrain(self, requirement):
constraint = self._versions.get(requirement.project_name)
# REINOUT: use the line below, with the .lower().
# Alternative is perhaps to use a self._versions that always uses
# lowercase keys.
# Actually, this lower-casing happens in buildout-versions, so we need
# to do it too. See buildout.py.
# constraint = self._versions.get(requirement.project_name.lower())
constraint = self._versions.get(requirement.project_name.lower())
if constraint:
requirement = _constrained_requirement(constraint, requirement)
return requirement
def install(self, specs, working_set=None):
......@@ -696,7 +691,8 @@ class Installer:
def default_versions(versions=None):
old = Installer._versions
if versions is not None:
Installer._versions = versions
Installer._versions = dict([(k.lower(), v)
for (k, v) in versions.items()])
return old
def download_cache(path=-1):
......
......@@ -280,6 +280,30 @@ When everything is pinned, no output is generated:
Updating foo.
recipe v2
The Python package index is case-insensitive. Both
http://pypi.python.org/simple/Django/ and
http://pypi.python.org/simple/dJaNgO/ work. And distributions aren't always
naming themselves consistently case-wise. So all version names are normalized
and case differences won't impact the pinning:
>>> write('buildout.cfg',
... '''
... [buildout]
... parts = foo
... find-links = %s
... show-picked-versions = true
...
... [versions]
... distriBUTE = 0.6.34
... Spam = 2
...
... [foo]
... recipe = spam
... ''' % join('recipe', 'dist'))
>>> print_(system(buildout), end='') # doctest: +ELLIPSIS
Updating foo.
recipe v2
Controlling the python version
-------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment