Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 7 additions & 13 deletions _msbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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'),
Expand Down Expand Up @@ -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',
),
)


Expand Down
2 changes: 1 addition & 1 deletion ci/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
16 changes: 8 additions & 8 deletions src/pymanager/appxmanifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Package IgnorableNamespaces="desktop4 desktop6 desktop7 uap13 uap17"
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:com="http://schemas.microsoft.com/appx/manifest/com/windows10"
xmlns:com4="http://schemas.microsoft.com/appx/manifest/com/windows10/4"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
xmlns:rescap4="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities/4"
xmlns:desktop4="http://schemas.microsoft.com/appx/manifest/desktop/windows10/4"
Expand Down Expand Up @@ -194,20 +194,20 @@
</uap:SupportedFileTypes>
</uap:FileTypeAssociation>
</uap:Extension>
<com:Extension Category="windows.comServer">
<com:ComServer>
<com:SurrogateServer AppId="C7E29CB0-9691-4DE8-B72B-6719DDC0B4A1" DisplayName="EditInIdleCommand">
<com:Class Id="C7E29CB0-9691-4DE8-B72B-6719DDC0B4A1" Path="pyshellext.dll" ThreadingModel="Both"/>
</com:SurrogateServer>
</com:ComServer>
</com:Extension>
<desktop4:Extension Category="windows.fileExplorerContextMenus">
<desktop4:FileExplorerContextMenus>
<desktop4:ItemType Type=".py">
<desktop4:Verb Id="EditInIdle" Clsid="C7E29CB0-9691-4DE8-B72B-6719DDC0B4A1" />
</desktop4:ItemType>
</desktop4:FileExplorerContextMenus>
</desktop4:Extension>
<com4:Extension Category="windows.comServer">
<com4:ComServer>
<com4:ExeServer Executable="pyshellext.exe" DisplayName="Python Shell Extension">
<com4:Class Id="C7E29CB0-9691-4DE8-B72B-6719DDC0B4A1" DisplayName="EditInIdleCommand" />
</com4:ExeServer>
</com4:ComServer>
</com4:Extension>
</Extensions>
</Application>

Expand Down
13 changes: 10 additions & 3 deletions src/pymanager/msi.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,17 @@
<File Source="vcruntime140.dll" />
<File Source="vcruntime140_1.dll" />

<File Source="pyshellext.dll">
<Class Id="{C7E29CB0-9691-4DE8-B72B-6719DDC0B4A1}" Advertise="no"
Context="InprocServer32" ThreadingModel="both" />
<!--
When installed via MSIX, this extension must be out of proc.
Apparently, when installed via MSI, it must be in proc. Which means we'd
need to compile DLLs for each platform just for the MSI, as well as the
EXE that we use for regular installs.
Right now, not worth it.

<File Source="pyshellext.exe">
<Class Id="{C7E29CB0-9691-4DE8-B72B-6719DDC0B4A1}" Advertise="no" Context="LocalServer32" />
</File>
-->

<File Source="version.txt" />
<Environment Id="PATH" Action="set" Name="PATH" Part="last" System="yes" Value="[INSTALLFOLDER]" />
Expand Down
3 changes: 0 additions & 3 deletions src/pyshellext/pyshellext.def

This file was deleted.

37 changes: 19 additions & 18 deletions src/pyshellext/shellext.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Support back to Windows 10
#define _WIN32_WINNT _WIN32_WINNT_WIN10
#include <sdkddkver.h>

// Use WRL to define a classic COM class
#define __WRL_CLASSIC_COM__
#include <wrl.h>

Expand Down Expand Up @@ -454,24 +452,27 @@ IExplorerCommand *MakeIdleCommand(HKEY hive, LPCWSTR root)
#endif


STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, _COM_Outptr_ void** ppv)
{
return Module<InProc>::GetModule().GetClassObject(rclsid, riid, ppv);
}

#ifndef PYSHELLEXT_TEST
class OutOfProcModule : public Module<OutOfProc, OutOfProcModule>
{ };

STDAPI DllCanUnloadNow()
{
return Module<InProc>::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