pywin32 icon indicating copy to clipboard operation
pywin32 copied to clipboard

Regenerate `pywin32_swig.patch` without Python 2 concerns

Open Avasam opened this issue 3 weeks ago • 8 comments

  • Replaced MODINIT_ERROR_RETURN macro usages with NULL
  • Fixed patch (trailing spaces are necessary otherwise git considers it "corrupted")
  • Reapplied the patch to swig1.1p5
  • Removed Python 2 codepaths (including the MODINIT_ERROR_RETURN macro) and minimal fix to makefiles for modern MSVC
  • Regenerated the patch file using git bas/MINGW64's diff tool.
  • Mention --ignore-space-change to avoind git thinking "this patch doesn't apply" due to line ending differences

Will reduce changes in https://github.com/mhammond/pywin32/pull/2686

Avasam avatar Dec 11 '25 05:12 Avasam

This seems fine, but I guess we are going to want a new executable too? ie, I'm not sure it makes sense to land this if it means the exe and this patch are inconsistent?

mhammond avatar Dec 11 '25 05:12 mhammond

right, I see #2686 also wants to modify this. I guess this seems fine if it helps keep that ball rolling (although I wonder how far that ball will actually roll!)

mhammond avatar Dec 11 '25 05:12 mhammond

We can have a new executable yeah, I see your point. Even though it should work the same.

If you don't wanna bother building a new one now, I could split up this PR into just fixing the patch and tool configs so git stops rejecting it.

Btw I noticed my patch generation had quite a different style, idk if it's because whoever wrote the original patch maybe did it with a different tool than git diff

Avasam avatar Dec 11 '25 05:12 Avasam

I suspect that patch predates git? But if you can verify locally the patch applies and makes a new executable which works I'm happy to have this merged

mhammond avatar Dec 11 '25 05:12 mhammond

Alright, I'll try to build SWIG locally and ensure that it still results in a valid pywin32 build. I'm off to bed for tonight though.

Avasam avatar Dec 11 '25 05:12 Avasam

(although I wonder how far that ball will actually roll!)

Me too. There's definitely some good changes from clin's attempt (like the new stable ABI functions for objects type and refcount). So I'll help take it piecemeal.

Avasam avatar Dec 11 '25 05:12 Avasam

I've had to fix include paths. I quickly did so by replacing INCLUDE with INCFLAGS and remove all STD_INC from make files.

But it did build a new swig.exe which I then used to successfully build pywin32. I can even confirm that pywin32 fails to build if I build swig without the patch (because of Python 2 code).

Do you want me to include the minimal makefile changes as well ?

Should I include the new swig executable in this PR or did you simply want me to make sure the patch was truly still valid ?

Avasam avatar Dec 14 '25 03:12 Avasam

Do you want me to include the minimal makefile changes as well ?

Should I include the new swig executable in this PR or did you simply want me to make sure the patch was truly still valid ?

I think you should include both if you don't mind. I'm not currently in a position to be able to regenerate the executables and you've been here long enough that I trust you to do that :) Thanks!

mhammond avatar Dec 14 '25 23:12 mhammond