From ea351da50cf970098d0586e1f9796bf80b599e1a Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 13 May 2018 15:30:10 +0200 Subject: [PATCH] deploy-ng: fix issue with irrelevant wheels in cache dir being used This is still not a perfect solution, since eg. the wrong version of a package may still be used if older versions are still in the __whl_cache__ directory. We may want to look into using pip to resolve the package versions, or do something clever such as automatically remove cached wheels if a newer version of the same package was downloaded. --- direct/src/showutil/dist.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/direct/src/showutil/dist.py b/direct/src/showutil/dist.py index 871d4c9ba2..e916a4d316 100644 --- a/direct/src/showutil/dist.py +++ b/direct/src/showutil/dist.py @@ -185,10 +185,12 @@ class build_apps(setuptools.Command): #TODO find a better way to get abi tag than from internal/private pip APIs if hasattr(pip, 'pep425tags'): - abi_tag = pip.pep425tags.get_abi_tag() + pep425tags = pip.pep425tags + wheel = pip.wheel else: - from pip._internal import pep425tags - abi_tag = pep425tags.get_abi_tag() + from pip._internal import pep425tags, wheel + + abi_tag = pep425tags.get_abi_tag() if 'u' in abi_tag and (platform.startswith('win') or platform.startswith('macosx')): abi_tag = abi_tag.replace('u', '') @@ -211,7 +213,18 @@ class build_apps(setuptools.Command): subprocess.check_call([sys.executable, '-m', 'pip'] + pip_args) - wheelpaths = [os.path.join(whldir,i) for i in os.listdir(whldir) if platform in i] + # Now figure out which of the downloaded wheels are relevant to us. + tags = pep425tags.get_supported(platform=platform, abi=abi_tag) + wheelpaths = [] + for filename in os.listdir(whldir): + try: + whl = wheel.Wheel(filename) + except wheel.InvalidWheelFilename: + continue + + if whl.supported(tags): + wheelpaths.append(os.path.join(whldir, filename)) + return wheelpaths def bundle_macos_app(self, builddir): @@ -278,7 +291,7 @@ class build_apps(setuptools.Command): wheelpaths = self.download_wheels(platform) for whl in wheelpaths: - if 'panda3d-' in whl: + if os.path.basename(whl).startswith('panda3d-'): p3dwhlfn = whl p3dwhl = self._get_zip_file(p3dwhlfn) break