psutil icon indicating copy to clipboard operation
psutil copied to clipboard

Add wheels for the free-threaded CPython build & test on CI

Open lysnikolaou opened this issue 10 months ago • 5 comments

Summary

  • OS: All OS's
  • Type: core, wheels

Description

Currently, psutil only offers wheels for the stable ABI. Ideally, we should also provide wheels for the free-threaded CPython build and also test it in CI.

There's also some global state in various places that needs to be locked in case it's intended to be used from multiple threads.

lysnikolaou avatar Apr 21 '25 11:04 lysnikolaou

Note that this was already proposed in gh-2491, with a lot of relevant discussion. The key comment is https://github.com/giampaolo/psutil/pull/2491#issuecomment-2591265995 (wait for abi4). That decision seems a little unfortunate (but it's early days); psutil is quite heavily used, so for CPython 3.14 in a few months it seems like cp314t wheels will help a lot of users. abi4 won't arrive until Python 3.15. Our team will be happy to contribute the extra maintenance effort that may be required to build and support cp314t wheels.

rgommers avatar May 04 '25 19:05 rgommers

There's also some global state in various places that needs to be locked ...

What global state is there?

colesbury avatar May 22 '25 19:05 colesbury

What global state is there?

I only spent a little bit of time on this. In that time I could find the following places:

lysnikolaou avatar May 26 '25 16:05 lysnikolaou

Thanks, that's helpful. For things like psutil_xfiles, I think we should make the state local to the function call (psutil_net_connections) instead of adding locking.

colesbury avatar May 26 '25 16:05 colesbury

For things like that (psutil_xfiles) feel free to open individual PRs (actually it's better).

giampaolo avatar May 26 '25 17:05 giampaolo

All of the PRs fixing places where global state is used have been merged. I've opened #2609 to build cp313t wheels. There's one test failure that seems to be unrelated to the changes we did (it fails while building cp313 (gil-enabled) wheels).

lysnikolaou avatar Aug 08 '25 14:08 lysnikolaou

psutil.users() on UNIX systems also has some issues: https://github.com/giampaolo/psutil/issues/2614.

giampaolo avatar Aug 08 '25 15:08 giampaolo

#2614 has been resolved, so I think #2609 is next to build free-threaded wheels.

lysnikolaou avatar Sep 02 '25 08:09 lysnikolaou

I reverted https://github.com/giampaolo/psutil/pull/2590 since it was causing a segfault.

giampaolo avatar Sep 02 '25 22:09 giampaolo

any hope to get 3.14 and 3.14t wheels at next release ?

stonebig avatar Oct 19 '25 13:10 stonebig

py313t wheels added as of https://github.com/giampaolo/psutil/pull/2609.

giampaolo avatar Oct 23 '25 21:10 giampaolo

py314t wheels added in https://github.com/giampaolo/psutil/pull/2659. I'll publish a release soon.

giampaolo avatar Oct 25 '25 09:10 giampaolo

And it's done. Release 7.1.2 with free-thread wheels is out! Thanks all.

giampaolo avatar Oct 25 '25 10:10 giampaolo

Blog post. @lysnikolaou I took the liberty to mention you: https://gmpy.dev/blog/2025/wheels-for-free-threaded-python-now-available-in-psutil

giampaolo avatar Oct 25 '25 13:10 giampaolo