hook-numpy.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 (probably because they are only imported
  19. # by extension modules, which PyInstaller cannot read).
  20. hiddenimports = ['numpy.core._dtype_ctypes']
  21. if is_conda:
  22. hiddenimports.append("six")
  23. # Remove testing and building code and packages that are referenced throughout
  24. # NumPy but are not really dependencies.
  25. excludedimports = [
  26. "scipy",
  27. "pytest",
  28. "nose",
  29. "f2py",
  30. "setuptools",
  31. "numpy.f2py",
  32. "distutils",
  33. "numpy.distutils",
  34. ]