File tree 3 files changed +13
-4
lines changed
3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change
1
+ Cache supported tags for wheels.
Original file line number Diff line number Diff line change @@ -612,6 +612,7 @@ 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 )
615
616
assert Wheel (
616
617
'onnxruntime-0.1.2-cp36-cp36m-manylinux1_x86_64.whl' ).is_compatible ()
617
618
Original file line number Diff line number Diff line change 27
27
NAMESPACE_PACKAGE_INIT = \
28
28
"__import__('pkg_resources').declare_namespace(__name__)\n "
29
29
30
+ _supported_tags = None
31
+
30
32
31
33
def unpack (src_dir , dst_dir ):
32
34
'''Move everything under `src_dir` to `dst_dir`, and delete the former.'''
@@ -82,10 +84,15 @@ def tags(self):
82
84
)
83
85
84
86
def is_compatible (self ):
85
- '''Is the wheel is compatible with the current platform?'''
86
- supported_tags = set (
87
- (t .interpreter , t .abi , t .platform ) for t in sys_tags ())
88
- return next ((True for t in self .tags () if t in supported_tags ), False )
87
+ '''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
+ return next ((True for t in self .tags () if t in _supported_tags ), False )
89
96
90
97
def egg_name (self ):
91
98
return _egg_basename (
You can’t perform that action at this time.
0 commit comments