From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 3E3CF1581FB for ; Sun, 1 Dec 2024 12:42:33 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 90DE8E081E; Sun, 1 Dec 2024 12:42:32 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 79598E081E for ; Sun, 1 Dec 2024 12:42:32 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id BC0E8342FDE for ; Sun, 1 Dec 2024 12:42:31 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 266FE1F0B for ; Sun, 1 Dec 2024 12:42:29 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1733056773.63959edc58c8a87d8a4661bedde274a504cc793a.sam@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: sys-apps/dstat/, sys-apps/dstat/files/ X-VCS-Repository: repo/gentoo X-VCS-Files: sys-apps/dstat/dstat-0.7.4-r4.ebuild sys-apps/dstat/files/dstat-0.7.4-use-importlib.patch X-VCS-Directories: sys-apps/dstat/files/ sys-apps/dstat/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 63959edc58c8a87d8a4661bedde274a504cc793a X-VCS-Branch: master Date: Sun, 1 Dec 2024 12:42:29 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: b9357e07-6137-45ce-92ce-c6048972563e X-Archives-Hash: b401ec71d67c9f0f56b7cb44ac255781 commit: 63959edc58c8a87d8a4661bedde274a504cc793a Author: Paul Healy gmail com> AuthorDate: Sun Oct 20 19:42:28 2024 +0000 Commit: Sam James gentoo org> CommitDate: Sun Dec 1 12:39:33 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=63959edc sys-apps/dstat: use importlib for plugins Replace imp module use with importlib Remove unfinished code block for loading shared lib plugins Bug: https://bugs.gentoo.org/941872 Signed-off-by: Paul Healy gmail.com> Closes: https://github.com/gentoo/gentoo/pull/39059 Signed-off-by: Sam James gentoo.org> sys-apps/dstat/dstat-0.7.4-r4.ebuild | 61 ++++++++++++++++++++++ .../dstat/files/dstat-0.7.4-use-importlib.patch | 37 +++++++++++++ 2 files changed, 98 insertions(+) diff --git a/sys-apps/dstat/dstat-0.7.4-r4.ebuild b/sys-apps/dstat/dstat-0.7.4-r4.ebuild new file mode 100644 index 000000000000..d0c6bd489b80 --- /dev/null +++ b/sys-apps/dstat/dstat-0.7.4-r4.ebuild @@ -0,0 +1,61 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +PYTHON_COMPAT=( python3_{10..12} ) + +inherit python-r1 + +DESCRIPTION="Versatile replacement for vmstat, iostat and ifstat" +HOMEPAGE="http://dag.wieers.com/home-made/dstat/" +SRC_URI="https://github.com/dagwieers/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz" + +LICENSE="GPL-2+" +SLOT="0" +KEYWORDS="~alpha amd64 ~arm64 ~hppa ~mips ppc ppc64 sparc x86 ~x86-linux" +IUSE="doc examples" +REQUIRED_USE="${PYTHON_REQUIRED_USE}" + +RDEPEND="${PYTHON_DEPS} + dev-python/six[${PYTHON_USEDEP}]" +DEPEND="${RDEPEND}" + +PATCHES=( + "${FILESDIR}/dstat-${PV}-skip-non-sandbox-tests.patch" + "${FILESDIR}/fix-collections-deprecation-warning.patch" + "${FILESDIR}/dstat-0.7.4-fix-csv-output.patch" + "${FILESDIR}/dstat-${PV}-fix-backslash-in-regex.patch" + "${FILESDIR}/dstat-${PV}-use-importlib.patch" +) + +src_prepare() { + # bug fix: allow delay to be specified + # backport from: https://github.com/dagwieers/dstat/pull/167/files + sed -e 's; / op\.delay; // op.delay;' -i "dstat" || die + + default +} + +src_test() { + python_foreach_impl emake test +} + +src_install() { + python_foreach_impl python_doscript dstat + + insinto /usr/share/dstat + newins dstat dstat.py + doins plugins/dstat_*.py + + doman docs/dstat.1 + + einstalldocs + + if use examples; then + dodoc examples/{mstat,read}.py + fi + if use doc; then + dodoc docs/*.html + fi +} diff --git a/sys-apps/dstat/files/dstat-0.7.4-use-importlib.patch b/sys-apps/dstat/files/dstat-0.7.4-use-importlib.patch new file mode 100644 index 000000000000..a6650ff1b37b --- /dev/null +++ b/sys-apps/dstat/files/dstat-0.7.4-use-importlib.patch @@ -0,0 +1,37 @@ +diff --git a/dstat b/dstat +index 9359965..541fe95 100755 +--- a/dstat ++++ b/dstat +@@ -2613,28 +2613,19 @@ def main(): + pluginfile = 'dstat_' + mod.replace('-', '_') + try: + if pluginfile not in globals(): +- import imp +- fp, pathname, description = imp.find_module(pluginfile, pluginpath) +- fp.close() ++ import importlib.machinery ++ spec = importlib.machinery.PathFinder().find_spec(pluginfile, pluginpath) + + ### TODO: Would using .pyc help with anything ? + ### Try loading python plugin +- if description[0] in ('.py', ): +- exec(open(pathname).read()) ++ if spec.origin.endswith('.py'): ++ exec(open(spec.origin).read()) + #execfile(pathname) + exec('global plug; plug = dstat_plugin(); del(dstat_plugin)') + plug.filename = pluginfile + plug.check() + plug.prepare() + +- ### Try loading C plugin (not functional yet) +- elif description[0] == '.so': +- exec('import %s; global plug; plug = %s.new()' % (pluginfile, pluginfile)) +- plug.check() +- plug.prepare() +-# print(dir(plug)) +-# print(plug.__module__) +-# print(plug.name) + else: + print('Module %s is of unknown type.' % pluginfile, file=sys.stderr) +