Skip to content

Commit 8961851

Browse files
committed
Simplify changes targeting sys_tags cache
1 parent 8af6bd4 commit 8961851

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

setuptools/tests/test_wheel.py

+7-14
Original file line numberDiff line numberDiff line change
@@ -609,20 +609,13 @@ def test_wheel_no_dist_dir():
609609

610610
def test_wheel_is_compatible(monkeypatch):
611611
def sys_tags():
612-
for t in parse_tag('cp36-cp36m-manylinux1_x86_64'):
613-
yield t
614-
monkeypatch.setattr('setuptools.wheel.sys_tags', sys_tags)
615-
# Clear the supported tags cache, otherwise the sys_tags monkeypatch
616-
# has no effect.
617-
setuptools.wheel._supported_tags.cache_clear()
618-
try:
619-
assert Wheel(
620-
'onnxruntime-0.1.2-cp36-cp36m-manylinux1_x86_64.whl'
621-
).is_compatible()
622-
finally:
623-
# Clear the cache again, otherwise the sys_tags monkeypatch
624-
# is still in effect for the rest of the tests.
625-
setuptools.wheel._supported_tags.cache_clear()
612+
return {
613+
(t.interpreter, t.abi, t.platform)
614+
for t in parse_tag('cp36-cp36m-manylinux1_x86_64')
615+
}
616+
monkeypatch.setattr('setuptools.wheel._get_supported_tags', sys_tags)
617+
assert Wheel(
618+
'onnxruntime-0.1.2-cp36-cp36m-manylinux1_x86_64.whl').is_compatible()
626619

627620

628621
def test_wheel_mode():

setuptools/wheel.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def _get_supported_tags():
3434
# We calculate the supported tags only once, otherwise calling
3535
# this method on thousands of wheels takes seconds instead of
3636
# milliseconds.
37-
return set((t.interpreter, t.abi, t.platform) for t in sys_tags())
37+
return {(t.interpreter, t.abi, t.platform) for t in sys_tags()}
3838

3939

4040
def unpack(src_dir, dst_dir):
@@ -92,8 +92,7 @@ def tags(self):
9292

9393
def is_compatible(self):
9494
'''Is the wheel compatible with the current platform?'''
95-
_supported_tags = _get_supported_tags()
96-
return next((True for t in self.tags() if t in _supported_tags), False)
95+
return next((True for t in self.tags() if t in _get_supported_tags()), False)
9796

9897
def egg_name(self):
9998
return _egg_basename(

0 commit comments

Comments
 (0)