hook-bacon.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # ------------------------------------------------------------------
  2. # Copyright (c) 2020 PyInstaller Development Team.
  3. #
  4. # This file is distributed under the terms of the GNU General Public
  5. # License (version 2.0 or later).
  6. #
  7. # The full license is available in LICENSE, distributed with
  8. # this software.
  9. #
  10. # SPDX-License-Identifier: GPL-2.0-or-later
  11. # ------------------------------------------------------------------
  12. # Hook for Bacon (https://github.com/aholkner/bacon)
  13. # Bacon requires its native DLLs to be copied alongside frozen executable.
  14. import os
  15. import ctypes
  16. from PyInstaller.compat import is_win, is_darwin
  17. from PyInstaller.utils.hooks import get_package_paths
  18. def collect_native_files(package, files):
  19. pkg_base, pkg_dir = get_package_paths(package)
  20. return [(os.path.join(pkg_dir, file), '.') for file in files]
  21. if is_win:
  22. files = ['Bacon.dll',
  23. 'd3dcompiler_46.dll',
  24. 'libEGL.dll',
  25. 'libGLESv2.dll',
  26. 'msvcp110.dll',
  27. 'msvcr110.dll',
  28. 'vccorllib110.dll']
  29. if ctypes.sizeof(ctypes.c_void_p) == 4:
  30. hiddenimports = ["bacon.windows32"]
  31. datas = collect_native_files('bacon.windows32', files)
  32. else:
  33. hiddenimports = ["bacon.windows64"]
  34. datas = collect_native_files('bacon.windows64', files)
  35. elif is_darwin:
  36. if ctypes.sizeof(ctypes.c_void_p) == 4:
  37. hiddenimports = ["bacon.darwin32"]
  38. files = ['Bacon.dylib']
  39. datas = collect_native_files('bacon.darwin32', files)
  40. else:
  41. hiddenimports = ["bacon.darwin64"]
  42. files = ['Bacon64.dylib']
  43. datas = collect_native_files('bacon.darwin64', files)