build_apps: Fix running with Pip 20

Fixes #854
Closes #856
This commit is contained in:
Mitchell Stokes 2020-02-09 16:52:05 -08:00 committed by rdb
parent 59608c9079
commit 391578ea1f

View File

@ -399,27 +399,22 @@ class build_apps(setuptools.Command):
self.announce('Gathering wheels for platform: {}'.format(platform), distutils.log.INFO) self.announce('Gathering wheels for platform: {}'.format(platform), distutils.log.INFO)
whldir = os.path.join(self.build_base, '__whl_cache__') whlcache = os.path.join(self.build_base, '__whl_cache__')
#TODO find a better way to get abi tag than from internal/private pip APIs pip_version = int(pip.__version__.split('.')[0])
if hasattr(pip, 'pep425tags'): if pip_version < 9:
pep425tags = pip.pep425tags raise RuntimeError("pip 9.0 or greater is required, but found {}".format(pip.__version__))
wheel = pip.wheel
else:
from pip._internal import pep425tags, wheel
abi_tag = pep425tags.get_abi_tag() abi_tag = 'cp%d%d' % (sys.version_info[:2])
if sys.version_info < (3, 8):
if 'u' in abi_tag and (platform.startswith('win') or platform.startswith('macosx')): abi_tag += 'm'
abi_tag = abi_tag.replace('u', '')
# For these distributions, we need to append 'u' on Linux # For these distributions, we need to append 'u' on Linux
if abi_tag in ('cp26m', 'cp27m', 'cp32m') and not platform.startswith('win') and not platform.startswith('macosx'): if abi_tag in ('cp26m', 'cp27m', 'cp32m') and not platform.startswith('win') and not platform.startswith('macosx'):
abi_tag += 'u' abi_tag += 'u'
pip_version = pip.__version__.split('.') whldir = os.path.join(whlcache, '_'.join((platform, abi_tag)))
if int(pip_version[0]) < 9: os.makedirs(whldir, exist_ok=True)
raise RuntimeError("pip 9.0 or greater is required, but found {}".format(pip.__version__))
# Remove any .zip files. These are built from a VCS and block for an # Remove any .zip files. These are built from a VCS and block for an
# interactive prompt on subsequent downloads. # interactive prompt on subsequent downloads.
@ -447,19 +442,12 @@ class build_apps(setuptools.Command):
subprocess.check_call([sys.executable, '-m', 'pip'] + pip_args) subprocess.check_call([sys.executable, '-m', 'pip'] + pip_args)
# Now figure out which of the downloaded wheels are relevant to us. # Return a list of paths to the downloaded whls
tags = pep425tags.get_supported(platform=platform, abi=abi_tag) return [
wheelpaths = [] os.path.join(whldir, filename)
for filename in os.listdir(whldir): for filename in os.listdir(whldir)
try: if filename.endswith('.whl')
whl = wheel.Wheel(filename) ]
except wheel.InvalidWheelFilename:
continue
if whl.supported(tags):
wheelpaths.append(os.path.join(whldir, filename))
return wheelpaths
def update_pe_resources(self, appname, runtime): def update_pe_resources(self, appname, runtime):
"""Update resources (e.g., icons) in windows PE file""" """Update resources (e.g., icons) in windows PE file"""