File tree 2 files changed +20
-11
lines changed
2 files changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -612,9 +612,17 @@ def sys_tags():
612
612
for t in parse_tag ('cp36-cp36m-manylinux1_x86_64' ):
613
613
yield t
614
614
monkeypatch .setattr ('setuptools.wheel.sys_tags' , sys_tags )
615
- monkeypatch .setattr ('setuptools.wheel._supported_tags' , None )
616
- assert Wheel (
617
- 'onnxruntime-0.1.2-cp36-cp36m-manylinux1_x86_64.whl' ).is_compatible ()
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 ()
618
626
619
627
620
628
def test_wheel_mode ():
Original file line number Diff line number Diff line change 2
2
3
3
import email
4
4
import itertools
5
+ import functools
5
6
import os
6
7
import posixpath
7
8
import re
27
28
NAMESPACE_PACKAGE_INIT = \
28
29
"__import__('pkg_resources').declare_namespace(__name__)\n "
29
30
30
- _supported_tags = None
31
+
32
+ @functools .lru_cache (maxsize = None )
33
+ def _get_supported_tags ():
34
+ # We calculate the supported tags only once, otherwise calling
35
+ # this method on thousands of wheels takes seconds instead of
36
+ # milliseconds.
37
+ return set ((t .interpreter , t .abi , t .platform ) for t in sys_tags ())
31
38
32
39
33
40
def unpack (src_dir , dst_dir ):
@@ -85,13 +92,7 @@ def tags(self):
85
92
86
93
def is_compatible (self ):
87
94
'''Is the wheel compatible with the current platform?'''
88
- global _supported_tags
89
- if _supported_tags is None :
90
- # We calculate the supported tags only once, otherwise calling
91
- # this method on thousands of wheels takes seconds instead of
92
- # milliseconds.
93
- _supported_tags = set (
94
- (t .interpreter , t .abi , t .platform ) for t in sys_tags ())
95
+ _supported_tags = _get_supported_tags ()
95
96
return next ((True for t in self .tags () if t in _supported_tags ), False )
96
97
97
98
def egg_name (self ):
You can’t perform that action at this time.
0 commit comments