Skip to content

Commit 26416a4

Browse files
committed
Prefer find_spec to less invasively detect the presence of setuptools and wheel. Fixes #37.
1 parent 815ebae commit 26416a4

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

templates/default.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ def include_setuptools(args):
4949
"""
5050
cli = not args.no_setuptools
5151
env = not os.environ.get("PIP_NO_SETUPTOOLS")
52-
try:
53-
importlib.import_module("setuptools")
54-
absent = False
55-
except ImportError:
56-
absent = True
52+
absent = not importlib.util.find_spec("setuptools")
5753
return cli and env and absent
5854

5955

@@ -63,11 +59,7 @@ def include_wheel(args):
6359
"""
6460
cli = not args.no_wheel
6561
env = not os.environ.get("PIP_NO_WHEEL")
66-
try:
67-
importlib.import_module("wheel")
68-
absent = False
69-
except ImportError:
70-
absent = True
62+
absent = not importlib.util.find_spec("wheel")
7163
return cli and env and absent
7264

7365

0 commit comments

Comments
 (0)