hook-numpy.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. """This hook should collect all binary files and any hidden modules that numpy
  2. needs.
  3. Our (some-what inadequate) docs for writing PyInstaller hooks are kept here:
  4. https://pyinstaller.readthedocs.io/en/stable/hooks.html
  5. """
  6. from PyInstaller.compat import is_conda, is_pure_conda
  7. from PyInstaller.utils.hooks import collect_dynamic_libs, is_module_satisfies
  8. # Collect all DLLs inside numpy's installation folder, dump them into built
  9. # app's root.
  10. binaries = collect_dynamic_libs("numpy", ".")
  11. # If using Conda without any non-conda virtual environment manager:
  12. if is_pure_conda:
  13. # Assume running the NumPy from Conda-forge and collect it's DLLs from the
  14. # communal Conda bin directory. DLLs from NumPy's dependencies must also be
  15. # collected to capture MKL, OpenBlas, OpenMP, etc.
  16. from PyInstaller.utils.hooks import conda_support
  17. datas = conda_support.collect_dynamic_libs("numpy", dependencies=True)
  18. # Submodules PyInstaller cannot detect. `_dtype_ctypes` is only imported
  19. # from C and `_multiarray_tests` is used in tests (which are not packed).
  20. hiddenimports = ['numpy.core._dtype_ctypes', 'numpy.core._multiarray_tests']
  21. # Remove testing and building code and packages that are referenced throughout
  22. # NumPy but are not really dependencies.
  23. excludedimports = [
  24. "scipy",
  25. "pytest",
  26. "f2py",
  27. "setuptools",
  28. "numpy.f2py",
  29. "distutils",
  30. "numpy.distutils",
  31. ]