On 22Jun2020 1039, Seth G wrote:
However, there is one feature of using the Windows PATH that I can't seem to 
replicate with add_dll_directory.
The MapServer DLL builds are linked to sqlite3 3.24.0, whereas Python 3.8.2 is 
linked to 2.6.0. Building with matching versions is not something I can easily 
change.

When using Windows PATH the folder with the newer version could be added to the 
front of the list to take priority and import worked correctly. This does not 
seem to be possible with add_dll_directory - the Python sqlite3.dll in 
C:\Python38\DLLs always takes priority leading to:

ImportError: DLL load failed while importing _mapscript: The specified 
procedure could not be found.

I presume I can't remove the C:\Python38\DLLs path, is there another solution 
to this issue?

DLLs should not be in the search path at all - it's searched by sys.path when importing .pyd files, which are loaded by absolute path and their dependencies found adjacent.

What is likely happening here is that _sqlite3.pyd is being imported before _mapscript, and so there is already a SQLITE3 module in memory. Like Python, Windows will not attempt to import a second module with the same name, but will return the original one.

So your best option here is probably to rebuild sqlite3.dll with as much of the version number (or some unique string) in the name as you need. Or you can statically link it into your extension module, assuming you aren't relying on shared state with other modules in your package. The latter is probably easier.

Cheers,
Steve
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/PMBOWXNIXBGPPOOTDWU3LGR6QSP73AXW/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to