hook-OpenGL.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. """
  13. Hook for PyOpenGL 3.x versions from 3.0.0b6 up. Previous versions have a
  14. plugin system based on pkg_resources which is problematic to handle correctly
  15. under pyinstaller; 2.x versions used to run fine without hooks, so this one
  16. shouldn't hurt.
  17. """
  18. from PyInstaller.compat import is_win, is_darwin
  19. from PyInstaller.utils.hooks import collect_data_files, collect_submodules
  20. # PlatformPlugin performs a conditional import based on os.name and
  21. # sys.platform. PyInstaller misses this so let's add it ourselves...
  22. if is_win:
  23. hiddenimports = ['OpenGL.platform.win32']
  24. elif is_darwin:
  25. hiddenimports = ['OpenGL.platform.darwin']
  26. # Use glx for other platforms (Linux, ...)
  27. else:
  28. hiddenimports = ['OpenGL.platform.glx']
  29. # Arrays modules are needed too.
  30. hiddenimports += collect_submodules('OpenGL.arrays')
  31. # PyOpenGL 3.x uses ctypes to load DLL libraries. PyOpenGL windows installer
  32. # adds necessary dll files to
  33. # DLL_DIRECTORY = os.path.join( os.path.dirname( OpenGL.__file__ ), 'DLLS')
  34. # PyInstaller is not able to find these dlls. Just include them all as data
  35. # files.
  36. if is_win:
  37. datas = collect_data_files('OpenGL')