public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/psutil/, dev-python/psutil/files/
Date: Mon, 14 Oct 2024 16:54:53 +0000 (UTC)	[thread overview]
Message-ID: <1728924886.59aa1d76b7c23496b717c018ce7819f2008a3f27.mgorny@gentoo> (raw)

commit:     59aa1d76b7c23496b717c018ce7819f2008a3f27
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 14 16:53:55 2024 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Oct 14 16:54:46 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=59aa1d76

dev-python/psutil: Enable py3.13t

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 dev-python/psutil/files/psutil-6.0.0-py313t.patch | 190 ++++++++++++++++++++++
 dev-python/psutil/psutil-6.0.0-r1.ebuild          |  47 ++++++
 2 files changed, 237 insertions(+)

diff --git a/dev-python/psutil/files/psutil-6.0.0-py313t.patch b/dev-python/psutil/files/psutil-6.0.0-py313t.patch
new file mode 100644
index 000000000000..1cdc63ed406e
--- /dev/null
+++ b/dev-python/psutil/files/psutil-6.0.0-py313t.patch
@@ -0,0 +1,190 @@
+From 5c0c0893c7565a39f1ac3f9c286fd1e1c58a7cd6 Mon Sep 17 00:00:00 2001
+From: Sam Gross <colesbury@gmail.com>
+Date: Mon, 24 Jun 2024 17:51:07 +0000
+Subject: [PATCH 1/2] Fix GIL warnings and a few thread-safety issues in
+ free-threaded CPython
+
+- The temporary `argv` C array is no longer global in OpenBSD's
+  proc_cmdline
+- The `maxcpus` variable is no longer global in FreeBSD's per_cpu_times.
+
+Signed-off-by: Sam Gross <colesbury@gmail.com>
+---
+ psutil/_psutil_aix.c       | 3 +++
+ psutil/_psutil_bsd.c       | 4 ++++
+ psutil/_psutil_linux.c     | 4 ++++
+ psutil/_psutil_osx.c       | 4 ++++
+ psutil/_psutil_posix.c     | 4 ++++
+ psutil/_psutil_sunos.c     | 4 ++++
+ psutil/_psutil_windows.c   | 4 ++++
+ psutil/arch/freebsd/cpu.c  | 2 +-
+ psutil/arch/openbsd/proc.c | 4 +++-
+ 9 files changed, 31 insertions(+), 2 deletions(-)
+
+diff --git a/psutil/_psutil_aix.c b/psutil/_psutil_aix.c
+index ce89a7bd7c..42f921188e 100644
+--- a/psutil/_psutil_aix.c
++++ b/psutil/_psutil_aix.c
+@@ -1080,6 +1080,9 @@ void init_psutil_aix(void)
+     PyObject *module = PyModule_Create(&moduledef);
+ #else
+     PyObject *module = Py_InitModule("_psutil_aix", PsutilMethods);
++#endif
++#ifdef Py_GIL_DISABLED
++    PyUnstable_Module_SetGIL(mod, Py_MOD_GIL_NOT_USED);
+ #endif
+     PyModule_AddIntConstant(module, "version", PSUTIL_VERSION);
+ 
+diff --git a/psutil/_psutil_bsd.c b/psutil/_psutil_bsd.c
+index 6517d5800a..facaba831f 100644
+--- a/psutil/_psutil_bsd.c
++++ b/psutil/_psutil_bsd.c
+@@ -143,6 +143,10 @@ static PyMethodDef mod_methods[] = {
+     if (mod == NULL)
+         INITERR;
+ 
++#ifdef Py_GIL_DISABLED
++    PyUnstable_Module_SetGIL(mod, Py_MOD_GIL_NOT_USED);
++#endif
++
+     if (PyModule_AddIntConstant(mod, "version", PSUTIL_VERSION)) INITERR;
+     // process status constants
+ 
+diff --git a/psutil/_psutil_linux.c b/psutil/_psutil_linux.c
+index 292e1c5524..46244c5792 100644
+--- a/psutil/_psutil_linux.c
++++ b/psutil/_psutil_linux.c
+@@ -78,6 +78,10 @@ static PyMethodDef mod_methods[] = {
+     if (mod == NULL)
+         INITERR;
+ 
++#ifdef Py_GIL_DISABLED
++    PyUnstable_Module_SetGIL(mod, Py_MOD_GIL_NOT_USED);
++#endif
++
+     if (PyModule_AddIntConstant(mod, "version", PSUTIL_VERSION)) INITERR;
+     if (PyModule_AddIntConstant(mod, "DUPLEX_HALF", DUPLEX_HALF)) INITERR;
+     if (PyModule_AddIntConstant(mod, "DUPLEX_FULL", DUPLEX_FULL)) INITERR;
+diff --git a/psutil/_psutil_osx.c b/psutil/_psutil_osx.c
+index 4aa11d1700..09fa267a98 100644
+--- a/psutil/_psutil_osx.c
++++ b/psutil/_psutil_osx.c
+@@ -91,6 +91,10 @@ static PyMethodDef mod_methods[] = {
+     if (mod == NULL)
+         INITERR;
+ 
++#ifdef Py_GIL_DISABLED
++    PyUnstable_Module_SetGIL(mod, Py_MOD_GIL_NOT_USED);
++#endif
++
+     if (psutil_setup() != 0)
+         INITERR;
+ 
+diff --git a/psutil/_psutil_posix.c b/psutil/_psutil_posix.c
+index 24628afc78..8ced7beaac 100644
+--- a/psutil/_psutil_posix.c
++++ b/psutil/_psutil_posix.c
+@@ -913,6 +913,10 @@ static PyMethodDef mod_methods[] = {
+     if (mod == NULL)
+         INITERR;
+ 
++#ifdef Py_GIL_DISABLED
++    PyUnstable_Module_SetGIL(mod, Py_MOD_GIL_NOT_USED);
++#endif
++
+ #if defined(PSUTIL_BSD) || \
+         defined(PSUTIL_OSX) || \
+         defined(PSUTIL_SUNOS) || \
+diff --git a/psutil/_psutil_sunos.c b/psutil/_psutil_sunos.c
+index 54f353c106..d21f59c618 100644
+--- a/psutil/_psutil_sunos.c
++++ b/psutil/_psutil_sunos.c
+@@ -1721,6 +1721,10 @@ void init_psutil_sunos(void)
+     if (module == NULL)
+         INITERROR;
+ 
++#ifdef Py_GIL_DISABLED
++    PyUnstable_Module_SetGIL(module, Py_MOD_GIL_NOT_USED);
++#endif
++
+     if (psutil_setup() != 0)
+         INITERROR;
+ 
+diff --git a/psutil/_psutil_windows.c b/psutil/_psutil_windows.c
+index bb6e12ff80..0c221bdc23 100644
+--- a/psutil/_psutil_windows.c
++++ b/psutil/_psutil_windows.c
+@@ -165,6 +165,10 @@ void init_psutil_windows(void)
+     if (module == NULL)
+         INITERROR;
+ 
++#ifdef Py_GIL_DISABLED
++    PyUnstable_Module_SetGIL(module, Py_MOD_GIL_NOT_USED);
++#endif
++
+     if (psutil_setup() != 0)
+         INITERROR;
+     if (psutil_set_se_debug() != 0)
+diff --git a/psutil/arch/freebsd/cpu.c b/psutil/arch/freebsd/cpu.c
+index a15d96efc1..9fa1a7dbe6 100644
+--- a/psutil/arch/freebsd/cpu.c
++++ b/psutil/arch/freebsd/cpu.c
+@@ -26,7 +26,7 @@ For reference, here's the git history with original(ish) implementations:
+ 
+ PyObject *
+ psutil_per_cpu_times(PyObject *self, PyObject *args) {
+-    static int maxcpus;
++    int maxcpus;
+     int mib[2];
+     int ncpu;
+     size_t len;
+diff --git a/psutil/arch/openbsd/proc.c b/psutil/arch/openbsd/proc.c
+index 96b85bc502..bec2c42ea7 100644
+--- a/psutil/arch/openbsd/proc.c
++++ b/psutil/arch/openbsd/proc.c
+@@ -147,7 +147,7 @@ PyObject *
+ psutil_proc_cmdline(PyObject *self, PyObject *args) {
+     pid_t pid;
+     int mib[4];
+-    static char **argv;
++    char **argv = NULL;
+     char **p;
+     size_t argv_size = 128;
+     PyObject *py_retlist = PyList_New(0);
+@@ -189,9 +189,11 @@ psutil_proc_cmdline(PyObject *self, PyObject *args) {
+         Py_DECREF(py_arg);
+     }
+ 
++    free(argv);
+     return py_retlist;
+ 
+ error:
++    free(argv);
+     Py_XDECREF(py_arg);
+     Py_DECREF(py_retlist);
+     return NULL;
+
+From 69c74c63a322fae4a763bf8347f9e5e3202d5ecf Mon Sep 17 00:00:00 2001
+From: Sam Gross <colesbury@gmail.com>
+Date: Mon, 24 Jun 2024 18:26:00 +0000
+Subject: [PATCH 2/2] Add `if (argv != NULL)` check
+
+Signed-off-by: Sam Gross <colesbury@gmail.com>
+---
+ psutil/arch/openbsd/proc.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/psutil/arch/openbsd/proc.c b/psutil/arch/openbsd/proc.c
+index bec2c42ea7..0881ccd555 100644
+--- a/psutil/arch/openbsd/proc.c
++++ b/psutil/arch/openbsd/proc.c
+@@ -193,7 +193,8 @@ psutil_proc_cmdline(PyObject *self, PyObject *args) {
+     return py_retlist;
+ 
+ error:
+-    free(argv);
++    if (argv != NULL)
++        free(argv);
+     Py_XDECREF(py_arg);
+     Py_DECREF(py_retlist);
+     return NULL;

diff --git a/dev-python/psutil/psutil-6.0.0-r1.ebuild b/dev-python/psutil/psutil-6.0.0-r1.ebuild
new file mode 100644
index 000000000000..f8d6a5297af0
--- /dev/null
+++ b/dev-python/psutil/psutil-6.0.0-r1.ebuild
@@ -0,0 +1,47 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DISTUTILS_EXT=1
+DISTUTILS_USE_PEP517=setuptools
+PYTHON_COMPAT=( python3_{10..13} python3_13t pypy3 )
+
+inherit distutils-r1 pypi
+
+TEST_PATCH=psutil-6.0.0-tests.patch
+DESCRIPTION="Retrieve information on running processes and system utilization"
+HOMEPAGE="
+	https://github.com/giampaolo/psutil/
+	https://pypi.org/project/psutil/
+"
+SRC_URI+="
+	https://dev.gentoo.org/~mgorny/dist/${TEST_PATCH}.xz
+"
+
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~arm64-macos ~ppc-macos ~x64-macos ~x64-solaris"
+IUSE="test"
+RESTRICT="!test? ( test )"
+
+PATCHES=(
+	"${WORKDIR}/${TEST_PATCH}"
+)
+
+python_test() {
+	# Since we are running in an environment a bit similar to CI,
+	# let's skip the tests that are disabled for CI
+	local -x TRAVIS=1
+	local -x APPVEYOR=1
+	local -x GITHUB_ACTIONS=1
+	local -x GENTOO_TESTING=1
+	"${EPYTHON}" psutil/tests/runner.py ||
+		die "tests failed with ${EPYTHON}"
+}
+
+python_compile() {
+	# Force -j1 to avoid .o linking race conditions
+	local MAKEOPTS=-j1
+	distutils-r1_python_compile
+}


             reply	other threads:[~2024-10-14 16:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-14 16:54 Michał Górny [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-10-04  8:05 [gentoo-commits] repo/gentoo:master commit in: dev-python/psutil/, dev-python/psutil/files/ Michał Górny
2020-07-16 19:00 Michał Górny
2019-11-22  3:15 Patrick McLean

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1728924886.59aa1d76b7c23496b717c018ce7819f2008a3f27.mgorny@gentoo \
    --to=mgorny@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox