1111import re
1212from collections import OrderedDict
1313from email .generator import Generator
14+ import distutils
1415from distutils .core import Command
1516from distutils .sysconfig import get_python_version
1617from distutils import log as logger
2122
2223import pkg_resources
2324
24- from .pep425tags import get_abbr_impl , get_impl_ver , get_abi_tag , get_platform
2525from .pkginfo import write_pkg_info
2626from .metadata import pkginfo_to_metadata
2727from .wheelfile import WheelFile
28- from . import pep425tags
2928from . import __version__ as wheel_version
3029
3130
3534PY_LIMITED_API_PATTERN = r'cp3\d'
3635
3736
37+ def python_tag ():
38+ return 'py{}' .format (sys .version_info [0 ])
39+
40+
41+ # copied from pep425tags.py, is there a better way?
42+ def get_platform ():
43+ """Return our platform name 'win32', 'linux_x86_64'"""
44+ # XXX remove distutils dependency
45+ result = distutils .util .get_platform ().replace ('.' , '_' ).replace ('-' , '_' )
46+ if result == "linux_x86_64" and sys .maxsize == 2147483647 :
47+ # pip pull request #3497
48+ result = "linux_i686"
49+ return result
50+
51+
3852def safer_name (name ):
3953 return safe_name (name ).replace ('-' , '_' )
4054
@@ -62,7 +76,7 @@ class bdist_wheel(Command):
6276 "temporary directory for creating the distribution" ),
6377 ('plat-name=' , 'p' ,
6478 "platform name to embed in generated filenames "
65- "(default: %s)" % get_platform (None )),
79+ "(default: %s)" % get_platform ()),
6680 ('keep-temp' , 'k' ,
6781 "keep the pseudo-installation tree around after " +
6882 "creating the distribution archive" ),
@@ -88,7 +102,7 @@ class bdist_wheel(Command):
88102 .format (', ' .join (supported_compressions ))),
89103 ('python-tag=' , None ,
90104 "Python implementation compatibility tag"
91- " (default: py%s )" % get_impl_ver ()[ 0 ] ),
105+ " (default: '%s' )" % ( python_tag ()) ),
92106 ('build-number=' , None ,
93107 "Build number for this particular version. "
94108 "As specified in PEP-0427, this must start with a digit. "
@@ -116,7 +130,7 @@ def initialize_options(self):
116130 self .group = None
117131 self .universal = False
118132 self .compression = 'deflated'
119- self .python_tag = 'py' + get_impl_ver ()[ 0 ]
133+ self .python_tag = python_tag ()
120134 self .build_number = None
121135 self .py_limited_api = False
122136 self .plat_name_supplied = False
@@ -167,6 +181,7 @@ def wheel_dist_name(self):
167181 return '-' .join (components )
168182
169183 def get_tag (self ):
184+ from . import pep425tags
170185 # bdist sets self.plat_name if unset, we should only use it for purepy
171186 # wheels if the user supplied it.
172187 if self .plat_name_supplied :
@@ -178,7 +193,7 @@ def get_tag(self):
178193 if self .plat_name and not self .plat_name .startswith ("macosx" ):
179194 plat_name = self .plat_name
180195 else :
181- plat_name = get_platform (self . bdist_dir )
196+ plat_name = get_platform ()
182197
183198 if plat_name in ('linux-x86_64' , 'linux_x86_64' ) and sys .maxsize == 2147483647 :
184199 plat_name = 'linux_i686'
@@ -192,15 +207,15 @@ def get_tag(self):
192207 impl = self .python_tag
193208 tag = (impl , 'none' , plat_name )
194209 else :
195- impl_name = get_abbr_impl ()
196- impl_ver = get_impl_ver ()
210+ impl_name = pep425tags . get_abbr_impl ()
211+ impl_ver = pep425tags . get_impl_ver ()
197212 impl = impl_name + impl_ver
198213 # We don't work on CPython 3.1, 3.0.
199214 if self .py_limited_api and (impl_name + impl_ver ).startswith ('cp3' ):
200215 impl = self .py_limited_api
201216 abi_tag = 'abi3'
202217 else :
203- abi_tag = str (get_abi_tag ()).lower ()
218+ abi_tag = str (pep425tags . get_abi_tag ()).lower ()
204219 tag = (impl , abi_tag , plat_name )
205220 supported_tags = pep425tags .get_supported (
206221 self .bdist_dir ,
0 commit comments