hook-blspy.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # ------------------------------------------------------------------
  2. # Copyright (c) 2021 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. import os
  13. import glob
  14. from PyInstaller.utils.hooks import get_module_file_attribute
  15. from PyInstaller.compat import is_win
  16. # blspy comes as a stand-alone extension module that's placed directly
  17. # in site-packages.
  18. #
  19. # On macOS and Linux, it is linked against the GMP library, whose shared
  20. # library is stored in blspy.libs and .dylibsblspy, respectively. As this
  21. # is a linked dependency, it is collected properly by PyInstaller and
  22. # no further work is needed.
  23. #
  24. # On Windows, however, the blspy extension is linked against MPIR library,
  25. # whose DLLs are placed directly into site-packages. The mpir.dll is
  26. # linked dependency and is picked up automatically, but it in turn
  27. # dynamically loads CPU-specific backends that are named mpir_*.dll.
  28. # We need to colllect these manually.
  29. if is_win:
  30. blspy_dir = os.path.dirname(get_module_file_attribute('blspy'))
  31. mpir_dlls = glob.glob(os.path.join(blspy_dir, 'mpir_*.dll'))
  32. binaries = [(mpir_dll, '.') for mpir_dll in mpir_dlls]