summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2021-06-20 18:15:01 +0200
committerMichał Górny <mgorny@gentoo.org>2021-06-20 18:31:45 +0200
commit8e0d5facc35dc749b754408f5ec151a2d65be175 (patch)
tree456b760789ecf95d986964d14c88aa719688ae52 /dev-python/pygobject
parentwww-plugins/gosuslugi-plugin: destabilize x64-macos (diff)
downloadgentoo-8e0d5facc35dc749b754408f5ec151a2d65be175.tar.gz
gentoo-8e0d5facc35dc749b754408f5ec151a2d65be175.tar.bz2
gentoo-8e0d5facc35dc749b754408f5ec151a2d65be175.zip
dev-python/pygobject: Fix ImportWarnings with py3.10
Closes: https://bugs.gentoo.org/796929 Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'dev-python/pygobject')
-rw-r--r--dev-python/pygobject/files/pygobject-3.40.1-dynamicimporter-py310.patch63
-rw-r--r--dev-python/pygobject/pygobject-3.40.1-r1.ebuild78
2 files changed, 141 insertions, 0 deletions
diff --git a/dev-python/pygobject/files/pygobject-3.40.1-dynamicimporter-py310.patch b/dev-python/pygobject/files/pygobject-3.40.1-dynamicimporter-py310.patch
new file mode 100644
index 000000000000..341a096767b6
--- /dev/null
+++ b/dev-python/pygobject/files/pygobject-3.40.1-dynamicimporter-py310.patch
@@ -0,0 +1,63 @@
+From 1ae65be0f7e621002e2e29921e0252c1b57a170c Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Sun, 20 Jun 2021 17:54:52 +0200
+Subject: [PATCH] Implement PEP451 semantics for DynamicImporter
+
+Make DynamicImporter PEP451-compliant in order to silence ImportWarnings
+in Python 3.10. This is mostly based on six._SixMetaPathImporter.
+
+Fixes #476
+---
+ gi/importer.py | 18 ++++++++++++++++++
+ 1 file changed, 18 insertions(+)
+
+diff --git a/gi/importer.py b/gi/importer.py
+index 32967974..006cf464 100644
+--- a/gi/importer.py
++++ b/gi/importer.py
+@@ -24,6 +24,7 @@
+ import sys
+ import warnings
+ import importlib
++import importlib.util
+ from contextlib import contextmanager
+
+ import gi
+@@ -103,6 +104,7 @@ def get_import_stacklevel(import_hook):
+ class DynamicImporter(object):
+
+ # Note: see PEP302 for the Importer Protocol implemented below.
++ # PEP451 for A ModuleSpec Type for the Import System.
+
+ def __init__(self, path):
+ self.path = path
+@@ -117,6 +119,16 @@ class DynamicImporter(object):
+
+ return self
+
++ def find_spec(self, fullname, path, target=None):
++ if not fullname.startswith(self.path):
++ return None
++
++ path, namespace = fullname.rsplit('.', 1)
++ if path != self.path:
++ return None
++
++ return importlib.util.spec_from_loader(fullname, self)
++
+ def load_module(self, fullname):
+ if fullname in sys.modules:
+ return sys.modules[fullname]
+@@ -149,3 +161,9 @@ class DynamicImporter(object):
+ sys.modules[fullname] = dynamic_module
+
+ return dynamic_module
++
++ def create_module(self, spec):
++ return self.load_module(spec.name)
++
++ def exec_module(self, module):
++ pass
+--
+2.32.0
+
diff --git a/dev-python/pygobject/pygobject-3.40.1-r1.ebuild b/dev-python/pygobject/pygobject-3.40.1-r1.ebuild
new file mode 100644
index 000000000000..01f7b7055ebd
--- /dev/null
+++ b/dev-python/pygobject/pygobject-3.40.1-r1.ebuild
@@ -0,0 +1,78 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+PYTHON_COMPAT=( python3_{7..10} )
+
+inherit gnome.org meson python-r1 virtualx xdg
+
+DESCRIPTION="Python bindings for GObject Introspection"
+HOMEPAGE="https://pygobject.readthedocs.io/"
+
+LICENSE="LGPL-2.1+"
+SLOT="3"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~x64-solaris ~x86-solaris"
+IUSE="+cairo examples test"
+RESTRICT="!test? ( test )"
+REQUIRED_USE="${PYTHON_REQUIRED_USE}"
+
+RDEPEND="${PYTHON_DEPS}
+ >=dev-libs/glib-2.56:2
+ >=dev-libs/gobject-introspection-1.56:=
+ dev-libs/libffi:=
+ cairo? (
+ >=dev-python/pycairo-1.16.0[${PYTHON_USEDEP}]
+ x11-libs/cairo[glib] )
+"
+DEPEND="${RDEPEND}
+ test? (
+ dev-libs/atk[introspection]
+ dev-python/pytest[${PYTHON_USEDEP}]
+ x11-libs/gdk-pixbuf:2[introspection,jpeg]
+ x11-libs/gtk+:3[introspection]
+ x11-libs/pango[introspection]
+ )
+"
+BDEPEND="
+ virtual/pkgconfig
+"
+
+PATCHES=(
+ "${FILESDIR}"/${P}-dynamicimporter-py310.patch
+)
+
+src_configure() {
+ configuring() {
+ meson_src_configure \
+ $(meson_feature cairo pycairo) \
+ $(meson_use test tests) \
+ -Dpython="${EPYTHON}"
+ }
+
+ python_foreach_impl configuring
+}
+
+src_compile() {
+ python_foreach_impl meson_src_compile
+}
+
+src_test() {
+ local -x GIO_USE_VFS="local" # prevents odd issues with deleting ${T}/.gvfs
+ local -x GIO_USE_VOLUME_MONITOR="unix" # prevent udisks-related failures in chroots, bug #449484
+
+ testing() {
+ local -x XDG_CACHE_HOME="${T}/${EPYTHON}"
+ meson_src_test || die "test failed for ${EPYTHON}"
+ }
+ virtx python_foreach_impl testing
+}
+
+src_install() {
+ installing() {
+ meson_src_install
+ python_optimize
+ }
+ python_foreach_impl installing
+ use examples && dodoc -r examples
+}