Commits

Daniel Holth committed d1d901d

move Python < 2.6 fallback into _markerlib

  • Participants
  • Parent commits b62968c

Comments (0)

Files changed (2)

File _markerlib/__init__.py

-"""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)()

File pkg_resources.py

             
     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 = []