From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-apps/dstat/, sys-apps/dstat/files/
Date: Sun, 1 Dec 2024 12:42:29 +0000 (UTC) [thread overview]
Message-ID: <1733056773.63959edc58c8a87d8a4661bedde274a504cc793a.sam@gentoo> (raw)
commit: 63959edc58c8a87d8a4661bedde274a504cc793a
Author: Paul Healy <lmiphay <AT> gmail <DOT> com>
AuthorDate: Sun Oct 20 19:42:28 2024 +0000
Commit: Sam James <sam <AT> gentoo <DOT> 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 <lmiphay <AT> gmail.com>
Closes: https://github.com/gentoo/gentoo/pull/39059
Signed-off-by: Sam James <sam <AT> 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)
+
next reply other threads:[~2024-12-01 12:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-01 12:42 Sam James [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-05-16 14:48 [gentoo-commits] repo/gentoo:master commit in: sys-apps/dstat/, sys-apps/dstat/files/ Arthur Zamarin
2020-09-19 12:29 Michał Górny
2017-01-15 11:20 Pacho Ramos
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=1733056773.63959edc58c8a87d8a4661bedde274a504cc793a.sam@gentoo \
--to=sam@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