aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/importlib-metadata/py3/patches/02-fix-for-support-system-python.patch
blob: 0babc060999cd58dbda97fd88fa76f95237e56ca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
--- contrib/python/importlib-metadata/py3/importlib_metadata/__init__.py	(index)
+++ contrib/python/importlib-metadata/py3/importlib_metadata/__init__.py	(working tree)
@@ -31,4 +31,10 @@ from importlib.abc import MetaPathFinder
 from typing import List, Mapping, Optional
 
+try:
+    import __res as res
+    ARCADIA = True
+except ImportError:
+    ARCADIA = False
+
 
 __all__ = [
@@ -712,3 +718,3 @@ class Prepared:
 
-@install
+@install(ARCADIA == False)
 class MetadataPathFinder(NullFinder, DistributionFinder):
@@ -813,3 +819,3 @@ class ArcadiaDistribution(Distribution):
 
-@install
+@install(ARCADIA == True)
 class ArcadiaMetadataFinder(NullFinder, DistributionFinder):
--- contrib/python/importlib-metadata/py3/importlib_metadata/_compat.py	(index)
+++ contrib/python/importlib-metadata/py3/importlib_metadata/_compat.py	(working tree)
@@ -15,11 +15,14 @@ except ImportError:  # pragma: no cover
-def install(cls):
-    """
-    Class decorator for installation on sys.meta_path.
-
-    Adds the backport DistributionFinder to sys.meta_path and
-    attempts to disable the finder functionality of the stdlib
-    DistributionFinder.
-    """
-    sys.meta_path.append(cls())
-    disable_stdlib_finder()
-    return cls
+def install(flag):
+    def dec_install(cls):
+        """
+        Class decorator for installation on sys.meta_path.
+
+        Adds the backport DistributionFinder to sys.meta_path and
+        attempts to disable the finder functionality of the stdlib
+        DistributionFinder.
+        """
+        if flag:
+            sys.meta_path.append(cls())
+            disable_stdlib_finder()
+        return cls
+    return dec_install