Can't try it right now but I can't see why adding sys.excutable to the PATH at that point
wouldn't "work" as an alternative to skipping the sanity check when frozen. My broader
concern is whether fiddling with the PATH is the best or really the correct fix. If you
need to exactly replicate Windows DLL search rules (which, just to make life fun, vary
depending on the Windows version and the state of the SafeDllSearchMode*) then you should
do that rather than hacking the PATH. For example, what if there is another hdf5dll.dll
already on the PATH? In that case you'd better put sys.executable in the front of the PATH,
but that might break something else. Maybe 99.9% of the time the PATH hack works but
it can also fail.
I think the only proper fix is to make find_library follow the Windows rules exactly.
Short of that, it is not safe to use it when the library might be in different places,
such as frozen vs non-frozen applications.
[*]
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682586%28v=vs.85%29.aspx
>> Ctypes only tries to find a library in the os.environ['PATH']
>> directories, not the current directory or the sys.executable directory
>> as one could expect.
>>
http://hg.python.org/cpython/file/64640a02b0ca/Lib/ctypes/util.py#l48
>>
>> As a workaround, for distributions that place the HDF5 and other DLLs in
>> the tables package directory, tables.__init__.py adds the tables package
>> directory to os.environ['PATH']. This also makes sure that the DLLs are
>> found when loading the hdf5Extension.pyd and other C extension modules
>> (another common problem). The use of __file__ to get the tables
>> directory should better be wrapped in a try..except statement.
>>
https://github.com/PyTables/PyTables/blob/develop/tables/__init__.py#L24
>>
>> Christoph
> Thanks, I'll fix it ASAP.
>
> P.S.: please Christoph, do you have some hint for gh-175 [1]?
> There is something we can do in PyTables?
>
> [1]
https://github.com/PyTables/PyTables/issues/175
Stuart