图片解析应用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.2 KiB

  1. '''
  2. Helper to preload windows dlls to prevent dll not found errors.
  3. Once a DLL is preloaded, its namespace is made available to any
  4. subsequent DLL. This file originated in the numpy-wheels repo,
  5. and is created as part of the scripts that build the wheel.
  6. '''
  7. import os
  8. import glob
  9. if os.name == 'nt':
  10. # convention for storing / loading the DLL from
  11. # numpy/.libs/, if present
  12. try:
  13. from ctypes import WinDLL
  14. basedir = os.path.dirname(__file__)
  15. except:
  16. pass
  17. else:
  18. libs_dir = os.path.abspath(os.path.join(basedir, '.libs'))
  19. DLL_filenames = []
  20. if os.path.isdir(libs_dir):
  21. for filename in glob.glob(os.path.join(libs_dir,
  22. '*openblas*dll')):
  23. # NOTE: would it change behavior to load ALL
  24. # DLLs at this path vs. the name restriction?
  25. WinDLL(os.path.abspath(filename))
  26. DLL_filenames.append(filename)
  27. if len(DLL_filenames) > 1:
  28. import warnings
  29. warnings.warn("loaded more than 1 DLL from .libs:"
  30. "\n%s" % "\n".join(DLL_filenames),
  31. stacklevel=1)