From f068a0e0fa2b1c27fb53f4aec016378dcb332f47 Mon Sep 17 00:00:00 2001 From: deepend-tildeclub Date: Tue, 7 Jul 2026 15:34:11 -0600 Subject: [PATCH] Fix Windows Python plugin DLL selection --- plugins/python/python38.vcxproj | 64 ++++++++++++++++++++++++++++++++ src/common/plugin.c | 23 +++++++++++- win32/copy/copy.vcxproj | 9 +++-- win32/installer/zoitechat.iss.tt | 6 +-- win32/zoitechat.props | 7 ++++ win32/zoitechat.sln | 9 +++++ 6 files changed, 109 insertions(+), 9 deletions(-) create mode 100644 plugins/python/python38.vcxproj diff --git a/plugins/python/python38.vcxproj b/plugins/python/python38.vcxproj new file mode 100644 index 00000000..688de715 --- /dev/null +++ b/plugins/python/python38.vcxproj @@ -0,0 +1,64 @@ + + + + v142 + DynamicLibrary + + + + Release + Win32 + + + Release + x64 + + + + {D58924D2-1492-4AC3-B058-7A214424EEDC} + Win32Proj + python38 + + + + + + + $(Python38Output) + $(ZoiteChatRel)plugins\ + + + + WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;PYTHON_EXPORTS;Py_NO_LINK_LIB;$(OwnFlags);%(PreprocessorDefinitions) + _DEBUG;Py_DEBUG;Py_REF_DEBUG;Py_TRACE_REFS;%(UndefinePreprocessorDefinitions) + /U_DEBUG /UPy_DEBUG /UPy_REF_DEBUG /UPy_TRACE_REFS %(AdditionalOptions) + MultiThreadedDLL + $(Glib);$(Python38Path)\include;..\..\src\common;$(ZoiteChatLib);%(AdditionalIncludeDirectories) + + + python.def + "$(Python38Lib).lib";$(DepLibs);%(AdditionalDependencies) + $(DepsRoot)\lib;$(Python38Path)\libs;%(AdditionalLibraryDirectories) + + + "$(Python38Path)\python.exe" generate_plugin.py ..\..\src\common\zoitechat-plugin.h python.py "$(IntDir)python.c" + + + + + + + + + + + + + + + + + + + + diff --git a/src/common/plugin.c b/src/common/plugin.c index c570e920..94f023f4 100644 --- a/src/common/plugin.c +++ b/src/common/plugin.c @@ -25,6 +25,7 @@ #ifdef WIN32 #include +#include #else #include #endif @@ -56,6 +57,22 @@ typedef struct session zoitechat_context; #endif #define DEBUG(x) {x;} +#ifdef WIN32 + +static gboolean +plugin_windows_is_windows7 (void) +{ + OSVERSIONINFOEXA version; + + memset (&version, 0, sizeof (version)); + version.dwOSVersionInfoSize = sizeof (version); + if (!GetVersionExA ((OSVERSIONINFOA *)&version)) + return FALSE; + + return version.dwPlatformId == VER_PLATFORM_WIN32_NT && + version.dwMajorVersion == 6 && version.dwMinorVersion == 1; +} +#endif /* crafted to be an even 32 bytes */ struct _zoitechat_hook @@ -491,8 +508,10 @@ plugin_auto_load (session *sess) for_files (lib_dir, "hcfishlim.dll", plugin_auto_load_cb); for_files(lib_dir, "hclua.dll", plugin_auto_load_cb); for_files (lib_dir, "hcperl.dll", plugin_auto_load_cb); - for_files (lib_dir, "hcpython3.dll", plugin_auto_load_cb); - for_files (lib_dir, "hcpython38.dll", plugin_auto_load_cb); + if (plugin_windows_is_windows7 ()) + for_files (lib_dir, "hcpython38.dll", plugin_auto_load_cb); + else + for_files (lib_dir, "hcpython3.dll", plugin_auto_load_cb); for_files (lib_dir, "hcupd.dll", plugin_auto_load_cb); for_files (lib_dir, "hcsysinfo.dll", plugin_auto_load_cb); #else diff --git a/win32/copy/copy.vcxproj b/win32/copy/copy.vcxproj index 2d0a3479..71500afd 100644 --- a/win32/copy/copy.vcxproj +++ b/win32/copy/copy.vcxproj @@ -66,6 +66,7 @@ + @@ -105,10 +106,10 @@ - - - - + + + + diff --git a/win32/installer/zoitechat.iss.tt b/win32/installer/zoitechat.iss.tt index 26c95a76..f0bf41a3 100644 --- a/win32/installer/zoitechat.iss.tt +++ b/win32/installer/zoitechat.iss.tt @@ -181,8 +181,8 @@ Source: "plugins\hcperl.dll"; DestDir: "{app}\plugins"; Flags: ignoreversion; Co Source: "python\*.py"; DestDir: "{app}\python"; Flags: ignoreversion; Components: langs\python -Source: "plugins\hcpython3.dll"; DestDir: "{app}\plugins"; Flags: ignoreversion; Components: langs\python -Source: "plugins\hcpython38.dll"; DestDir: "{app}\plugins"; Flags: ignoreversion skipifsourcedoesntexist; Components: langs\python +Source: "plugins\hcpython3.dll"; DestDir: "{app}\plugins"; Flags: ignoreversion; Components: langs\python; Check: not IsWindows7 +Source: "plugins\hcpython38.dll"; DestDir: "{app}\plugins"; Flags: ignoreversion skipifsourcedoesntexist; Components: langs\python; Check: IsWindows7 Source: "_cffi_backend.cp3*.pyd"; DestDir: "{app}"; Flags: ignoreversion; Components: langs\python Source: "zoitechat.exe"; DestDir: "{app}"; Flags: ignoreversion; Components: libs @@ -382,7 +382,7 @@ begin REDIST := 'https://aka.ms/vs/17/release/vc_redist.x64.exe'; PERL := 'https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_54201_64bit/strawberry-perl-5.42.0.1-64bit.msi'; PY3 := PythonURL(); - SPELL := 'https://github.com/zoitechat/gvsbuild/releases/download/zoitechat-2.16.2/ZoiteChat.Spelling.Dictionaries.r2.exe'; + SPELL := 'https://github.com/hexchat/gvsbuild/releases/download/hexchat-2.16.2/HexChat.Spelling.Dictionaries.r2.exe'; if WizardIsComponentSelected('deps\vcredist2015') and not CheckVCInstall() then idpAddFile(REDIST, ExpandConstant('{tmp}\vcredist.exe')); diff --git a/win32/zoitechat.props b/win32/zoitechat.props index b6d1ccf1..daf9bcfa 100644 --- a/win32/zoitechat.props +++ b/win32/zoitechat.props @@ -8,6 +8,7 @@ c:\gtk-build\gendef c:\gtk-build\perl-5.42.0.1 c:\gtk-build\python-3.14 + c:\gtk-build\python-3.8.10 c:\gtk-build\WinSparkle @@ -32,6 +33,12 @@ true false + $(YourPython38Path)\$(ZoiteChatPlatform) + python38 + hcpython38 + true + false + true false diff --git a/win32/zoitechat.sln b/win32/zoitechat.sln index fb24a62b..969c74eb 100644 --- a/win32/zoitechat.sln +++ b/win32/zoitechat.sln @@ -60,6 +60,7 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "installer", "installer\installer.vcxproj", "{5A0F4962-E670-4DA2-9E45-52CC47F26E2F}" ProjectSection(ProjectDependencies) = postProject {C2321A03-0BA7-45B3-8740-ABD82B36B0BF} = {C2321A03-0BA7-45B3-8740-ABD82B36B0BF} + {D58924D2-1492-4AC3-B058-7A214424EEDC} = {D58924D2-1492-4AC3-B058-7A214424EEDC} {BF0EBC16-68AD-4CD1-864C-5B56836EBE2A} = {BF0EBC16-68AD-4CD1-864C-5B56836EBE2A} {17E4BE39-76F7-4A06-AD21-EFD0C5091F76} = {17E4BE39-76F7-4A06-AD21-EFD0C5091F76} {4C0F3940-2EEE-4646-82F7-6CE75B9A72F4} = {4C0F3940-2EEE-4646-82F7-6CE75B9A72F4} @@ -80,6 +81,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "perl", "..\plugins\perl\per {87554B59-006C-4D94-9714-897B27067BA3} = {87554B59-006C-4D94-9714-897B27067BA3} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python38", "..\plugins\python\python38.vcxproj", "{D58924D2-1492-4AC3-B058-7A214424EEDC}" + ProjectSection(ProjectDependencies) = postProject + {87554B59-006C-4D94-9714-897B27067BA3} = {87554B59-006C-4D94-9714-897B27067BA3} + EndProjectSection +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python3", "..\plugins\python\python3.vcxproj", "{C2321A03-0BA7-45B3-8740-ABD82B36B0BF}" ProjectSection(ProjectDependencies) = postProject {87554B59-006C-4D94-9714-897B27067BA3} = {87554B59-006C-4D94-9714-897B27067BA3} @@ -127,6 +133,8 @@ Global {D90BC3E3-1341-4849-9354-5F40489D39D1}.Release|x64.Build.0 = Release|x64 {C2321A03-0BA7-45B3-8740-ABD82B36B0BF}.Release|x64.ActiveCfg = Release|x64 {C2321A03-0BA7-45B3-8740-ABD82B36B0BF}.Release|x64.Build.0 = Release|x64 + {D58924D2-1492-4AC3-B058-7A214424EEDC}.Release|x64.ActiveCfg = Release|x64 + {D58924D2-1492-4AC3-B058-7A214424EEDC}.Release|x64.Build.0 = Release|x64 {C53145CC-D021-40C9-B97C-0249AB9A43C9}.Release|x64.ActiveCfg = Release|x64 {C53145CC-D021-40C9-B97C-0249AB9A43C9}.Release|x64.Build.0 = Release|x64 {BF0EBC16-68AD-4CD1-864C-5B56836EBE2A}.Release|x64.ActiveCfg = Release|x64 @@ -151,6 +159,7 @@ Global {5A0F4962-E670-4DA2-9E45-52CC47F26E2F} = {0FD996A7-464F-4981-8380-3DCA3A244A13} {D90BC3E3-1341-4849-9354-5F40489D39D1} = {D237DA6B-BD5F-46C0-8BEA-50E9A1340240} {C2321A03-0BA7-45B3-8740-ABD82B36B0BF} = {D237DA6B-BD5F-46C0-8BEA-50E9A1340240} + {D58924D2-1492-4AC3-B058-7A214424EEDC} = {D237DA6B-BD5F-46C0-8BEA-50E9A1340240} {C53145CC-D021-40C9-B97C-0249AB9A43C9} = {561126F4-FA18-45FC-A2BF-8F858F161D6D} {BF0EBC16-68AD-4CD1-864C-5B56836EBE2A} = {021EC1D0-FF67-4700-9AB2-EAABF1159C09} {4C0F3940-2EEE-4646-82F7-6CE75B9A72F4} = {D237DA6B-BD5F-46C0-8BEA-50E9A1340240}