platform.py (1127B)
1 def _from_system_packaging(): 2 from packaging.tags import sys_tags 3 tag = sys_tags().__next__() 4 return (tag.interpreter, tag.abi, tag.platform) 5 6 7 def _from_bundled_packaging(): 8 from .bundled.packaging.tags import sys_tags 9 tag = sys_tags().__next__() 10 return (tag.interpreter, tag.abi, tag.platform) 11 12 13 def _from_wheel_pep425tags(): 14 from wheel.pep425tags import ( 15 get_abbr_impl, get_impl_ver, get_abi_tag, get_platform, 16 ) 17 # sporked from wheel.bdist_wheel.get_tag 18 plat_name = get_platform().replace('-', '_').replace('.', '_') 19 impl_name = get_abbr_impl() 20 impl_ver = get_impl_ver() 21 impl = impl_name + impl_ver 22 abi_tag = str(get_abi_tag()).lower() 23 return (impl, abi_tag, plat_name) 24 25 26 def get_wheel_tag(): 27 """Get the specific implementation name in a wheel-compatible format.""" 28 try: 29 return _from_system_packaging() 30 except ImportError: 31 try: 32 return _from_wheel_pep425tags() 33 except: 34 return _from_bundled_packaging() 35 36 37 def _is_python2(): 38 import sys 39 return sys.version_info[0] == 2 40 41 42 PY2 = _is_python2()