diff options
author | Ales Erjavec <ales.erjavec@fri.uni-lj.si> | 2016-04-22 20:02:52 +0200 |
---|---|---|
committer | Ales Erjavec <ales.erjavec@fri.uni-lj.si> | 2016-04-22 20:02:52 +0200 |
commit | 3d357c49cb25400711bf95e075f062ba07f22e72 (patch) | |
tree | 0994fd8e89493baba396abf6ceecc211cb5d7bdd | |
parent | 80a06d58f7e5fbf2cc54ec3dbc3f90f188d58bcb (diff) | |
download | wheel-3d357c49cb25400711bf95e075f062ba07f22e72.tar.gz |
Make `wheel convert` utility record the right python/soabi/plat tags
Before it would record the running interpreter's tags in the
generated WHEEL file, making invalid binary wheels.
-rwxr-xr-x | wheel/egg2wheel.py | 16 | ||||
-rwxr-xr-x | wheel/wininst2wheel.py | 30 |
2 files changed, 43 insertions, 3 deletions
diff --git a/wheel/egg2wheel.py b/wheel/egg2wheel.py index bf919c4..e819824 100755 --- a/wheel/egg2wheel.py +++ b/wheel/egg2wheel.py @@ -10,6 +10,7 @@ import distutils.dist from distutils.archive_util import make_archive from argparse import ArgumentParser from glob import iglob +from wheel.wininst2wheel import _bdist_wheel_tag egg_info_re = re.compile(r'''(?P<name>.+?)-(?P<ver>.+?) (-(?P<pyver>.+?))?(-(?P<arch>.+?))?.egg''', re.VERBOSE) @@ -43,8 +44,19 @@ def egg2wheel(egg_path, dest_dir): abi, arch )) - bw = wheel.bdist_wheel.bdist_wheel(distutils.dist.Distribution()) - bw.root_is_purelib = egg_info['arch'] is None + root_is_purelib = egg_info['arch'] is None + if root_is_purelib: + bw = wheel.bdist_wheel.bdist_wheel(distutils.dist.Distribution()) + else: + bw = _bdist_wheel_tag(distutils.dist.Distribution()) + + bw.root_is_purelib = root_is_purelib + bw.plat_name_supplied = True + bw.plat_name = egg_info['arch'] or 'any' + if not root_is_purelib: + bw.full_tag_supplied = True + bw.full_tag = (pyver, abi, arch) + dist_info_dir = os.path.join(dir, '%s.dist-info' % dist_info) bw.egg2dist(os.path.join(dir, 'EGG-INFO'), dist_info_dir) diff --git a/wheel/wininst2wheel.py b/wheel/wininst2wheel.py index 297f8d1..f208959 100755 --- a/wheel/wininst2wheel.py +++ b/wheel/wininst2wheel.py @@ -158,8 +158,19 @@ def bdist_wininst2wheel(path, dest_dir=os.path.curdir): abi, arch )) - bw = wheel.bdist_wheel.bdist_wheel(distutils.dist.Distribution()) + if root_is_purelib: + bw = wheel.bdist_wheel.bdist_wheel(distutils.dist.Distribution()) + else: + bw = _bdist_wheel_tag(distutils.dist.Distribution()) + bw.root_is_purelib = root_is_purelib + bw.plat_name_supplied = True + bw.plat_name = info['arch'] or 'any' + + if not root_is_purelib: + bw.full_tag_supplied = True + bw.full_tag = (pyver, abi, arch) + dist_info_dir = os.path.join(dir, '%s.dist-info' % dist_info) bw.egg2dist(os.path.join(dir, egginfo_name), dist_info_dir) bw.write_wheelfile(dist_info_dir, generator='wininst2wheel') @@ -168,6 +179,23 @@ def bdist_wininst2wheel(path, dest_dir=os.path.curdir): archive_wheelfile(os.path.join(dest_dir, wheel_name), dir) rmtree(dir) + +class _bdist_wheel_tag(wheel.bdist_wheel.bdist_wheel): + # allow the client to override the default generated wheel tag + # The default bdist_wheel implementation uses python and abi tags + # of the running python process. This is not suitable for + # generating/repackaging prebuild binaries. + + full_tag_supplied = False + full_tag = None # None or a (pytag, soabitag, plattag) triple + + def get_tag(self): + if self.full_tag_supplied and self.full_tag is not None: + return self.full_tag + else: + return super(_bdist_wheel_tag, self).get_tag() + + def main(): parser = ArgumentParser() parser.add_argument('installers', nargs='*', help="Installers to convert") |