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,15 +2464,41 @@ class DistInfoDistribution(Distribution): ...@@ -2464,15 +2464,41 @@ class DistInfoDistribution(Distribution):
try: try:
return self.__dep_map return self.__dep_map
except AttributeError: except AttributeError:
dm = self.__dep_map = {None: []} self.__dep_map = self._compute_dependencies()
# Including condition expressions return self.__dep_map
# XXX parse condition expressions, extras
reqs = self._parsed_pkg_info.get_all('Requires-Dist') def _compute_dependencies(self):
# extras = self._parsed_pkg_info.get_all('Provides-Extra') or [] """Recompute this distribution's dependencies."""
# for extra,reqs in split_sections(self._get_metadata(name)): def dummy_marker(marker):
# if extra: extra = safe_extra(extra) def marker_fn(environment=None, override=None):
dm.setdefault(None,[]).extend(parse_requirements(reqs)) return True
return dm return marker_fn
try:
from wheel.markers import as_function
except ImportError:
as_function = dummy_marker
dm = self.__dep_map = {None: []}
reqs = []
# Including any condition expressions
for req in self._parsed_pkg_info.get_all('Requires-Dist'):
rs = req.split(';', 1) + ['']
parsed = parse_requirements(rs[0]).next()
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
def requires(self,extras=()): def requires(self,extras=()):
"""List of Requirements needed for this distro if `extras` are used""" """List of Requirements needed for this distro if `extras` are used"""
......
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