Commit b4f2de74 authored by Julien Muchembled's avatar Julien Muchembled Committed by Xavier Thompson

[feat] Install egg from wheel only if explictly required

Egg is installed from wheel when the requested version ends with :whl
parent 906cf88b
...@@ -58,6 +58,8 @@ except ImportError: ...@@ -58,6 +58,8 @@ except ImportError:
BIN_SCRIPTS = 'Scripts' if WINDOWS else 'bin' BIN_SCRIPTS = 'Scripts' if WINDOWS else 'bin'
WHL_DIST = pkg_resources.EGG_DIST + 1
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')
...@@ -487,9 +489,10 @@ class Installer(object): ...@@ -487,9 +489,10 @@ class Installer(object):
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
(dist.precedence == pkg_resources.SOURCE_DIST if source (dist.precedence == pkg_resources.SOURCE_DIST if source
else not (dist.precedence == pkg_resources.DEVELOP_DIST else not (dist.precedence == pkg_resources.DEVELOP_DIST
and {'setup.py', 'pyproject.toml'}.isdisjoint( and {'setup.py', 'pyproject.toml'}.isdisjoint(
...@@ -675,6 +678,9 @@ class Installer(object): ...@@ -675,6 +678,9 @@ class Installer(object):
"""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)
...@@ -682,6 +688,8 @@ class Installer(object): ...@@ -682,6 +688,8 @@ class Installer(object):
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