Commit 0abf873d authored by Julien Muchembled's avatar Julien Muchembled

Install egg from wheel only if explictly required

Egg is install from wheel the requested version ends with :whl

This replaces:
  6d9b7483 Avoid installing eggs from wheels when possible
  ff2ee218 Do never install from wheels
parent 33ae2583
...@@ -39,11 +39,7 @@ import tempfile ...@@ -39,11 +39,7 @@ import tempfile
import zc.buildout import zc.buildout
import warnings import warnings
_INF = -float('inf')
WHL_DIST = pkg_resources.EGG_DIST + 1 WHL_DIST = pkg_resources.EGG_DIST + 1
def dist_key(dist):
key = dist.precedence
return _INF if key == WHL_DIST else key
warnings.filterwarnings( warnings.filterwarnings(
'ignore', '.+is being parsed as a legacy, non PEP 440, version') 'ignore', '.+is being parsed as a legacy, non PEP 440, version')
...@@ -549,9 +545,10 @@ class Installer: ...@@ -549,9 +545,10 @@ 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)
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 and (dist.precedence == WHL_DIST) == wheel and
((not source) or ((not source) or
(dist.precedence == pkg_resources.SOURCE_DIST) (dist.precedence == pkg_resources.SOURCE_DIST)
) )
...@@ -593,7 +590,8 @@ class Installer: ...@@ -593,7 +590,8 @@ class Installer:
): ):
return dist return dist
return max(dists, key=dist_key) best.sort()
return best[-1]
def _fetch(self, dist, tmp, download_cache): def _fetch(self, dist, tmp, download_cache):
if (download_cache if (download_cache
...@@ -772,6 +770,9 @@ class Installer: ...@@ -772,6 +770,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:
wheel = constraint.endswith(':whl')
if wheel:
constraint = constraint[:-4]
try: try:
requirement = _constrained_requirement(constraint, requirement = _constrained_requirement(constraint,
requirement) requirement)
...@@ -779,6 +780,8 @@ class Installer: ...@@ -779,6 +780,8 @@ 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