
Guido van Rossum wrote:
I would like to argue that on Windows, import of dynamic libraries is broken. If a file something.pyd is imported, then sys.path is searched to find the module. If a file something.dll is imported, the same thing happens. But Windows defines its own search order for *.dll files which Python ignores. I would suggest that this is wrong for files named *.dll, but OK for files named *.pyd.
I think you misunderstand some of the issues.
Python cannot import every .dll file. Only .dll files that conform to the convention for Python extension modules can be imported. (The convention is that it must export an init<module> function.)
Of course I meant that the test is LoadLibrary(module) followed by GetProcAddress(h, "init" + module). Both must succeed.
This seems logical -- Python extensions must live in directories that Python searches (Python must do its own search because the search order is significant).
The PYTHONPATH search path is what I am trying to get away from. If I eliminate PYTHONPATH I still can not use the Windows DLL search path (which is superior) because DLLs are searched on PYTHONPATH too; thus my post. I don't believe it is important for Python module.dll to be located on PYTHONPATH.
A SysAdmin should be able to install and maintain *.dll as she has been trained to do. This makes maintaining Python installations simpler and more un-surprising.
I don't see that a SysAdmin needs to do much DLL management. This is up to installer scripts. Anyway how hard can it be for a SysAdmin to leave DLLs in specific directories alone?
The problem is maintaining PYTHONPATH plus having DLL's on a non-standard search path. Yes, PythonDev[:] and professional SysAdmins can do it. But it is not as simple as it could be. Someone has to write the install scripts. And what if something doesn't work? Think of Python being used as a teaching language for the 8th grade. Think of the 8th grade teacher trying to get all this right. The only thing that works is simplicity.
But at what point should this LoadLibrary() call be called? The import statement contains no clue that a DLL is requested -- the sys.path search reveals that.
Just after built-in and frozen modules.
I claim that there is nothing with the current strategy.
Thank you for thoughtfully considering and commenting at length on this issue. Lets ignore it for the moment. The other problems with PYTHONPATH are more pressing. But if those issues are solved, this one will stick out. JimA