diff options
| -rw-r--r-- | _markerlib/__init__.py | 18 | ||||
| -rw-r--r-- | pkg_resources.py | 11 |
2 files changed, 17 insertions, 12 deletions
diff --git a/_markerlib/__init__.py b/_markerlib/__init__.py index a7b26037..d13e4d5a 100644 --- a/_markerlib/__init__.py +++ b/_markerlib/__init__.py @@ -1,2 +1,16 @@ -"""Used by pkg_resources to interpret PEP 345 environment markers.""" -from _markerlib.markers import default_environment, compile, interpret, as_function +try: + import ast + from markerlib.markers import default_environment, compile, interpret +except ImportError: + if 'ast' in globals(): + raise + def default_environment(): + return {} + def compile(marker): + def marker_fn(environment=None, override=None): + # 'empty markers are True' heuristic won't install extra deps. + return not marker.strip() + marker_fn.__doc__ = marker + return marker_fn + def interpret(marker, environment=None, override=None): + return compile(marker)() diff --git a/pkg_resources.py b/pkg_resources.py index 060db644..a5a10eb4 100644 --- a/pkg_resources.py +++ b/pkg_resources.py @@ -2482,16 +2482,7 @@ class DistInfoDistribution(Distribution): def _compute_dependencies(self): """Recompute this distribution's dependencies.""" - def dummy_marker(marker): - def marker_fn(environment=None, override=None): - # 'empty markers are True' heuristic won't install extra deps. - return not marker.strip() - marker_fn.__doc__ = marker - return marker_fn - try: - from _markerlib import compile as compile_marker - except ImportError: - compile_marker = dummy_marker + from _markerlib import compile as compile_marker dm = self.__dep_map = {None: []} reqs = [] |
