Thanks Steve for the clarifications. As a workaround placing the older sqlite3.dll in the same folder as the _mapscript.pyd file while leaving all the other DLLs in a different folder referenced by add_dll_directory allows for a successful import. For a less hacky fix - after checking the version numbers for sqlite3 again they are not too different so it may be easiest to update the upstream builds to a matching version. Apologies for the noise - I thought this was related to the new add_dll_directory function, but I can break old versions using PATH and mismatched sqlite3 .dlls too!
Seth -- web:http://geographika.co.uk twitter: @geographika On Mon, Jun 22, 2020, at 5:46 PM, Steve Dower wrote: > 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/SO37EWIVDOKEIQO6MPSR2EVL5EDPLV4J/ Code of Conduct: http://python.org/psf/codeofconduct/