This PR addresses potential issues with loading the FreeImage.dll on Windows, especially in frozen distributions.
ctypes.util.find_library does not find DLLs that are placed next to freeimage.py or sys.executable, the most common places for binary and frozen distributions to place FreeImage.dll. Currently FreeImage.dll is preferably loaded from other places in the os.environ['PATH'] list. A FreeImage.dll located next to sys.executable is never loaded AFAICT. This makes binary/frozen distributions that ship with tested FreeImage.dll more unreliable.
With the proposed fix, FreeImage.dll is first loaded from the directory where freeimage.py is located, and if that fails loaded from one of the Windows DLL search path, which includes the sys.executable directory at the top of the list.
This PR addresses potential issues with loading the FreeImage.dll on Windows, especially in frozen distributions.
ctypes.util.find_library
does not find DLLs that are placed next to freeimage.py or sys.executable, the most common places for binary and frozen distributions to place FreeImage.dll. Currently FreeImage.dll is preferably loaded from other places in the os.environ['PATH'] list. A FreeImage.dll located next to sys.executable is never loaded AFAICT. This makes binary/frozen distributions that ship with tested FreeImage.dll more unreliable.With the proposed fix, FreeImage.dll is first loaded from the directory where freeimage.py is located, and if that fails loaded from one of the Windows DLL search path, which includes the sys.executable directory at the top of the list.
The code is adapted from https://github.com/PyTables/PyTables/pull/178 to 180
Tested on Windows, Python 2.6 to 3.2 only. This should be tested on other platforms.