Meta: Status of free-threaded support and prebuilt wheels
Hi @pthom, thought about creating a tracker to raise awareness for the status of freethreaded wheels of the project.
While I'm personally not fully invested into the experimental mode yet, imgui-bundle is one of the few dependencies in all my projects without prebuilt wheels for it. The demo script PYTHON_GIL=0 imgui_bundle_demo ran without any immediate problems, segfaults, or artifacts with a uv's managed cpython-3.13.3+freethreaded-linux-x86_64-gnu interpreter - or perhaps I didn't notice or test enough.
However, I'm fully aware you have no current official support for it, as importing the package raises the following warning. I didn't try to spawn many threads, sharing resources (bad thing in opengl), concurrently modifying states, etc tho.
Point is, at least it run.
<frozen importlib._bootstrap>:488: RuntimeWarning: The global interpreter lock (GIL) has been enabled to
load module 'imgui_bundle._imgui_bundle', which has not declared that it can run safely without the GIL.
To override this behavior and keep the GIL disabled (at your own risk), run with PYTHON_GIL=0 or -Xgil=0.
Sidenote: Per issue #345, I had to compile from source as cmake updated, which will be fixed in the next release of yours.
I stumbled on the discussion https://github.com/pthom/imgui_bundle/discussions/334#discussioncomment-13215023, but you seem worried of PyPI storage limits and I left a comment for the possibility to increase it via their support. Linking the points, I can understand why this isn't a priority nor currently a wanted feature that would be "wasted" space in a synthetic issue Python itself is technically accountable for. Given that it at least runs, experimental support for it shouldn't be too far away, the risk is opt-in at the end of the day!
Not really trying to make a point or request here, I myself haven't updated my own stuff to support freethread mode.
Just asking to at least have it on your low priority list, thanks for your time 🙂
Hi, @Tremeschin
Thanks a lot for taking the time to test this and report your results!
Building free-threaded wheels is not in my immediate todo, as it adds quite a lot of configurations to test.
However, I'll keep it in the low priority list, as you suggested, and hence this issue will remain open.
To be honest, I did not explore at all this subject, and I don't know which changes might be required to make a native wheel compatible with free-threaded mode. Since you did it in your LibTurbo project, can you provide additional info (links, docs, etc)?
Awesome, thanks for considering it!
Perhaps once python supports a single wheel for both variants, as seen in https://github.com/giampaolo/psutil/pull/2491#issuecomment-2591035396, it could be a good starting point for some initial work and experimental releases on the matter, just mentioning.
Since you did it in your LibTurbo project, can you provide additional info (links, docs, etc)?
Ah, I had simply enabled the CI for a future patch release as it ran fine without changes on initial testing last year, but I'm yet to mark support for it in the cpython code to remove those warnings and test it properly.
The C++ part contains quite complex threading, signaling, mutexes, etc, but I'm not changing or extending any python object states there (which is mostly the breaking changes of freethreaded), I got lucky, no/minor changes necessary.
Otherwise, while searching for status of freethreaded in a couple other packages, I've naturally found good resources for it like this comment https://github.com/python-pillow/Pillow/issues/8199#issuecomment-2208871462, that's all I have today for you 😅
Just to add some more info:
I could confirm that is seems to work when enabling freethreading. I could compile and test wheels where it is enabled and they seem to work. It is understandable since the GUI needs to run on the main thread.
The branch freethreading_experimental demoes it. It was not merged to the main branch.
However I did not make any change other than enabling support for it: some globals remain, especially on ImGui side. It is perhaps not a big deal since once again the gui is supposed to run on the main thread.
Related Commit: https://github.com/pthom/imgui_bundle/commit/e58ff916242fe963f9563ad8cd4ae9f238a3a8fe
Related Wheels: https://github.com/pthom/imgui_bundle/actions/runs/19680106845
Note: in this branch, freethreaded wheels on windows are disabled for obscure link errors.