Skip to content

Commit 1153d48

Browse files
committed
Add ABI3T_COMPAT_DLLNAME
1 parent 5db5a47 commit 1153d48

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

PCbuild/pyproject.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
<_PlatformPreprocessorDefinition Condition="$(Platform) == 'x64'">_WIN64;</_PlatformPreprocessorDefinition>
5050
<_PlatformPreprocessorDefinition Condition="$(Platform) == 'x64' and $(PlatformToolset) != 'ClangCL'">_M_X64;$(_PlatformPreprocessorDefinition)</_PlatformPreprocessorDefinition>
5151
<_Py3NamePreprocessorDefinition>PY3_DLLNAME=L"$(Py3DllName)$(PyDebugExt)";</_Py3NamePreprocessorDefinition>
52+
<_Abi3tCompatDllNamePreprocessorDefinition Condition="$(DisableGil) != 'true'">ABI3T_COMPAT_DLLNAME=L"$(PyAbi3tCompat3DllName)$(PyDebugExt)";</_Abi3tCompatDllNamePreprocessorDefinition>
5253
<_FreeThreadedPreprocessorDefinition Condition="$(DisableGil) == 'true'">Py_GIL_DISABLED=1;</_FreeThreadedPreprocessorDefinition>
5354
<_PymallocHugepagesPreprocessorDefinition Condition="$(UsePymallocHugepages) == 'true'">PYMALLOC_USE_HUGEPAGES=1;</_PymallocHugepagesPreprocessorDefinition>
5455
</PropertyGroup>
@@ -57,6 +58,7 @@
5758
<AdditionalIncludeDirectories>$(PySourcePath)Include;$(PySourcePath)Include\internal;$(PySourcePath)Include\internal\mimalloc;$(PySourcePath)PC;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
5859
<PreprocessorDefinitions>WIN32;$(_Py3NamePreprocessorDefinition)$(_PlatformPreprocessorDefinition)$(_DebugPreprocessorDefinition)$(_PyStatsPreprocessorDefinition)$(_PydPreprocessorDefinition)$(_FreeThreadedPreprocessorDefinition)$(_PymallocHugepagesPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
5960
<PreprocessorDefinitions Condition="'$(SupportPGO)' and ($(Configuration) == 'PGInstrument' or $(Configuration) == 'PGUpdate')">_Py_USING_PGO=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
61+
<PreprocessorDefinitions Condition="$(DisableGil) != 'true'">$(_Abi3tCompatDllNamePreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
6062

6163
<Optimization>MaxSpeed</Optimization>
6264
<IntrinsicFunctions>true</IntrinsicFunctions>

Python/dynload_win.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,16 @@ _Py_CheckPython3(void)
169169
use that DLL */
170170
if (PyWin_DLLhModule && GetModuleFileNameW(PyWin_DLLhModule, py3path, MAXPATHLEN)) {
171171
wchar_t *p = wcsrchr(py3path, L'\\');
172+
172173
if (p) {
174+
#ifdef ABI3T_COMPAT_DLLNAME
175+
wcscpy(p + 1, ABI3T_COMPAT_DLLNAME);
176+
hPython3 = LoadLibraryExW(py3path, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
177+
if (hPython3 != NULL) {
178+
return 1;
179+
}
180+
#endif
181+
173182
wcscpy(p + 1, PY3_DLLNAME);
174183
hPython3 = LoadLibraryExW(py3path, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
175184
if (hPython3 != NULL) {
@@ -178,6 +187,13 @@ _Py_CheckPython3(void)
178187
}
179188
}
180189

190+
#ifdef ABI3T_COMPAT_DLLNAME
191+
hPython3 = LoadLibraryExW(ABI3T_COMPAT_DLLNAME, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR);
192+
if (hPython3 != NULL) {
193+
return 1;
194+
}
195+
#endif
196+
181197
/* If we can locate python3.dll in our application dir,
182198
use that DLL */
183199
hPython3 = LoadLibraryExW(PY3_DLLNAME, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR);

0 commit comments

Comments
 (0)