dist: Add special support for hidden imports of plyer module

This commit is contained in:
rdb 2022-03-12 16:52:12 +01:00
parent 218f2af7fb
commit 5c03cd59fb

View File

@ -80,6 +80,7 @@ defaultHiddenImports = {
],
'pandas.compat': ['lzma', 'cmath'],
'pandas._libs.tslibs.conversion': ['pandas._libs.tslibs.base'],
'plyer': ['plyer.platforms'],
}
@ -853,6 +854,20 @@ class Freezer:
if hiddenImports is not None:
self.hiddenImports.update(hiddenImports)
# Special hack for plyer, which has platform-specific hidden imports
plyer_platform = None
if self.platform.startswith('android'):
plyer_platform = 'android'
elif self.platform.startswith('linux'):
plyer_platform = 'linux'
elif self.platform.startswith('mac'):
plyer_platform = 'macosx'
elif self.platform.startswith('win'):
plyer_platform = 'win'
if plyer_platform:
self.hiddenImports['plyer'].append(f'plyer.platforms.{plyer_platform}.*')
# Suffix/extension for Python C extension modules
if self.platform == PandaSystem.getPlatform():
suffixes = imp.get_suffixes()