On 6/22/20, Steve Dower <[email protected]> wrote:
>
> 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.
Qualified DLL loads won't interfere with each other, but dependent
DLLs are loaded by base name only. In these cases a SxS assembly
allows loading multiple DLLs that have the same base name. If the
assembly is referenced by a DLL, embed the manifest in the DLL as
resource 2. For example:
>>> import ctypes
>>> test1 = ctypes.CDLL('./test1')
>>> test2 = ctypes.CDLL('./test2')
>>> test1.call_spam.restype = None
>>> test2.call_spam.restype = None
>>> test1.call_spam()
spam v1.0
>>> test2.call_spam()
spam v2.0
>>> import win32process, win32api
>>> names = [win32api.GetModuleFileName(x)
... for x in win32process.EnumProcessModules(-1)]
>>> spams = [x for x in names if 'spam' in x]
>>> print(*spams, sep='\n')
C:\Temp\test\c\spam.dll
C:\Temp\test\c\spam_assembly\spam.dll
Source
spam1.c (spam.dll):
#include <stdio.h>
void __declspec(dllexport) spam()
{
printf("spam v1.0\n");
}
test1.c (test1.dll):
#pragma comment(lib, "spam")
void __declspec(dllimport) spam();
void __declspec(dllexport) call_spam()
{
spam();
}
---
spam_assembly/spam_assembly.manifest:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
name="spam_assembly"
version="2.0.0.0"
type="win32"
processorArchitecture="amd64" />
<file name="spam.dll" />
</assembly>
spam2.c (spam_assembly/spam.dll):
#include <stdio.h>
void __declspec(dllexport) spam()
{
printf("spam v2.0\n");
}
test2.c (test2.dll -- link with /manifest:embed,id=2):
#pragma comment(lib, "spam")
#pragma comment(linker, "/manifestdependency:\"\
type='win32' \
name='spam_assembly' \
version='2.0.0.0' \
processorArchitecture='amd64' \"")
void __declspec(dllimport) spam();
void __declspec(dllexport) call_spam()
{
spam();
}
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/5PDVL7KOBCCIVRSYQH4WXHBCZ23KYKG3/
Code of Conduct: http://python.org/psf/codeofconduct/