Skip to content

2nd try at adding no-GIL support#2686

Draft
clin1234 wants to merge 84 commits intomhammond:mainfrom
clin1234:nogil+swig4
Draft

2nd try at adding no-GIL support#2686
clin1234 wants to merge 84 commits intomhammond:mainfrom
clin1234:nogil+swig4

Conversation

@clin1234
Copy link
Contributor

@clin1234 clin1234 commented Dec 2, 2025

Should resolve #2303

Also interesting observations about test failures:

On no-GIL interpreters running on x86, only one test failure occurs: https://github.com/clin1234/pywin32/actions/runs/19752747214/job/56598607801#step:10:381

On x64, multiple test failures occur: https://github.com/clin1234/pywin32/actions/runs/19752747214/job/56598607814#step:10:463

Copy link
Owner

@mhammond mhammond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't get far here - I check the first dozen or so files and none of the changes I saw were related to the gil at all.

Co-authored-by: Avasam <samuel.06@hotmail.com>
@Avasam

This comment was marked as resolved.

@clin1234

This comment was marked as resolved.

@@ -1,3 +1,5 @@
Original patch message is as follows:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm all for a swig update (it's oooooooold, and I'd like to look into type-stubs autogeneration solutions, such as swig/swig#735 (comment)), but I have 1 concern, and 1 technical debt issue I'd like to raise up.

First, I would highly prefer for @mhammond (or another maintainer, could be me, but Mark himself would be best) to regenerate the binary files. Out of principle for open source trust, since binary files cannot meaningfully be inspected or reviewed. (the XZ Utils backdoor is still fresh in my memory).

Second, I haven't looked too deeply into the patching of the SWIG source code we do, but I wonder if it can be reduced. Are there new features/configurations released in the past 26-28 years that can help us? Is there anything we can request upstream ? (just like how I've actively been fixing and updating setuptools/distutils to remove our MSVCCompiler hack). If we could eventually replace the vendored SWIG by https://pypi.org/project/swig/ it would be the dream.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do, as I don't have access to MSVC

@Avasam
Copy link
Collaborator

Avasam commented Dec 9, 2025

On no-GIL interpreters running on x86, only one test failure occurs: clin1234/pywin32/actions/runs/19752747214/job/56598607801#step:10:381

If it's only PythonWin failing, I personally wouldn't mind partial free-threaded support that omits the editor. As Mark once said: #2450 (review)

[...] I sure wouldn't recommend people looking for an IDE to try pythonwin

#line 640 "configure"
#include "confdefs.h"
-main(){return(0);}
+int main(){return(0);}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are any of these new patch addition necessary?

As for removing redundant patches, as well as fixing bad patch file formatting, I open #2694

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently so, as I was testing compilation with a modern clang version

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, were any SWIG changes necessary, not to compile SWIG itself on modern tooling. But did you need a new binary for any of your other code changes here.

The only actual differences I can find in this patch are add int before main and removing a register keyword

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None for the SWIG interface files, afaik

Copy link
Collaborator

@Avasam Avasam Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SWIG updated in #2694 to drop obsolete Python 2 support.

Looking at all the changes under SWIG/* it seems mostly like adding the source code and not files that were needed for free-threaded/no-GIL support ?

Co-authored-by: Avasam <samuel.06@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Free-threaded support?

3 participants