summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnderson Bravalheri <andersonbravalheri@gmail.com>2023-03-08 00:07:13 +0000
committerAnderson Bravalheri <andersonbravalheri@gmail.com>2023-03-08 00:07:21 +0000
commit8961851931e0bb92c7d91411d6bdcf0c98ca9767 (patch)
treef6ab86e73ac9fc987afdb02399a7961a9e6815a9
parent8af6bd4818558e4e4427e730ede8bc7ba17ca000 (diff)
downloadpython-setuptools-git-8961851931e0bb92c7d91411d6bdcf0c98ca9767.tar.gz
Simplify changes targeting sys_tags cache
-rw-r--r--setuptools/tests/test_wheel.py21
-rw-r--r--setuptools/wheel.py5
2 files changed, 9 insertions, 17 deletions
diff --git a/setuptools/tests/test_wheel.py b/setuptools/tests/test_wheel.py
index 934cf7f3..559e16d7 100644
--- a/setuptools/tests/test_wheel.py
+++ b/setuptools/tests/test_wheel.py
@@ -609,20 +609,13 @@ def test_wheel_no_dist_dir():
def test_wheel_is_compatible(monkeypatch):
def sys_tags():
- for t in parse_tag('cp36-cp36m-manylinux1_x86_64'):
- yield t
- monkeypatch.setattr('setuptools.wheel.sys_tags', sys_tags)
- # Clear the supported tags cache, otherwise the sys_tags monkeypatch
- # has no effect.
- setuptools.wheel._supported_tags.cache_clear()
- try:
- assert Wheel(
- 'onnxruntime-0.1.2-cp36-cp36m-manylinux1_x86_64.whl'
- ).is_compatible()
- finally:
- # Clear the cache again, otherwise the sys_tags monkeypatch
- # is still in effect for the rest of the tests.
- setuptools.wheel._supported_tags.cache_clear()
+ return {
+ (t.interpreter, t.abi, t.platform)
+ for t in parse_tag('cp36-cp36m-manylinux1_x86_64')
+ }
+ monkeypatch.setattr('setuptools.wheel._get_supported_tags', sys_tags)
+ assert Wheel(
+ 'onnxruntime-0.1.2-cp36-cp36m-manylinux1_x86_64.whl').is_compatible()
def test_wheel_mode():
diff --git a/setuptools/wheel.py b/setuptools/wheel.py
index ff29e2fb..850e43cd 100644
--- a/setuptools/wheel.py
+++ b/setuptools/wheel.py
@@ -34,7 +34,7 @@ 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())
+ return {(t.interpreter, t.abi, t.platform) for t in sys_tags()}
def unpack(src_dir, dst_dir):
@@ -92,8 +92,7 @@ class Wheel:
def is_compatible(self):
'''Is the wheel compatible with the current platform?'''
- _supported_tags = _get_supported_tags()
- return next((True for t in self.tags() if t in _supported_tags), False)
+ return next((True for t in self.tags() if t in _get_supported_tags()), False)
def egg_name(self):
return _egg_basename(