Commit ac2bc6ee authored by Daniel Holth's avatar Daniel Holth

implement environment markers

--HG--
branch : distribute
extra : rebase_source : 16af7be95f787ab5de573388270b97cda6c9cea7
parent ec81bfe5
...@@ -15,7 +15,6 @@ method. ...@@ -15,7 +15,6 @@ method.
import sys, os, zipimport, time, re, imp, types import sys, os, zipimport, time, re, imp, types
from urlparse import urlparse, urlunparse from urlparse import urlparse, urlunparse
from email.parser import Parser
try: try:
frozenset frozenset
...@@ -2456,6 +2455,7 @@ class DistInfoDistribution(Distribution): ...@@ -2456,6 +2455,7 @@ class DistInfoDistribution(Distribution):
try: try:
return self._pkg_info return self._pkg_info
except AttributeError: except AttributeError:
from email.parser import Parser
self._pkg_info = Parser().parsestr(self.get_metadata(self.PKG_INFO)) self._pkg_info = Parser().parsestr(self.get_metadata(self.PKG_INFO))
return self._pkg_info return self._pkg_info
...@@ -2464,14 +2464,40 @@ class DistInfoDistribution(Distribution): ...@@ -2464,14 +2464,40 @@ class DistInfoDistribution(Distribution):
try: try:
return self.__dep_map return self.__dep_map
except AttributeError: except AttributeError:
self.__dep_map = self._compute_dependencies()
return self.__dep_map
def _compute_dependencies(self):
"""Recompute this distribution's dependencies."""
def dummy_marker(marker):
def marker_fn(environment=None, override=None):
return True
return marker_fn
try:
from wheel.markers import as_function
except ImportError:
as_function = dummy_marker
dm = self.__dep_map = {None: []} dm = self.__dep_map = {None: []}
# Including condition expressions
# XXX parse condition expressions, extras reqs = []
reqs = self._parsed_pkg_info.get_all('Requires-Dist') # Including any condition expressions
# extras = self._parsed_pkg_info.get_all('Provides-Extra') or [] for req in self._parsed_pkg_info.get_all('Requires-Dist'):
# for extra,reqs in split_sections(self._get_metadata(name)): rs = req.split(';', 1) + ['']
# if extra: extra = safe_extra(extra) parsed = parse_requirements(rs[0]).next()
dm.setdefault(None,[]).extend(parse_requirements(reqs)) parsed.marker_fn = as_function(rs[1].strip())
reqs.append(parsed)
def reqs_for_extra(extra):
for req in reqs:
if req.marker_fn(override={'extra':extra}):
yield req
common = set(reqs_for_extra(None))
dm[None].extend(common)
for extra in self._parsed_pkg_info.get_all('Provides-Extra'):
dm[extra] = list(set(reqs_for_extra(extra)) - common)
return dm return dm
def requires(self,extras=()): def requires(self,extras=()):
......
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