File tree 3 files changed +17
-7
lines changed
3 files changed +17
-7
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 @@ -609,9 +609,11 @@ def test_wheel_no_dist_dir():
609
609
610
610
def test_wheel_is_compatible (monkeypatch ):
611
611
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 )
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 )
615
617
assert Wheel (
616
618
'onnxruntime-0.1.2-cp36-cp36m-manylinux1_x86_64.whl' ).is_compatible ()
617
619
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
28
29
"__import__('pkg_resources').declare_namespace(__name__)\n "
29
30
30
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 {(t .interpreter , t .abi , t .platform ) for t in sys_tags ()}
38
+
39
+
31
40
def unpack (src_dir , dst_dir ):
32
41
'''Move everything under `src_dir` to `dst_dir`, and delete the former.'''
33
42
for dirpath , dirnames , filenames in os .walk (src_dir ):
@@ -82,10 +91,8 @@ def tags(self):
82
91
)
83
92
84
93
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 )
94
+ '''Is the wheel compatible with the current platform?'''
95
+ return next ((True for t in self .tags () if t in _get_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