Commit 55db8537 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 d64737e5
......@@ -538,13 +538,31 @@ class Installer(object):
return max(dists)
# 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
dists = [d for d in index[requirement.key] 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_key = requirement.key.replace('.', '-')
if wkrd_key != requirement.key:
dists.extend(
d.clone(project_name=requirement.project_name)
for d in index[wkrd_key]
if d.key == wkrd_key # for thoroughness
and d.version in requirement
)
if not dists:
# Nothing is available.
return None
# Filter the available dists for the requirement and source flag
dists = [dist for dist in index[requirement.key]
if dist in requirement and filter_precedence(dist)]
# Filter the available dists for the source flag.
dists = [dist for dist in dists if filter_precedence(dist)]
# If we prefer final dists, filter for final and use the
# 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