Gentoo Archives: gentoo-commits

From: Mart Raudsepp <leio@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: gnome-extra/gnome-builder/, gnome-extra/gnome-builder/files/
Date: Thu, 05 Apr 2018 17:47:12
Message-Id: 1522950330.6b4c897174a7089836a3a221f38482594c5bc2b2.leio@gentoo
1 commit: 6b4c897174a7089836a3a221f38482594c5bc2b2
2 Author: Mart Raudsepp <leio <AT> gentoo <DOT> org>
3 AuthorDate: Thu Apr 5 16:44:29 2018 +0000
4 Commit: Mart Raudsepp <leio <AT> gentoo <DOT> org>
5 CommitDate: Thu Apr 5 17:45:30 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6b4c8971
7
8 gnome-extra/gnome-builder: fix jedi-0.10.x compat for Python autocompletion
9
10 gnome-builder-3.24 was compatible with jedi 0.9 or older. Add patches to make
11 it compatible with 0.10.x instead, which is still available in main tree at least.
12 It is still incompatible with 0.11+
13
14 Package-Manager: Portage-2.3.28, Repoman-2.3.9
15
16 .../gnome-builder/files/3.24.2-jedi-fixes-1.patch | 28 +++
17 .../gnome-builder/files/3.24.2-jedi-fixes-2.patch | 25 +++
18 .../gnome-builder/files/3.24.2-jedi-fixes-3.patch | 197 +++++++++++++++++++++
19 .../gnome-builder/gnome-builder-3.24.2-r1.ebuild | 133 ++++++++++++++
20 4 files changed, 383 insertions(+)
21
22 diff --git a/gnome-extra/gnome-builder/files/3.24.2-jedi-fixes-1.patch b/gnome-extra/gnome-builder/files/3.24.2-jedi-fixes-1.patch
23 new file mode 100644
24 index 00000000000..399811bb0ea
25 --- /dev/null
26 +++ b/gnome-extra/gnome-builder/files/3.24.2-jedi-fixes-1.patch
27 @@ -0,0 +1,28 @@
28 +From 294920f6b932992e9da8864ca96ae35fe2402406 Mon Sep 17 00:00:00 2001
29 +From: Christian Hergert <chergert@××××××.com>
30 +Date: Fri, 30 Jun 2017 21:19:41 -0700
31 +Subject: [PATCH] jedi: silence xml parser warning
32 +
33 +https://bugzilla.gnome.org/show_bug.cgi?id=784327
34 +---
35 +
36 +diff --git a/plugins/jedi/jedi_plugin.py b/plugins/jedi/jedi_plugin.py
37 +index 7be46f2..d257680 100644
38 +--- a/plugins/jedi/jedi_plugin.py
39 ++++ b/plugins/jedi/jedi_plugin.py
40 +@@ -298,7 +298,11 @@ class DocumentationDB(object):
41 + cursor.execute('UPDATE girfiles SET last_modified=? WHERE file=?', (mtime, filename))
42 + parser = lxml.etree.XMLParser(recover=True)
43 + tree = lxml.etree.parse(filename, parser=parser)
44 +- namespace = tree.find('core:namespace', namespaces=ns)
45 ++ try:
46 ++ namespace = tree.find('core:namespace', namespaces=ns)
47 ++ except:
48 ++ print("Failed to parse", filename)
49 ++ continue
50 + library_version = namespace.attrib['version']
51 + for node in namespace.findall('core:class', namespaces=ns):
52 + doc = node.find('core:doc', namespaces=ns)
53 +--
54 +libgit2 0.26.0
55 +
56
57 diff --git a/gnome-extra/gnome-builder/files/3.24.2-jedi-fixes-2.patch b/gnome-extra/gnome-builder/files/3.24.2-jedi-fixes-2.patch
58 new file mode 100644
59 index 00000000000..de8397a57a0
60 --- /dev/null
61 +++ b/gnome-extra/gnome-builder/files/3.24.2-jedi-fixes-2.patch
62 @@ -0,0 +1,25 @@
63 +From 1d7c6fa60faf9e81f2fa0f93898f8e1cc68da6d4 Mon Sep 17 00:00:00 2001
64 +From: Christian Hergert <chergert@××××××.com>
65 +Date: Thu, 6 Jul 2017 14:32:52 -0700
66 +Subject: [PATCH] jedi: ignore non-gir files
67 +
68 +The rnc file is now shipped here, so ignore that when going
69 +through the directory contents.
70 +---
71 +
72 +diff --git a/plugins/jedi/jedi_plugin.py b/plugins/jedi/jedi_plugin.py
73 +index d257680..25ade14 100644
74 +--- a/plugins/jedi/jedi_plugin.py
75 ++++ b/plugins/jedi/jedi_plugin.py
76 +@@ -280,6 +280,8 @@ class DocumentationDB(object):
77 + # I would use scandir for better performance, but it requires newer Python
78 + for gir_path in GIR_PATH_LIST:
79 + for gir_file in os.listdir(gir_path):
80 ++ if not gir_file.endswith('.gir'):
81 ++ continue
82 + if gir_file in processed_gir_files:
83 + continue
84 + processed_gir_files[gir_file] = None
85 +--
86 +libgit2 0.26.0
87 +
88
89 diff --git a/gnome-extra/gnome-builder/files/3.24.2-jedi-fixes-3.patch b/gnome-extra/gnome-builder/files/3.24.2-jedi-fixes-3.patch
90 new file mode 100644
91 index 00000000000..484341ad115
92 --- /dev/null
93 +++ b/gnome-extra/gnome-builder/files/3.24.2-jedi-fixes-3.patch
94 @@ -0,0 +1,197 @@
95 +From 8bf74c787af082102958de7498a9b4f4248788cc Mon Sep 17 00:00:00 2001
96 +From: Elad Alfassa <elad@×××××××××××××.org>
97 +Date: Wed, 9 Aug 2017 17:39:07 +0300
98 +Subject: [PATCH] jedi: adapt to jedi 0.10.0
99 +
100 +https://bugzilla.gnome.org/show_bug.cgi?id=778708
101 +---
102 +
103 +diff --git a/plugins/jedi/jedi_plugin.py b/plugins/jedi/jedi_plugin.py
104 +index 25ade14..8898b69 100644
105 +--- a/plugins/jedi/jedi_plugin.py
106 ++++ b/plugins/jedi/jedi_plugin.py
107 +@@ -55,7 +55,6 @@ from gi.repository import GtkSource
108 + from gi.repository import Ide
109 + from gi.types import GObjectMeta
110 + from gi.types import StructMeta
111 +-
112 + _ = Ide.gettext
113 +
114 + gi_importer = DynamicImporter('gi.repository')
115 +@@ -91,22 +90,31 @@ _ICONS = {
116 + try:
117 + import jedi
118 + from jedi.evaluate.compiled import CompiledObject
119 ++ from jedi.evaluate.compiled import get_special_object
120 + from jedi.evaluate.compiled import _create_from_name
121 +- from jedi.evaluate.compiled import builtin
122 ++ from jedi.evaluate.context import Context
123 + from jedi.evaluate.docstrings import _evaluate_for_statement_string
124 + from jedi.evaluate.imports import Importer
125 +
126 + class PatchedJediCompiledObject(CompiledObject):
127 + "A modified version of Jedi CompiledObject to work with GObject Introspection modules"
128 ++
129 ++ def __init__(self, evaluator, obj, parent_context=None, faked_class=None):
130 ++ # we have to override __init__ to change super(CompiledObject, self)
131 ++ # to Context, in order to prevent an infinite recursion
132 ++ Context.__init__(self, evaluator, parent_context)
133 ++ self.obj = obj
134 ++ self.tree_node = faked_class
135 ++
136 + def _cls(self):
137 + if self.obj.__class__ == IntrospectionModule:
138 + return self
139 + else:
140 +- return super()._cls()
141 ++ return super()._cls(self)
142 +
143 + @property
144 + def py__call__(self):
145 +- def actual(evaluator, params):
146 ++ def actual(params):
147 + # Parse the docstring to find the return type:
148 + ret_type = ''
149 + if '->' in self.obj.__doc__:
150 +@@ -115,18 +123,21 @@ try:
151 + if ret_type.startswith('iter:'):
152 + ret_type = ret_type[len('iter:'):] # we don't care if it's an iterator
153 +
154 +- if ret_type in __builtins__:
155 ++ if hasattr(__builtins__, ret_type):
156 + # The function we're inspecting returns a builtin python type, that's easy
157 +- obj = _create_from_name(builtin, builtin, ret_type)
158 +- return evaluator.execute(obj, params)
159 ++ # (see test/test_evaluate/test_compiled.py in the jedi source code for usage)
160 ++ builtins = get_special_object(self.evaluator, 'BUILTINS')
161 ++ builtin_obj = builtins.py__getattribute__(ret_type)
162 ++ obj = _create_from_name(self.evaluator, builtins, builtin_obj, "")
163 ++ return self.evaluator.execute(obj, params)
164 + else:
165 + # The function we're inspecting returns a GObject type
166 +- parent = self.parent.obj.__name__
167 ++ parent = self.parent_context.obj.__name__
168 + if parent.startswith('gi.repository'):
169 + parent = parent[len('gi.repository.'):]
170 + else:
171 + # a module with overrides, such as Gtk, behaves differently
172 +- parent_module = self.parent.obj.__module__
173 ++ parent_module = self.parent_context.obj.__module__
174 + if parent_module.startswith('gi.overrides'):
175 + parent_module = parent_module[len('gi.overrides.'):]
176 + parent = '%s.%s' % (parent_module, parent)
177 +@@ -138,22 +149,28 @@ try:
178 + # A pygobject type in a different module
179 + return_type_parent = ret_type.split('.', 1)[0]
180 + ret_type = 'from gi.repository import %s\n%s' % (return_type_parent, ret_type)
181 +- result = _evaluate_for_statement_string(evaluator, ret_type, self.parent)
182 +- return result
183 ++ result = _evaluate_for_statement_string(self.parent_context, ret_type)
184 ++ return set(result)
185 + if type(self.obj) == FunctionInfo:
186 + return actual
187 + return super().py__call__
188 +
189 ++ # we need to override CompiledBoundMethod without changing it much,
190 ++ # just so it'll not get confused due to our overriden CompiledObject
191 ++ class PatchedCompiledBoundMethod(PatchedJediCompiledObject):
192 ++ def __init__(self, func):
193 ++ super().__init__(func.evaluator, func.obj, func.parent_context, func.tree_node)
194 ++
195 + class PatchedJediImporter(Importer):
196 + "A modified version of Jedi Importer to work with GObject Introspection modules"
197 + def follow(self):
198 + module_list = super().follow()
199 +- if module_list == []:
200 ++ if not module_list:
201 + import_path = '.'.join([str(i) for i in self.import_path])
202 + if import_path.startswith('gi.repository'):
203 + try:
204 + module = gi_importer.load_module(import_path)
205 +- module_list = [PatchedJediCompiledObject(module)]
206 ++ module_list = [PatchedJediCompiledObject(self._evaluator, module)]
207 + except ImportError:
208 + pass
209 + return module_list
210 +@@ -169,9 +186,9 @@ try:
211 + return original_jedi_get_module('gi._gobject')
212 +
213 + jedi.evaluate.compiled.fake.get_module = patched_jedi_get_module
214 +-
215 +- jedi.evaluate.imports.Importer = PatchedJediImporter
216 + jedi.evaluate.compiled.CompiledObject = PatchedJediCompiledObject
217 ++ jedi.evaluate.instance.CompiledBoundMethod = PatchedCompiledBoundMethod
218 ++ jedi.evaluate.imports.Importer = PatchedJediImporter
219 + HAS_JEDI = True
220 + except ImportError:
221 + print("jedi not found, python auto-completion not possible.")
222 +@@ -331,7 +348,6 @@ def update_doc_db_on_startup():
223 +
224 + update_doc_db_on_startup()
225 +
226 +-
227 + class JediCompletionProvider(Ide.Object, GtkSource.CompletionProvider, Ide.CompletionProvider):
228 + context = None
229 + current_word = None
230 +@@ -600,6 +616,15 @@ class JediCompletionRequest:
231 + script = jedi.Script(self.content, self.line + 1, self.column, self.filename)
232 +
233 + db = DocumentationDB()
234 ++
235 ++ def get_gi_obj(info):
236 ++ """ Get a GObject Introspection object from a jedi Completion, or None if the completion is not GObject Introspection related """
237 ++ if (type(info._module) == PatchedJediCompiledObject and
238 ++ info._module.obj.__class__ == IntrospectionModule):
239 ++ return next(info._name.infer()).obj
240 ++ else:
241 ++ return None
242 ++
243 + for info in script.completions():
244 + if self.cancelled:
245 + return
246 +@@ -608,10 +633,9 @@ class JediCompletionRequest:
247 +
248 + # we have to use custom names here because .type and .params can't
249 + # be overridden (they are properties)
250 +- if type(info._definition) == PatchedJediCompiledObject and \
251 +- type(info._definition.obj) == FunctionInfo:
252 ++ obj = get_gi_obj(info)
253 ++ if type(obj) == FunctionInfo:
254 + info.real_type = 'function'
255 +- obj = info._definition.obj
256 + params = [arg_info.get_name() for arg_info in obj.get_arguments()]
257 + else:
258 + info.real_type = info.type
259 +@@ -626,8 +650,8 @@ class JediCompletionRequest:
260 + params.append(param.name)
261 +
262 + doc = info.docstring()
263 +- if hasattr(info._definition, 'obj'):
264 +- obj = info._definition.obj
265 ++ if obj is not None:
266 ++ # get documentation for this GObject Introspection object
267 + symbol = None
268 + namespace = None
269 +
270 +@@ -640,17 +664,7 @@ class JediCompletionRequest:
271 + namespace = obj.get_namespace()
272 +
273 + if symbol is not None:
274 +- # we need to walk down the path to find the module so we can get the version
275 +- parent = info._definition.parent
276 +- found = False
277 +- while not found:
278 +- new_parent = parent.parent
279 +- if new_parent is None:
280 +- found = True
281 +- else:
282 +- parent = new_parent
283 +- version = parent.obj._version
284 +- result = db.query(symbol, version)
285 ++ result = db.query(symbol, info._module.obj._version)
286 + if result is not None:
287 + doc = result
288 +
289 +--
290 +libgit2 0.26.0
291 +
292
293 diff --git a/gnome-extra/gnome-builder/gnome-builder-3.24.2-r1.ebuild b/gnome-extra/gnome-builder/gnome-builder-3.24.2-r1.ebuild
294 new file mode 100644
295 index 00000000000..1daef3f2656
296 --- /dev/null
297 +++ b/gnome-extra/gnome-builder/gnome-builder-3.24.2-r1.ebuild
298 @@ -0,0 +1,133 @@
299 +# Copyright 1999-2018 Gentoo Foundation
300 +# Distributed under the terms of the GNU General Public License v2
301 +
302 +EAPI=6
303 +PYTHON_COMPAT=( python3_{4,5,6} )
304 +VALA_MIN_API_VERSION="0.30"
305 +VALA_USE_DEPEND="vapigen"
306 +DISABLE_AUTOFORMATTING=1
307 +FORCE_PRINT_ELOG=1
308 +
309 +inherit gnome2 python-single-r1 vala virtualx readme.gentoo-r1
310 +
311 +DESCRIPTION="Builder attempts to be an IDE for writing software for GNOME"
312 +HOMEPAGE="https://wiki.gnome.org/Apps/Builder"
313 +
314 +# FIXME: Review licenses at some point
315 +LICENSE="GPL-3+ GPL-2+ LGPL-3+ LGPL-2+ MIT CC-BY-SA-3.0 CC0-1.0"
316 +SLOT="0"
317 +KEYWORDS="~amd64 ~x86"
318 +IUSE="clang +git sysprof vala webkit"
319 +REQUIRED_USE="${PYTHON_REQUIRED_USE}"
320 +
321 +# When bumping, pay attention to all the included plugins/*/configure.ac files and the requirements within.
322 +# Most have no extra requirements and default to enabled; we need to handle the ones with extra requirements, which tend to default to auto(magic).
323 +# Look at the last (fourth) argument given to AC_ARG_ENABLE to decide. We don't support any disabling of those that are default-enabled and have no extra deps beyond C/python/introspection.
324 +# FIXME: >=dev-util/devhelp-3.20.0 dependency is automagic for devhelp integration plugin
325 +# FIXME: vte could be optional via $(use_enable vte terminal-plugin) - but most/all people want this and have vte?
326 +# FIXME: flatpak-plugin needs flatpak.pc >=0.6.9, libgit2[threads] >=libgit2-glib-0.24.0[ssh] libsoup-2.4.pc
327 +# FIXME: --with-sanitizer configure option
328 +# FIXME: Enable rdtscp based high performance counter usage on suitable architectures for EGG_COUNTER?
329 +# Editorconfig needs pcre.h, with vte migrating away, might want it optional?
330 +# Python is always enabled - the core python plugin support checks are automagic and not worth crippling it by not supporting python plugins
331 +# Relatedly introspection is always required to not have broken python using plugins or have to enable/disable them based on it. This is a full IDE, not a place to be really minimal.
332 +# An introspection USE flag of a dep is required if any introspection based language plugin wants to use it. Last full check at 3.22.4
333 +RDEPEND="
334 + >=x11-libs/gtk+-3.22.1:3[introspection]
335 + >=dev-libs/glib-2.50.0:2[dbus]
336 + >=x11-libs/gtksourceview-3.22.0:3.0[introspection]
337 + >=dev-libs/gobject-introspection-1.48.0:=
338 + >=dev-python/pygobject-3.22.0:3
339 + >=dev-libs/libxml2-2.9.0
340 + >=x11-libs/pango-1.38.0
341 + >=dev-libs/libpeas-1.18.0[python,${PYTHON_USEDEP}]
342 + >=dev-libs/json-glib-1.2.0
343 + >=app-text/gspell-1.2.0
344 + >=app-text/enchant-1.6.0
345 + webkit? ( >=net-libs/webkit-gtk-2.12.0:4=[introspection] )
346 + clang? ( sys-devel/clang:= )
347 + git? (
348 + dev-libs/libgit2[ssh,threads]
349 + >=dev-libs/libgit2-glib-0.25.0[ssh] )
350 + >=x11-libs/vte-0.46:2.91
351 + sysprof? ( >=dev-util/sysprof-3.23.91[gtk] )
352 + dev-libs/libpcre:3
353 + ${PYTHON_DEPS}
354 + vala? ( $(vala_depend) )
355 +"
356 +# desktop-file-utils for desktop-file-validate check in configure for 3.22.4
357 +DEPEND="${RDEPEND}
358 + dev-libs/appstream-glib
359 + dev-util/desktop-file-utils
360 + >=sys-devel/gettext-0.19.8
361 + virtual/pkgconfig
362 + !<sys-apps/sandbox-2.10-r3
363 +"
364 +
365 +# Tests fail if all plugins aren't enabled (webkit, clang, devhelp, perhaps more)
366 +RESTRICT="test"
367 +
368 +DOC_CONTENTS='gnome-builder can use various other dependencies on runtime to provide
369 +extra capabilities beyond these expressed via USE flags. Some of these
370 +that are currently available with packages include:
371 +
372 +* dev-util/ctags with exuberant-ctags selected via "eselect ctags" for
373 + C, C++, Python, JavaScript, CSS, HTML and Ruby autocompletion, semantic
374 + highlighting and symbol resolving support.
375 +* dev-python/jedi-0.10.x and dev-python/lxml for more accurate Python
376 + autocompletion support.
377 +* dev-util/valgrind for integration with valgrind.
378 +* dev-util/meson for integration with the Meson build system.
379 +* dev-util/cargo for integration with the Rust Cargo build system.
380 +'
381 +# FIXME: Package gnome-code-assistance and mention here, or maybe USE flag and default enable because it's rather important
382 +# eslint for additional diagnostics in JavaScript files
383 +# jhbuild support
384 +# rust language server via rls
385 +# autotools stuff for autotools plugin; gtkmm/autoconf-archive for C++ template
386 +# mono/PHPize stuff
387 +
388 +PATCHES=( "${FILESDIR}"/${PV}-jedi-fixes-{1,2,3}.patch ) # jedi-0.10+ compatibility from 3.25.9x; remove 0.10 specific mention from DOC_CONTENTS once compat with 0.11+
389 +
390 +pkg_setup() {
391 + python-single-r1_pkg_setup
392 +}
393 +
394 +src_prepare() {
395 + use vala && vala_src_prepare
396 + gnome2_src_prepare
397 +}
398 +
399 +src_configure() {
400 + gnome2_src_configure \
401 + --with-channel=distro \
402 + --enable-editorconfig \
403 + --enable-introspection \
404 + $(use_enable vala vala-pack-plugin) \
405 + $(use_enable webkit) \
406 + $(use_enable webkit html-preview-plugin) \
407 + $(use_enable clang clang-plugin) \
408 + $(use_enable git git-plugin) \
409 + $(use_enable sysprof sysprof-plugin) \
410 + --disable-flatpak-plugin \
411 + --enable-terminal-plugin \
412 + --enable-gettext-plugin \
413 + --disable-static
414 +}
415 +
416 +src_install() {
417 + gnome2_src_install
418 + readme.gentoo_create_doc
419 +}
420 +
421 +pkg_postinst() {
422 + gnome2_pkg_postinst
423 + readme.gentoo_print_elog
424 +}
425 +
426 +src_test() {
427 + # FIXME: this should be handled at eclass level
428 + "${EROOT}${GLIB_COMPILE_SCHEMAS}" --allow-any-name "${S}/data/gsettings" || die
429 +
430 + GSETTINGS_SCHEMA_DIR="${S}/data/gsettings" virtx emake check
431 +}