Skip to content

Add support for MinGW#214

Merged
albertosottile merged 12 commits intopy2exe:masterfrom
raedrizqie:py2exe-mingw
Nov 12, 2024
Merged

Add support for MinGW#214
albertosottile merged 12 commits intopy2exe:masterfrom
raedrizqie:py2exe-mingw

Conversation

@raedrizqie
Copy link
Copy Markdown
Contributor

Fixes #191

Tested with a simple hello world program on both python 3.11 and 3.12

Thanks to @AraHaan for the _memimporter fix: #191 (comment)
Thanks to @sdbbs for the dllfinder fix: #1 (comment)

Note: I don't know why the matplotlib test fails though

@albertosottile
Copy link
Copy Markdown
Member

albertosottile commented Nov 11, 2024

Thanks for contribution. Before I can get into the real review (it will take some time on my side), I have two questions:

  • would it be possible to split this in two PRs (MinGW and 3.12)? I feel that the MinGW part could be much easier to review, much less controversial, and bring value immediately
  • re compatibility with 3.12, how is the proposed solution supposed to help with loading the Python 3.12 DLL from memory (in other words, to work with bundle_files <= 1)?

@raedrizqie
Copy link
Copy Markdown
Contributor Author

ok, thanks for the suggestions.. i will split the PR

@raedrizqie raedrizqie changed the title Add support for MinGW and fix building with Python 3.12 Add support for MinGW Nov 12, 2024
Copy link
Copy Markdown
Member

@albertosottile albertosottile left a comment

Choose a reason for hiding this comment

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

I left a few comments. General thought: I am willing to merge this PR as it is (if we are able to make all the tests pass, currently working on that). However, please be advised that MinGW is not a test target of this project and I personally do not intend to actively support it. Therefore, there is a chance that every single future commit could break this compatibility.

@raedrizqie
Copy link
Copy Markdown
Contributor Author

I left a few comments. General thought: I am willing to merge this PR as it is (if we are able to make all the tests pass, currently working on that). However, please be advised that MinGW is not a test target of this project and I personally do not intend to actively support it. Therefore, there is a chance that every single future commit could break this compatibility.

No worries, MSYS2 will maintain this package :)

@albertosottile
Copy link
Copy Markdown
Member

No worries, MSYS2 will maintain this package :)

That's good to hear. But then, would you like to add one (or more) MinGW test target in the Actions workflow?

@albertosottile albertosottile merged commit e9c5f0e into py2exe:master Nov 12, 2024
@albertosottile
Copy link
Copy Markdown
Member

Thank you again for this PR!

@raedrizqie
Copy link
Copy Markdown
Contributor Author

Thank you too!

@raedrizqie raedrizqie deleted the py2exe-mingw branch November 13, 2024 06:49
@AraHaan
Copy link
Copy Markdown

AraHaan commented Nov 14, 2024

Also to add a little note for when 3.13+ needs support.

In windows due to how LoadLibraryA/W loads DLLs with the TLS information that initialization of the python core when bundle_files <= 1 is not possible. The resulting files must be the exe with the python core dll as a separate file from the exe in order for it to be initialized properly. That is unless the dll gets packed into the win32 resource section and just prior to it calling any python C api functions for it to write the dll to the disk. But even then that can break the built in C extensions when the exe does not directly import the core dll in it's IMPORT_ADDRESS_TABLE.

What this means for py2exe:

  • When 3.13+ on python is requested, py2exe must provide both the core dll with the exe. I am sorry that it is currently not possible to single file it for 3.13+.
    • In 3.13+ a bit of required C code inside of import.c in the cpython source code for which _memimporter.c uses was removed so adding them would require build our own custom import.c that contains only the removed functions updated to the call the 3.13+ stable ABI.

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.

Support Python 3.12 py2exe hangs in dllfinder.py

4 participants