Closed cjw1115 closed 1 year ago
Here is how I build the bindings:
Build the bindings generator (pywinrt.exe
). This is a program that generates C++ code based on WinRT metadata.
cd src\scripts\windows
vsdevcmd-build.cmd
Set up a VS 2019 x64 dev environment in Power Shell.
Import-Module "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\Community\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
Enter-VsDevShell -VsInstallPath "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\Community" -DevCmdArguments '-arch=x64'
In the dev environment, run the generate and build scripts.
cd src\package\pywinrt\projection
.\generate.ps1
.\build.ps1
generate.ps1
uses cppwinrt.exe
(from NuGet) and pywinrt.exe
(that we built) to generate C++ code that gets compiled by the build.ps1
script.
There is a -fullProjection
argument for generate.ps1
to build all of the WinRT modules, otherwise just a select few are built.
I'm not sure what would be required to bind your own component, but if cppwinrt can do it, pywinrt can probably do it too.
Thank you @dlech Now I can build the whole py/winrt module on my device, got a correct _winrt.pyd. And I also try to call some winrt API from my test python script, it works well!
Under the help of @dlech , I can projection my own winmd file, it works. But a expected error "Class not registered" is thrown in runtime. In win32 or .Net framework project, we can try to add manifest to indicate our COM dll, but in python, I don't know how to do that. Do you have any idea? Thanks!
This issue is stale because it has been open 10 days with no activity. Remove stale label or comment or this will be closed in 5 days.
When I try to build the pywinrt.exe myself, I didn't get the file _winrt,pyd. Then I download the latest winrt in pip, the package contains the _winrt.pyd.
So I have two questions
Thanks