On Wed, Mar 11, 2015 at 4:37 PM David Cournapeau <courn...@gmail.com> wrote:
> Hi, > > While looking at the import code of python for C extensions, I was > wondering why we pass a relative path instead of an absolute path to > LoadLibraryEx (see bottom for some context). > > In python 2.7, the full path existence was even checked before calling > into LoadLibraryEx ( > https://github.com/python/cpython/blob/2.7/Python/dynload_win.c#L189), > but it looks like this check was removed in python 3.x branch. > I personally don't know of any specific reason. -Brett > > Is there any defined behaviour that depends on this path to be relative ? > > Context > ----------- > > The reason why I am interested in this is the potential use of > SetDllDirectory to share dlls between multiple python extensions. > Currently, the only solutions I am aware of are: > > 1. putting the dlls in the PATH > 2. bundling the dlls side by side the .pyd > 3. patching packages to use preloading (using e.g. ctypes) > > I am investigating a solution 4, where the dlls would be put in a separate > "private" directory only known of python itself, without the need to modify > PATH. > > Patching python to use SetDllDirectory("some private paths specific to a > python interpreter") works perfectly, except that it slightly changes the > semantics of LoadLibraryEx not to look for dlls in the current directory. > This breaks importing extensions built in place, unless I modify the call > in ;https://github.com/python/cpython/blob/2.7/Python/dynload_win.c#L195 > from: > > hDLL = LoadLibraryEx(pathname, NULL LOAD_WITH_ALTERED_SEARCH_PATH) > > to > > hDLL = LoadLibraryEx(pathbuf, NULL LOAD_WITH_ALTERED_SEARCH_PATH) > > That seems to work, but I am quite worried about changing any import > semantics by accident. > > David > _______________________________________________ > Python-Dev mailing list > Python-Dev@python.org > https://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: https://mail.python.org/mailman/options/python-dev/ > brett%40python.org >
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com