Commit 7fa21de5 authored by Kirill Smelkov's avatar Kirill Smelkov

Accept both tarballs and pure-python wheels as sources

This redoes 0abf873d (Install egg from wheel only if explictly required),
because that switch to install wheels only when explicitly requested
broke things in several places[1,2]. We can avoid such breakage if
instead of rejecting all wheels by default, we accept wheels, but allow
only pure-python wheels to be installed.

As nexedi/slapos!1026 (comment 138639)
shows detecting whether a dist is pure-python wheel is just

	(dist.precedence == WHL_DIST and dist.platform is None)

So let's use this and rework egg installer accordingly.

This patch is completely untested. However the way to check whether a
wheel is source-only was tested at nexedi/slapos!1026 (comment 138639).

If this patch is accepted and new slapos.buildout release is made, then
all :whl usage in slapos.git can be dropped.

/cc @tomo, @jerome, @jm

[1] nexedi/slapos!1026
[2] nexedi/slapos!1026 (comment 138590)
parent 6cec641f
...@@ -561,12 +561,13 @@ class Installer: ...@@ -561,12 +561,13 @@ class Installer:
return None return None
# Filter the available dists for the requirement and source flag # Filter the available dists for the requirement and source flag
wheel = getattr(requirement, 'wheel', False) # Accept tarballs and pure-python wheels as sources
dists = [dist for dist in index[requirement.project_name] dists = [dist for dist in index[requirement.project_name]
if ((dist in requirement) if ((dist in requirement)
and (dist.precedence == WHL_DIST) == wheel and and
((not source) or ((not source) or
(dist.precedence == pkg_resources.SOURCE_DIST) ((dist.precedence == pkg_resources.SOURCE_DIST) or
(dist.precedence == WHL_DIST and dist.platform is None))
) )
) )
] ]
...@@ -786,6 +787,9 @@ class Installer: ...@@ -786,6 +787,9 @@ class Installer:
"""Return requirement with optional [versions] constraint added.""" """Return requirement with optional [versions] constraint added."""
constraint = self._versions.get(requirement.project_name.lower()) constraint = self._versions.get(requirement.project_name.lower())
if constraint: if constraint:
# accept `<egg>:whl` as just `<egg>` for backward compatibility
# because once we were handling :whl suffix as explicit request to
# install via wheel and parts of slapos still use this.
wheel = constraint.endswith(':whl') wheel = constraint.endswith(':whl')
if wheel: if wheel:
constraint = constraint[:-4] constraint = constraint[:-4]
...@@ -796,8 +800,6 @@ class Installer: ...@@ -796,8 +800,6 @@ class Installer:
logger.info(self._version_conflict_information( logger.info(self._version_conflict_information(
requirement.project_name.lower())) requirement.project_name.lower()))
raise raise
if wheel:
requirement.wheel = True
return requirement return requirement
......
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