Eryk Sun <eryk...@gmail.com> added the comment:

> I'm very against doing magic to extract the names from the DLL, but 
> but maybe we could have a search path in the parent package? Then 
> add/remove it around importing the module.

That works, too. I'm happy either way.

We still can't load multiple DLLs with the same name with this technique. That 
requires private assembly packages, which is doable (in Windows 7+), but a bit 
complex and requires modifying the embedded #2 manifest of the extension 
module. The alternative is to rewrite the PE import tables of all DLLs to 
reference unique DLL names. Neither is necessary if everything is built against 
unique, versioned DLL names.

> I think you're right that we just need to update the LoadLibrary
> flags, but will those also apply to dependencies of the loaded 
> module? 

The DLL search path is computed once per LoadLibraryExW call based on either 
the call flags or the process default flags. We shouldn't mess with the process 
default, since there's no way to restore the legacy DLL search path, in 
particular this includes the Windows directory (%SystemRoot%), 16-bit System 
directory (%SystemRoot%\System), current directory, and PATH. 

Should we support a convenient syntax for including the current value of PATH 
at extension-module load time? This could be an entry that's exactly equal to 
"<PATH>". (Less-than and greater-than are reserved as wildcard characters by 
all Windows file systems that I can think of.) It would iterate over PATH, 
adding each directory via AddDllDirectory. Of course, all added directories 
would subsequently be removed via RemoveDllDirectory after the LoadLibraryExW 
call.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36085>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to