summaryrefslogtreecommitdiff
path: root/setuptools/wheel.py
diff options
context:
space:
mode:
Diffstat (limited to 'setuptools/wheel.py')
-rw-r--r--setuptools/wheel.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/setuptools/wheel.py b/setuptools/wheel.py
index aab7ed05..ff29e2fb 100644
--- a/setuptools/wheel.py
+++ b/setuptools/wheel.py
@@ -2,6 +2,7 @@
import email
import itertools
+import functools
import os
import posixpath
import re
@@ -27,7 +28,13 @@ WHEEL_NAME = re.compile(
NAMESPACE_PACKAGE_INIT = \
"__import__('pkg_resources').declare_namespace(__name__)\n"
-_supported_tags = None
+
+@functools.lru_cache(maxsize=None)
+def _get_supported_tags():
+ # We calculate the supported tags only once, otherwise calling
+ # this method on thousands of wheels takes seconds instead of
+ # milliseconds.
+ return set((t.interpreter, t.abi, t.platform) for t in sys_tags())
def unpack(src_dir, dst_dir):
@@ -85,13 +92,7 @@ class Wheel:
def is_compatible(self):
'''Is the wheel compatible with the current platform?'''
- global _supported_tags
- if _supported_tags is None:
- # We calculate the supported tags only once, otherwise calling
- # this method on thousands of wheels takes seconds instead of
- # milliseconds.
- _supported_tags = set(
- (t.interpreter, t.abi, t.platform) for t in sys_tags())
+ _supported_tags = _get_supported_tags()
return next((True for t in self.tags() if t in _supported_tags), False)
def egg_name(self):