Skip to content

Commit 30d152c

Browse files
committed
[GR-37034] fix setuptools-60.9 compat
PullRequest: graalpython/2156
2 parents a47ca66 + 903a559 commit 30d152c

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
diff --git a/_distutils_hack/__init__.py b/_distutils_hack/__init__.py
2+
index c6f7de6..194293b 100644
3+
--- a/_distutils_hack/__init__.py
4+
+++ b/_distutils_hack/__init__.py
5+
@@ -40,7 +40,9 @@ def enabled():
6+
"""
7+
Allow selection of distutils by environment variable.
8+
"""
9+
- which = os.environ.get('SETUPTOOLS_USE_DISTUTILS', 'local')
10+
+ # which = os.environ.get('SETUPTOOLS_USE_DISTUTILS', 'local')
11+
+ # GraalVM change: default to stdlib
12+
+ which = os.environ.get('SETUPTOOLS_USE_DISTUTILS', 'stdlib')
13+
return which == 'local'
14+
15+
16+
@@ -163,7 +165,8 @@ DISTUTILS_FINDER = DistutilsMetaFinder()
17+
18+
19+
def add_shim():
20+
- DISTUTILS_FINDER in sys.meta_path or insert_shim()
21+
+ if enabled():
22+
+ DISTUTILS_FINDER in sys.meta_path or insert_shim()
23+
24+
25+
class shim:
26+
@@ -175,7 +178,8 @@ class shim:
27+
28+
29+
def insert_shim():
30+
- sys.meta_path.insert(0, DISTUTILS_FINDER)
31+
+ if enabled():
32+
+ sys.meta_path.insert(0, DISTUTILS_FINDER)
33+
34+
35+
def remove_shim():
36+
diff --git a/setuptools/_vendor/importlib_metadata/_compat.py b/setuptools/_vendor/importlib_metadata/_compat.py
37+
index ef3136f..612377b 100644
38+
--- a/setuptools/_vendor/importlib_metadata/_compat.py
39+
+++ b/setuptools/_vendor/importlib_metadata/_compat.py
40+
@@ -36,7 +36,7 @@ def disable_stdlib_finder():
41+
def matches(finder):
42+
return getattr(
43+
finder, '__module__', None
44+
- ) == '_frozen_importlib_external' and hasattr(finder, 'find_distributions')
45+
+ ) in ('_frozen_importlib_external', 'importlib._bootstrap_external') and hasattr(finder, 'find_distributions')
46+
47+
for finder in filter(matches, sys.meta_path): # pragma: nocover
48+
del finder.find_distributions

0 commit comments

Comments
 (0)