-
Notifications
You must be signed in to change notification settings - Fork 844
Integrate PyCOMTest server dll into CI workflow #2493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…dll. Also changed '.gitignore' to put the Visual Studio solution and pjoject files under revision control.
PyCOMTest server dll to the CI workflow.
OK, the problem was that the However, building it locally with Visual Studio 2022 does not work anymore because even with the v142 tools installed it's missing some ATL header files. So the checked in Visual Studio project file is in fact for Visual Studio 2019 and to build with Visual Studio 2022 locally it needs to be retargeted back to v143. |
This will include PyCOMTest in the tests of the github CI workflow.
I'm so stupid. How could I forget to register the dll with regsvr32 after building it? Now for the next problem. To be honest, I encountered the same problem when I ran the tests locally but didn't care because it had nothing to do with the COM Record stuff on which I was working at that time. Therefore I simply commented the StringTest out. The problem is caused by a unicode character. @Avasam @mhammond Any idea what could cause the issue? At least we're a step further and the PyCOMTest runs in the CI workflow. |
I think And if you fix that, I'm also pretty sure at line 29 it's supposed to be a I was already piling up typo fixes, so I created a PR and included replacing |
a459c0e
to
91b8050
Compare
@Avasam Thank you for the suggestion. However, the result is still negative and I'm at my wits end.
|
91b8050
to
7962e53
Compare
We're obviously dealing here with a character encoding mess. After a little more testing I can say that there's not just a difference between the string returned from the COM server and the Python string but also a problem with the character encoding in the display of the github CI workflow output. The Python string which is reported as The string returned by the COM server is still wrong, although I have no idea which character encoding the github CI workflow output is using to render this as the plain registered trademark sign. On my local machine it's rendered as 'Hello Wo®ld', i.e. with a capital A avec accent circonfelxe before the registered trademark sign. To get a better idea what is returned by the COM server and how that compares to the expected Python string, I added some code to encode both strings to 'utf-32' with the following result:
So the problem is still in the IDL file. However, I don't want to spend more time on this issue. So if nobody else knows a remedy this will get stuck here. :-( |
7962e53
to
0c60173
Compare
Finally I found the way to fix the issue with the registered trademark sign. Investigation of the IDL file with a hex-editor showed that there was the byte sequence 0xC2, 0xAE for the utf-8 encoded registered trademark sign. I changed my editor to save the file ANSI encoded instead of utf-8 so that now there's just 0xAE for the registered trademark sign. This makes the StringTest pass successfully. So it looks like the IDL file needs to be saved ANSI encoded. Unfortunately PyCOMTest now still fails a little further down when trying to get the CoPyComTest class by CLSID. This does not happen when I run it locally. |
Locally I fail at
But other than that I can also confirm everything else passes locally. So there's something different with the CI.
Could take a look at the generated python from genpy |
Far out, what a mess :( So the udl compiler assumes a specific encoding? |
In https://github.com/Avasam/pywin32/tree/refs/heads/testing-for-PyCOMTest_server I hackily made the CI upload the gen_py folder content as an artifact. Here's the CI's Edit: I ran You can see that |
Alright, narrowing down the issue to being that when run under >>> from win32com.client.CLSIDToClass import *
>>> GetClass("{8EE0C520-5605-11D0-AE5F-CADD4C000000}")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Avasam\AppData\Local\Programs\Python\Python310\lib\site-packages\win32com\client\CLSIDToClass.py", line 52, in GetClass
return mapCLSIDToClass[clsid]
KeyError: '{8EE0C520-5605-11D0-AE5F-CADD4C000000}'
>>> import importlib
>>> importlib.import_module('win32com.gen_py.6BCDCB60-5605-11D0-AE5F-CADD4C000000x0x1x1.CoPyCOMTest')
<module 'win32com.gen_py.6BCDCB60-5605-11D0-AE5F-CADD4C000000x0x1x1.CoPyCOMTest' from 'C:\\Users\\Avasam\\AppData\\Local\\Temp\\gen_py\\3.10\\6BCDCB60-5605-11D0-AE5F-CADD4C000000x0x1x1\\CoPyCOMTest.py'>
>>> GetClass("{8EE0C520-5605-11D0-AE5F-CADD4C000000}")
<class 'win32com.gen_py.6BCDCB60-5605-11D0-AE5F-CADD4C000000x0x1x1.CoPyCOMTest.CoPyCOMTest'>
But when it already exists as a package, only |
@Avasam I'm a little confused by your findings because I don't understand where in the code the PyCOMTestLib module is generated as a package. Is the 6BCDCB60-5605-11D0-AE5F-CADD4C000000x0x1x1 package generated anywhere before the call to As far as I understand the way to force the creation of a package is to pass the |
It would seem like it, since with a Oh also if the module I ended up bissecting the tests, first found the culprit was part of the pywin32/com/win32com/test/testArrays.py Line 54 in c0f06cf
Adding
|
Add bForDemand=False to testArrays.py
Currently something is wrong with the CI workflow.
|
Back to the main topic although we can't do much until the issue with the CI pipeline is solved. Thank you @Avasam for taking the effort to bisect the tests.
Good question, especially because everywhere else in
If I remember correctly, somewhere in the code is a comment that suggests, that the main reason for implementing the package stuff was to speed up the process for large type libraries by creating only those interface modules of a component that are actually required. I would therefore expect that it shouldn't affect functionality whether you set
No. |
Wooh! Progress. The non 3.8 CI failures are unrelated and something I noticed as well in a different PR. I'll have to investigate separately. The |
Probably just to test
Right, that sounds correct - the intent was I'll try and re-read some of the above soon, but let me know if there are other specific problems here (it sounds like you might have got past this though?)
Not sure if this is still blocking you, but this is generated from the .mc file - iirc, distutils etc handled this, although there is an ominous comment here |
I fixed the unrelated CI build failure in #2498 |
This was initially implemented in commit 17fb589 to address mhammond#1699. The initial implementation had a problem with bool() (see mhammond#1753). The problem was caused by implementing __nonzero__ instead of __bool__, which was pointed out in the conclusion of mhammond#1870. The commit c072ff7 tried to fix mhammond#1753 but introduced another issue mhammond#1870.
Finally this is good to go. The last commit will also close #1870 which did in the last comment already provide the solution for the |
I also recently read that issue and figured it was likely related. But unfortunately was too occupied right now to try the changes myself. (GitHub reviews on the go are easy to do ^^) Thanks a lot for taking your time to resolve all this! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see the build script in .github/workflows/main.yml
moved to a local script file that can easily be run locally as well. And added to https://github.com/mhammond/pywin32/tree/main/com/win32com/test/readme.txt 's documentation. But I'm perfectly happy seeing this merged as-is and making said changes myself as a follow-up.
Waiting for @mhammond 's review.
Would you like to add a change entry for the #1870 fix ? |
Thanks! |
This pull request addresses issue #2492 and does in a first step add a Visual Studio solution file and a project file, to enable the building and registration of the PyCOMTest server dll with a recent compiler.
The configuration file for the github CI workflow was modified to perform the compilation of the PyCOMTest server dll before running the unit tests.
closes #2492, closes #1870