diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6bb2a12..4f3b94a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,7 +36,7 @@ jobs: python-version: 3.14-dev - name: Install build dependencies - run: python -m pip install pymsbuild + run: python -m pip install "pymsbuild>=1.2.0b1" - name: 'Install test runner' run: python -m pip install pytest pytest-cov diff --git a/_msbuild.py b/_msbuild.py index cf8f71f..18353d3 100644 --- a/_msbuild.py +++ b/_msbuild.py @@ -149,8 +149,7 @@ def mainw_exe(name): CProject('launcher', VersionInfo(FileDescription="Python launcher", OriginalFilename="launcher.exe"), CPP_SETTINGS, - Property('DynamicLibcppLinkage', 'true'), - ItemDefinition('ClCompile', RuntimeLibrary='MultiThreaded'), + Property('StaticLibcppLinkage', 'true'), ItemDefinition('Link', SubSystem='CONSOLE'), Manifest('default.manifest'), ResourceFile('pyicon.rc'), @@ -163,8 +162,7 @@ def mainw_exe(name): CProject('launcherw', VersionInfo(FileDescription="Python launcher (windowed)", OriginalFilename="launcherw.exe"), CPP_SETTINGS, - Property('DynamicLibcppLinkage', 'true'), - ItemDefinition('ClCompile', RuntimeLibrary='MultiThreaded'), + Property('StaticLibcppLinkage', 'true'), ItemDefinition('Link', SubSystem='WINDOWS'), Manifest('default.manifest'), ResourceFile('pywicon.rc'), @@ -206,24 +204,20 @@ def mainw_exe(name): CProject("pyshellext", VersionInfo( FileDescription="Python shell extension", - OriginalFilename="pyshellext.dll", - ), - Property('DynamicLibcppLinkage', 'true'), - ItemDefinition('ClCompile', - LanguageStandard='stdcpp20', - RuntimeLibrary='MultiThreaded', + OriginalFilename="pyshellext.exe", ), + Property('StaticLibcppLinkage', 'true'), + ItemDefinition('ClCompile', LanguageStandard='stdcpp20'), ItemDefinition('Link', AdditionalDependencies=Prepend("RuntimeObject.lib;"), SubSystem='WINDOWS', - ModuleDefinitionFile='$(SourceRootDir)src\\pyshellext\\pyshellext.def', ), Manifest('default.manifest'), CSourceFile('shellext.cpp'), ResourceFile('pyshellext.rc'), - SourceFile('pyshellext.def'), source='src/pyshellext', - ) + ConfigurationType='Application', + ), ) diff --git a/ci/release.yml b/ci/release.yml index 6e6528a..1542c62 100644 --- a/ci/release.yml +++ b/ci/release.yml @@ -89,7 +89,7 @@ stages: workingDirectory: $(Build.BinariesDirectory) - powershell: | - python -m pip install pymsbuild + python -m pip install "pymsbuild>=1.2.0b1" displayName: 'Install build dependencies' - ${{ if eq(parameters.PreTest, 'true') }}: diff --git a/pyproject.toml b/pyproject.toml index e4d9bdb..76c1914 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ['pymsbuild>=1.1.1,<2.0'] +requires = ['pymsbuild>=1.2.0b1,<2.0'] build-backend = "pymsbuild" [tool.coverage.run] diff --git a/src/pymanager/appxmanifest.xml b/src/pymanager/appxmanifest.xml index bb872fb..5930d6e 100644 --- a/src/pymanager/appxmanifest.xml +++ b/src/pymanager/appxmanifest.xml @@ -2,7 +2,7 @@ - - - - - - - @@ -208,6 +201,13 @@ + + + + + + + diff --git a/src/pymanager/msi.wxs b/src/pymanager/msi.wxs index e843fe2..9abd466 100644 --- a/src/pymanager/msi.wxs +++ b/src/pymanager/msi.wxs @@ -44,10 +44,17 @@ - - + diff --git a/src/pyshellext/pyshellext.def b/src/pyshellext/pyshellext.def deleted file mode 100644 index 751bc6c..0000000 --- a/src/pyshellext/pyshellext.def +++ /dev/null @@ -1,3 +0,0 @@ -EXPORTS - DllGetClassObject PRIVATE - DllCanUnloadNow PRIVATE diff --git a/src/pyshellext/shellext.cpp b/src/pyshellext/shellext.cpp index b38f669..991e816 100644 --- a/src/pyshellext/shellext.cpp +++ b/src/pyshellext/shellext.cpp @@ -1,8 +1,6 @@ -// Support back to Windows 10 #define _WIN32_WINNT _WIN32_WINNT_WIN10 #include -// Use WRL to define a classic COM class #define __WRL_CLASSIC_COM__ #include @@ -454,24 +452,27 @@ IExplorerCommand *MakeIdleCommand(HKEY hive, LPCWSTR root) #endif -STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, _COM_Outptr_ void** ppv) -{ - return Module::GetModule().GetClassObject(rclsid, riid, ppv); -} - +#ifndef PYSHELLEXT_TEST +class OutOfProcModule : public Module +{ }; -STDAPI DllCanUnloadNow() -{ - return Module::GetModule().Terminate() ? S_OK : S_FALSE; -} -#ifndef PYSHELLEXT_TEST -STDAPI_(BOOL) DllMain(_In_opt_ HINSTANCE hinst, DWORD reason, _In_opt_ void*) +int WINAPI wWinMain( + HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPWSTR lpCmdLine, + int nCmdShow +) { - if (reason == DLL_PROCESS_ATTACH) { - hModule = hinst; - DisableThreadLibraryCalls(hinst); - } - return TRUE; + HANDLE hStopEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + hModule = hInstance; + + CoInitializeEx(nullptr, COINIT_MULTITHREADED); + auto& module = OutOfProcModule::Create([=]() { SetEvent(hStopEvent); }); + module.RegisterObjects(); + ::WaitForSingleObject(hStopEvent, INFINITE); + module.UnregisterObjects(); + CoUninitialize(); + return 0; } #endif