File tree Expand file tree Collapse file tree 3 files changed +17
-7
lines changed Expand file tree Collapse file tree 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():
609609
610610def 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 )
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 )
615617 assert Wheel (
616618 'onnxruntime-0.1.2-cp36-cp36m-manylinux1_x86_64.whl' ).is_compatible ()
617619
Original file line number Diff line number Diff line change 22
33import email
44import itertools
5+ import functools
56import os
67import posixpath
78import re
2829 "__import__('pkg_resources').declare_namespace(__name__)\n "
2930
3031
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+
3140def unpack (src_dir , dst_dir ):
3241 '''Move everything under `src_dir` to `dst_dir`, and delete the former.'''
3342 for dirpath , dirnames , filenames in os .walk (src_dir ):
@@ -82,10 +91,8 @@ def tags(self):
8291 )
8392
8493 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 )
8996
9097 def egg_name (self ):
9198 return _egg_basename (
You can’t perform that action at this time.
0 commit comments