Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/pygobject/, dev-python/pygobject/files/
Date: Sun, 20 Jun 2021 16:31:54
Message-Id: 1624206705.8e0d5facc35dc749b754408f5ec151a2d65be175.mgorny@gentoo
1 commit: 8e0d5facc35dc749b754408f5ec151a2d65be175
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Sun Jun 20 16:15:01 2021 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Sun Jun 20 16:31:45 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8e0d5fac
7
8 dev-python/pygobject: Fix ImportWarnings with py3.10
9
10 Closes: https://bugs.gentoo.org/796929
11 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
12
13 .../pygobject-3.40.1-dynamicimporter-py310.patch | 63 +++++++++++++++++
14 dev-python/pygobject/pygobject-3.40.1-r1.ebuild | 78 ++++++++++++++++++++++
15 2 files changed, 141 insertions(+)
16
17 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
18 new file mode 100644
19 index 00000000000..341a096767b
20 --- /dev/null
21 +++ b/dev-python/pygobject/files/pygobject-3.40.1-dynamicimporter-py310.patch
22 @@ -0,0 +1,63 @@
23 +From 1ae65be0f7e621002e2e29921e0252c1b57a170c Mon Sep 17 00:00:00 2001
24 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o>
25 +Date: Sun, 20 Jun 2021 17:54:52 +0200
26 +Subject: [PATCH] Implement PEP451 semantics for DynamicImporter
27 +
28 +Make DynamicImporter PEP451-compliant in order to silence ImportWarnings
29 +in Python 3.10. This is mostly based on six._SixMetaPathImporter.
30 +
31 +Fixes #476
32 +---
33 + gi/importer.py | 18 ++++++++++++++++++
34 + 1 file changed, 18 insertions(+)
35 +
36 +diff --git a/gi/importer.py b/gi/importer.py
37 +index 32967974..006cf464 100644
38 +--- a/gi/importer.py
39 ++++ b/gi/importer.py
40 +@@ -24,6 +24,7 @@
41 + import sys
42 + import warnings
43 + import importlib
44 ++import importlib.util
45 + from contextlib import contextmanager
46 +
47 + import gi
48 +@@ -103,6 +104,7 @@ def get_import_stacklevel(import_hook):
49 + class DynamicImporter(object):
50 +
51 + # Note: see PEP302 for the Importer Protocol implemented below.
52 ++ # PEP451 for A ModuleSpec Type for the Import System.
53 +
54 + def __init__(self, path):
55 + self.path = path
56 +@@ -117,6 +119,16 @@ class DynamicImporter(object):
57 +
58 + return self
59 +
60 ++ def find_spec(self, fullname, path, target=None):
61 ++ if not fullname.startswith(self.path):
62 ++ return None
63 ++
64 ++ path, namespace = fullname.rsplit('.', 1)
65 ++ if path != self.path:
66 ++ return None
67 ++
68 ++ return importlib.util.spec_from_loader(fullname, self)
69 ++
70 + def load_module(self, fullname):
71 + if fullname in sys.modules:
72 + return sys.modules[fullname]
73 +@@ -149,3 +161,9 @@ class DynamicImporter(object):
74 + sys.modules[fullname] = dynamic_module
75 +
76 + return dynamic_module
77 ++
78 ++ def create_module(self, spec):
79 ++ return self.load_module(spec.name)
80 ++
81 ++ def exec_module(self, module):
82 ++ pass
83 +--
84 +2.32.0
85 +
86
87 diff --git a/dev-python/pygobject/pygobject-3.40.1-r1.ebuild b/dev-python/pygobject/pygobject-3.40.1-r1.ebuild
88 new file mode 100644
89 index 00000000000..01f7b7055eb
90 --- /dev/null
91 +++ b/dev-python/pygobject/pygobject-3.40.1-r1.ebuild
92 @@ -0,0 +1,78 @@
93 +# Copyright 1999-2021 Gentoo Authors
94 +# Distributed under the terms of the GNU General Public License v2
95 +
96 +EAPI=7
97 +
98 +PYTHON_COMPAT=( python3_{7..10} )
99 +
100 +inherit gnome.org meson python-r1 virtualx xdg
101 +
102 +DESCRIPTION="Python bindings for GObject Introspection"
103 +HOMEPAGE="https://pygobject.readthedocs.io/"
104 +
105 +LICENSE="LGPL-2.1+"
106 +SLOT="3"
107 +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"
108 +IUSE="+cairo examples test"
109 +RESTRICT="!test? ( test )"
110 +REQUIRED_USE="${PYTHON_REQUIRED_USE}"
111 +
112 +RDEPEND="${PYTHON_DEPS}
113 + >=dev-libs/glib-2.56:2
114 + >=dev-libs/gobject-introspection-1.56:=
115 + dev-libs/libffi:=
116 + cairo? (
117 + >=dev-python/pycairo-1.16.0[${PYTHON_USEDEP}]
118 + x11-libs/cairo[glib] )
119 +"
120 +DEPEND="${RDEPEND}
121 + test? (
122 + dev-libs/atk[introspection]
123 + dev-python/pytest[${PYTHON_USEDEP}]
124 + x11-libs/gdk-pixbuf:2[introspection,jpeg]
125 + x11-libs/gtk+:3[introspection]
126 + x11-libs/pango[introspection]
127 + )
128 +"
129 +BDEPEND="
130 + virtual/pkgconfig
131 +"
132 +
133 +PATCHES=(
134 + "${FILESDIR}"/${P}-dynamicimporter-py310.patch
135 +)
136 +
137 +src_configure() {
138 + configuring() {
139 + meson_src_configure \
140 + $(meson_feature cairo pycairo) \
141 + $(meson_use test tests) \
142 + -Dpython="${EPYTHON}"
143 + }
144 +
145 + python_foreach_impl configuring
146 +}
147 +
148 +src_compile() {
149 + python_foreach_impl meson_src_compile
150 +}
151 +
152 +src_test() {
153 + local -x GIO_USE_VFS="local" # prevents odd issues with deleting ${T}/.gvfs
154 + local -x GIO_USE_VOLUME_MONITOR="unix" # prevent udisks-related failures in chroots, bug #449484
155 +
156 + testing() {
157 + local -x XDG_CACHE_HOME="${T}/${EPYTHON}"
158 + meson_src_test || die "test failed for ${EPYTHON}"
159 + }
160 + virtx python_foreach_impl testing
161 +}
162 +
163 +src_install() {
164 + installing() {
165 + meson_src_install
166 + python_optimize
167 + }
168 + python_foreach_impl installing
169 + use examples && dodoc -r examples
170 +}