Commit 99412eac authored by Xavier Thompson's avatar Xavier Thompson

[wkrd] Workaround package index after PEP 625

Since PEP 625, sdist filenames replace . and - in the project name by
_, such as e.g. zc.buildout==3.0.1 yielding zc_buildout-3.0.1.tar.gz.

However, when looking up available dists in a package index, when an
sdist with such a normalized filename is found, setuptools interprets
the filename by replacing _ with - and uses that as the dist's name;
e.g. zc_buildout-3.0.1.tar.gz yields zc-buildout. This causes lookups
for the name with . (e.g.: zc.buildout) to fail.

Workaround by also looking up the name with . replaced by _, and then
fixing the names of found dists back to expected name.
parent 58c08402
...@@ -538,13 +538,31 @@ class Installer(object): ...@@ -538,13 +538,31 @@ class Installer(object):
return max(dists) return max(dists)
# initialize out index for this project: # initialize out index for this project:
if index.obtain(requirement) is None: index.obtain(requirement) # ignore result
# setuptools may get mixed-up between . and - in project names
# due to . and - being turned into _ in sdist archive names, but
# _ in archive names being translated to - during index lookup.
# See https://github.com/buildout/buildout/issues/647
project_name = requirement.project_name
dists = [d for d in index[project_name] if d in requirement]
# Workaround by also looking up the name with - instead of .
# and fixing the name of dists found back to . instead of -.
wkrd_name = project_name.replace('.', '-')
if wkrd_name != project_name:
dists.extend(
d.clone(project_name=project_name)
for d in index[wkrd_name]
if d.version in requirement
)
if not dists:
# Nothing is available. # Nothing is available.
return None return None
# Filter the available dists for the requirement and source flag # Filter the available dists for the source flag.
dists = [dist for dist in index[requirement.project_name] dists = [dist for dist in dists if filter_precedence(dist)]
if dist in requirement and filter_precedence(dist)]
# If we prefer final dists, filter for final and use the # If we prefer final dists, filter for final and use the
# result if it is non empty. # result if it is non empty.
......
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