[gentoo-dev] [PATCH] gnome2.eclass: Add EAPI=7 support
Closes: https://bugs.gentoo.org/658638 Closes: https://bugs.gentoo.org/717100 Signed-off-by: Matt Turner --- leio noted that banning GNOME2_LA_PUNT from EAPI 7 would mean adding src_install() { gnome2_src_install } to a bunch of ebuilds, which we don't want to do. Implement GNOME2_LA_PUNT with find ... -delete in EAPI 7. eclass/gnome2.eclass | 29 ++--- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/eclass/gnome2.eclass b/eclass/gnome2.eclass index 341802f8c80..27ea9f96c0d 100644 --- a/eclass/gnome2.eclass +++ b/eclass/gnome2.eclass @@ -4,7 +4,7 @@ # @ECLASS: gnome2.eclass # @MAINTAINER: # gn...@gentoo.org -# @SUPPORTED_EAPIS: 5 6 +# @SUPPORTED_EAPIS: 5 6 7 # @BLURB: Provides phases for Gnome/Gtk+ based packages. # @DESCRIPTION: # Exports portage base functions used by ebuilds written for packages using the @@ -17,13 +17,14 @@ GNOME2_EAUTORECONF=${GNOME2_EAUTORECONF:-""} [[ ${GNOME2_EAUTORECONF} == 'yes' ]] && inherit autotools -inherit eutils libtool ltprune gnome.org gnome2-utils xdg +[[ ${EAPI} == [56] ]] && inherit eutils ltprune +inherit libtool gnome.org gnome2-utils xdg case ${EAPI:-0} in 5) EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install pkg_preinst pkg_postinst pkg_postrm ;; - 6) + 6|7) EXPORT_FUNCTIONS src_prepare src_configure src_compile src_install pkg_preinst pkg_postinst pkg_postrm ;; *) die "EAPI=${EAPI} is not supported" ;; @@ -70,8 +71,8 @@ fi # @ECLASS-VARIABLE: GNOME2_LA_PUNT # @DESCRIPTION: -# It relies on prune_libtool_files (from ltprune.eclass) -# for this. Available values for GNOME2_LA_PUNT: +# In EAPIs 5 and 6, it relies on prune_libtool_files (from ltprune.eclass) for +# this. Later EAPIs use find ... -delete. Available values for GNOME2_LA_PUNT: # - "no": will not clean any .la files # - "yes": will run prune_libtool_files --modules # - If it is not set, it will run prune_libtool_files @@ -85,7 +86,7 @@ gnome2_src_unpack() { unpack ${A} cd "${S}" else - die "gnome2_src_unpack is banned from eapi6" + die "gnome2_src_unpack is banned since eapi6" fi } @@ -264,11 +265,17 @@ gnome2_src_install() { rm -fr "${ED}/usr/share/applications/mimeinfo.cache" # Delete all .la files - case "${GNOME2_LA_PUNT}" in - yes)prune_libtool_files --modules;; - no) ;; - *) prune_libtool_files;; - esac + if has ${EAPI} 5 6; then + case "${GNOME2_LA_PUNT}" in + yes)prune_libtool_files --modules;; + no) ;; + *) prune_libtool_files;; + esac + else + if [[ ${GNOME2_LA_PUNT} != 'no' ]]; then + find "${ED}" -name '*.la' -delete || die + fi + fi } # @FUNCTION: gnome2_pkg_preinst -- 2.26.2
[gentoo-portage-dev] [PATCH v4] Use default asyncio event loop implementation in API consumer threads
Make the _safe_loop function return an AsyncioEventLoop instance, so that the default asyncio event loop implementation will be used in API consumer threads. This is possible because the underlying asyncio.get_event_loop() function returns a separate event loop for each thread. The AsyncioEventLoop _run_until_complete method will now appropriately handle a ValueError from signal.set_wakeup_fd(-1) if it is not called in the main thread. For external API consumers calling from a non-main thread, an asyncio loop must be registered for the current thread, or else an error will be raised like this: RuntimeError: There is no current event loop in thread 'Thread-1'. In order to avoid this RuntimeError, the external API consumer is responsible for setting an event loop and managing its lifecycle. This code will set an event loop for the current thread: asyncio.set_event_loop(asyncio.new_event_loop()) In order to avoid a ResourceWarning, the caller should also close the corresponding loop before the current thread terminates. Bug: https://bugs.gentoo.org/758755 Signed-off-by: Zac Medico --- [PATCH v4] treat external API consumers the same as interal callers if they call from the main thread, and document asyncio loop lifecycle management now required for external API consumers calling from a non-main thread .../util/_eventloop/asyncio_event_loop.py | 6 - lib/portage/util/futures/_asyncio/__init__.py | 26 ++- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/lib/portage/util/_eventloop/asyncio_event_loop.py b/lib/portage/util/_eventloop/asyncio_event_loop.py index 836f1c30a..4d7047ae8 100644 --- a/lib/portage/util/_eventloop/asyncio_event_loop.py +++ b/lib/portage/util/_eventloop/asyncio_event_loop.py @@ -121,4 +121,8 @@ class AsyncioEventLoop(_AbstractEventLoop): try: return self._loop.run_until_complete(future) finally: - self._wakeup_fd = signal.set_wakeup_fd(-1) + try: + self._wakeup_fd = signal.set_wakeup_fd(-1) + except ValueError: + # This is intended to fail when not called in the main thread. + pass diff --git a/lib/portage/util/futures/_asyncio/__init__.py b/lib/portage/util/futures/_asyncio/__init__.py index a902ad895..0b35c6daf 100644 --- a/lib/portage/util/futures/_asyncio/__init__.py +++ b/lib/portage/util/futures/_asyncio/__init__.py @@ -34,7 +34,6 @@ import portage portage.proxy.lazyimport.lazyimport(globals(), 'portage.util.futures.unix_events:_PortageEventLoopPolicy', 'portage.util.futures:compat_coroutine@_compat_coroutine', - 'portage.util._eventloop.EventLoop:EventLoop@_EventLoop', ) from portage.util._eventloop.asyncio_event_loop import AsyncioEventLoop as _AsyncioEventLoop from portage.util._eventloop.global_event_loop import ( @@ -246,14 +245,27 @@ def _wrap_loop(loop=None): def _safe_loop(): """ Return an event loop that's safe to use within the current context. - For portage internal callers, this returns a globally shared event - loop instance. For external API consumers, this constructs a - temporary event loop instance that's safe to use in a non-main - thread (it does not override the global SIGCHLD handler). + For portage internal callers or external API consumers calling from + the main thread, this returns a globally shared event loop instance. + + For external API consumers calling from a non-main thread, an + asyncio loop must be registered for the current thread, or else an + error will be raised like this: + + RuntimeError: There is no current event loop in thread 'Thread-1'. + + In order to avoid this RuntimeError, the external API consumer + is responsible for setting an event loop and managing its lifecycle. + This code will set an event loop for the current thread: + + asyncio.set_event_loop(asyncio.new_event_loop()) + + In order to avoid a ResourceWarning, the caller should also close the + corresponding loop before the current thread terminates. @rtype: asyncio.AbstractEventLoop (or compatible) @return: event loop instance """ - if portage._internal_caller: + if portage._internal_caller or threading.current_thread() is threading.main_thread(): return _global_event_loop() - return _EventLoop(main=False) + return _AsyncioEventLoop() -- 2.26.2
[gentoo-portage-dev] Re: [PATCH v3] Use default asyncio event loop implementation in API consumer threads
Accidentally encrypted the last email. Here's an unencrypted version. On 12/6/20 2:14 PM, Zac Medico wrote: > Make the _safe_loop function return an AsyncioEventLoop instance, > so that the default asyncio event loop implementation will be used > in API consumer threads. This is possible because the underlying > asyncio.get_event_loop() function returns a new event loop for > each thread. The AsyncioEventLoop _run_until_complete method will > now appropriately handle a ValueError from signal.set_wakeup_fd(-1) > if it is not called in the main thread. > > Bug: https://bugs.gentoo.org/758755 > Signed-off-by: Zac Medico > --- > [PATCH v3] fixed AsyncioEventLoop _run_until_complete method to > handle ValueError from signal.set_wakeup_fd(-1) > > lib/portage/util/_eventloop/asyncio_event_loop.py | 6 +- > lib/portage/util/futures/_asyncio/__init__.py | 3 +-- > 2 files changed, 6 insertions(+), 3 deletions(-) > > diff --git a/lib/portage/util/_eventloop/asyncio_event_loop.py > b/lib/portage/util/_eventloop/asyncio_event_loop.py > index 836f1c30a..4d7047ae8 100644 > --- a/lib/portage/util/_eventloop/asyncio_event_loop.py > +++ b/lib/portage/util/_eventloop/asyncio_event_loop.py > @@ -121,4 +121,8 @@ class AsyncioEventLoop(_AbstractEventLoop): > try: > return self._loop.run_until_complete(future) > finally: > - self._wakeup_fd = signal.set_wakeup_fd(-1) > + try: > + self._wakeup_fd = signal.set_wakeup_fd(-1) > + except ValueError: > + # This is intended to fail when not called in > the main thread. > + pass > diff --git a/lib/portage/util/futures/_asyncio/__init__.py > b/lib/portage/util/futures/_asyncio/__init__.py > index a902ad895..12013be00 100644 > --- a/lib/portage/util/futures/_asyncio/__init__.py > +++ b/lib/portage/util/futures/_asyncio/__init__.py > @@ -34,7 +34,6 @@ import portage > portage.proxy.lazyimport.lazyimport(globals(), > 'portage.util.futures.unix_events:_PortageEventLoopPolicy', > 'portage.util.futures:compat_coroutine@_compat_coroutine', > - 'portage.util._eventloop.EventLoop:EventLoop@_EventLoop', > ) > from portage.util._eventloop.asyncio_event_loop import AsyncioEventLoop as > _AsyncioEventLoop > from portage.util._eventloop.global_event_loop import ( > @@ -256,4 +255,4 @@ def _safe_loop(): > """ > if portage._internal_caller: > return _global_event_loop() > - return _EventLoop(main=False) > + return _AsyncioEventLoop() > This fails if an event loop has not been created for the current thread: File "/usr/lib/python3.8/asyncio/events.py", line 639, in get_event_loop raise RuntimeError('There is no current event loop in thread %r.' RuntimeError: There is no current event loop in thread 'Thread-1'. However, if we automatically instantiate a loop for the current thread then we will be responsible for closing it as well, or else we'll eventually see a ResourceWarning like this: /usr/lib/python3.8/asyncio/base_events.py:654: ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False> _warn(f"unclosed event loop {self!r}", ResourceWarning, source=self) ResourceWarning: Enable tracemalloc to get the object allocation traceback So, I think it's probably best if we force the API consumer to manage the lifecycle of an asyncio loop for each thread that it uses to call the portage API. -- Thanks, Zac signature.asc Description: OpenPGP digital signature
[gentoo-portage-dev] Re: [PATCH v3] Use default asyncio event loop implementation in API consumer threads
On 12/6/20 2:14 PM, Zac Medico wrote: > Make the _safe_loop function return an AsyncioEventLoop instance, > so that the default asyncio event loop implementation will be used > in API consumer threads. This is possible because the underlying > asyncio.get_event_loop() function returns a new event loop for > each thread. The AsyncioEventLoop _run_until_complete method will > now appropriately handle a ValueError from signal.set_wakeup_fd(-1) > if it is not called in the main thread. > > Bug: https://bugs.gentoo.org/758755 > Signed-off-by: Zac Medico > --- > [PATCH v3] fixed AsyncioEventLoop _run_until_complete method to > handle ValueError from signal.set_wakeup_fd(-1) > > lib/portage/util/_eventloop/asyncio_event_loop.py | 6 +- > lib/portage/util/futures/_asyncio/__init__.py | 3 +-- > 2 files changed, 6 insertions(+), 3 deletions(-) > > diff --git a/lib/portage/util/_eventloop/asyncio_event_loop.py > b/lib/portage/util/_eventloop/asyncio_event_loop.py > index 836f1c30a..4d7047ae8 100644 > --- a/lib/portage/util/_eventloop/asyncio_event_loop.py > +++ b/lib/portage/util/_eventloop/asyncio_event_loop.py > @@ -121,4 +121,8 @@ class AsyncioEventLoop(_AbstractEventLoop): > try: > return self._loop.run_until_complete(future) > finally: > - self._wakeup_fd = signal.set_wakeup_fd(-1) > + try: > + self._wakeup_fd = signal.set_wakeup_fd(-1) > + except ValueError: > + # This is intended to fail when not called in > the main thread. > + pass > diff --git a/lib/portage/util/futures/_asyncio/__init__.py > b/lib/portage/util/futures/_asyncio/__init__.py > index a902ad895..12013be00 100644 > --- a/lib/portage/util/futures/_asyncio/__init__.py > +++ b/lib/portage/util/futures/_asyncio/__init__.py > @@ -34,7 +34,6 @@ import portage > portage.proxy.lazyimport.lazyimport(globals(), > 'portage.util.futures.unix_events:_PortageEventLoopPolicy', > 'portage.util.futures:compat_coroutine@_compat_coroutine', > - 'portage.util._eventloop.EventLoop:EventLoop@_EventLoop', > ) > from portage.util._eventloop.asyncio_event_loop import AsyncioEventLoop as > _AsyncioEventLoop > from portage.util._eventloop.global_event_loop import ( > @@ -256,4 +255,4 @@ def _safe_loop(): > """ > if portage._internal_caller: > return _global_event_loop() > - return _EventLoop(main=False) > + return _AsyncioEventLoop() > This fails if an event loop has not been created for the current thread: File "/usr/lib/python3.8/asyncio/events.py", line 639, in get_event_loop raise RuntimeError('There is no current event loop in thread %r.' RuntimeError: There is no current event loop in thread 'Thread-1'. However, if we automatically instantiate a loop for the current thread then we will be responsible for closing it as well, or else we'll eventually see a ResourceWarning like this: /usr/lib/python3.8/asyncio/base_events.py:654: ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False> _warn(f"unclosed event loop {self!r}", ResourceWarning, source=self) ResourceWarning: Enable tracemalloc to get the object allocation traceback So, I think it's probably best if we force the API consumer to manage the lifecycle of an asyncio loop for each thread that it uses to call the portage API. -- Thanks, Zac signature.asc Description: OpenPGP digital signature
[gentoo-portage-dev] [PATCH v3] Use default asyncio event loop implementation in API consumer threads
Make the _safe_loop function return an AsyncioEventLoop instance, so that the default asyncio event loop implementation will be used in API consumer threads. This is possible because the underlying asyncio.get_event_loop() function returns a new event loop for each thread. The AsyncioEventLoop _run_until_complete method will now appropriately handle a ValueError from signal.set_wakeup_fd(-1) if it is not called in the main thread. Bug: https://bugs.gentoo.org/758755 Signed-off-by: Zac Medico --- [PATCH v3] fixed AsyncioEventLoop _run_until_complete method to handle ValueError from signal.set_wakeup_fd(-1) lib/portage/util/_eventloop/asyncio_event_loop.py | 6 +- lib/portage/util/futures/_asyncio/__init__.py | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/portage/util/_eventloop/asyncio_event_loop.py b/lib/portage/util/_eventloop/asyncio_event_loop.py index 836f1c30a..4d7047ae8 100644 --- a/lib/portage/util/_eventloop/asyncio_event_loop.py +++ b/lib/portage/util/_eventloop/asyncio_event_loop.py @@ -121,4 +121,8 @@ class AsyncioEventLoop(_AbstractEventLoop): try: return self._loop.run_until_complete(future) finally: - self._wakeup_fd = signal.set_wakeup_fd(-1) + try: + self._wakeup_fd = signal.set_wakeup_fd(-1) + except ValueError: + # This is intended to fail when not called in the main thread. + pass diff --git a/lib/portage/util/futures/_asyncio/__init__.py b/lib/portage/util/futures/_asyncio/__init__.py index a902ad895..12013be00 100644 --- a/lib/portage/util/futures/_asyncio/__init__.py +++ b/lib/portage/util/futures/_asyncio/__init__.py @@ -34,7 +34,6 @@ import portage portage.proxy.lazyimport.lazyimport(globals(), 'portage.util.futures.unix_events:_PortageEventLoopPolicy', 'portage.util.futures:compat_coroutine@_compat_coroutine', - 'portage.util._eventloop.EventLoop:EventLoop@_EventLoop', ) from portage.util._eventloop.asyncio_event_loop import AsyncioEventLoop as _AsyncioEventLoop from portage.util._eventloop.global_event_loop import ( @@ -256,4 +255,4 @@ def _safe_loop(): """ if portage._internal_caller: return _global_event_loop() - return _EventLoop(main=False) + return _AsyncioEventLoop() -- 2.26.2
[gentoo-portage-dev] [PATCH v2] Use default asyncio event loop implementation in API consumer threads
Make the _safe_loop function return an AsyncioEventLoop instance, so that the default asyncio event loop implementation will be used in API consumer threads. This is possible because the underlying asyncio.get_event_loop() function returns a new event loop for each thread. Bug: https://bugs.gentoo.org/758755 Signed-off-by: Zac Medico --- [PATCH v2] fixed _safe_loop function to return a new AsyncioEventLoop per thread lib/portage/util/futures/_asyncio/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/portage/util/futures/_asyncio/__init__.py b/lib/portage/util/futures/_asyncio/__init__.py index a902ad895..12013be00 100644 --- a/lib/portage/util/futures/_asyncio/__init__.py +++ b/lib/portage/util/futures/_asyncio/__init__.py @@ -34,7 +34,6 @@ import portage portage.proxy.lazyimport.lazyimport(globals(), 'portage.util.futures.unix_events:_PortageEventLoopPolicy', 'portage.util.futures:compat_coroutine@_compat_coroutine', - 'portage.util._eventloop.EventLoop:EventLoop@_EventLoop', ) from portage.util._eventloop.asyncio_event_loop import AsyncioEventLoop as _AsyncioEventLoop from portage.util._eventloop.global_event_loop import ( @@ -256,4 +255,4 @@ def _safe_loop(): """ if portage._internal_caller: return _global_event_loop() - return _EventLoop(main=False) + return _AsyncioEventLoop() -- 2.26.2
[gentoo-dev] [PATCH] gnome2.eclass: Add EAPI=7 support
Closes: https://bugs.gentoo.org/717100 Signed-off-by: Matt Turner --- leio noted that the previous patch would potentially change the installed .la files in EAPI 5 and 6 ebuilds. So just continue using ltprune in those EAPIs and ban GNOME2_LA_PUNT in EAPI 7. eclass/gnome2.eclass | 18 +- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/eclass/gnome2.eclass b/eclass/gnome2.eclass index 341802f8c80..546438f289c 100644 --- a/eclass/gnome2.eclass +++ b/eclass/gnome2.eclass @@ -4,7 +4,7 @@ # @ECLASS: gnome2.eclass # @MAINTAINER: # gn...@gentoo.org -# @SUPPORTED_EAPIS: 5 6 +# @SUPPORTED_EAPIS: 5 6 7 # @BLURB: Provides phases for Gnome/Gtk+ based packages. # @DESCRIPTION: # Exports portage base functions used by ebuilds written for packages using the @@ -17,13 +17,14 @@ GNOME2_EAUTORECONF=${GNOME2_EAUTORECONF:-""} [[ ${GNOME2_EAUTORECONF} == 'yes' ]] && inherit autotools -inherit eutils libtool ltprune gnome.org gnome2-utils xdg +[[ ${EAPI} == [56] ]] && inherit eutils ltprune +inherit libtool gnome.org gnome2-utils xdg case ${EAPI:-0} in 5) EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install pkg_preinst pkg_postinst pkg_postrm ;; - 6) + 6|7) EXPORT_FUNCTIONS src_prepare src_configure src_compile src_install pkg_preinst pkg_postinst pkg_postrm ;; *) die "EAPI=${EAPI} is not supported" ;; @@ -75,7 +76,14 @@ fi # - "no": will not clean any .la files # - "yes": will run prune_libtool_files --modules # - If it is not set, it will run prune_libtool_files -GNOME2_LA_PUNT=${GNOME2_LA_PUNT:-""} +# Banned since eapi7. +if has ${EAPI} 5 6; then + GNOME2_LA_PUNT=${GNOME2_LA_PUNT:-""} +elif [[ -n $GNOME_LA_PUNT ]]; then + die "GNOME2_LA_PUNT is banned since eapi7" +else + GNOME2_LA_PUNT="no" +fi # @FUNCTION: gnome2_src_unpack # @DESCRIPTION: @@ -85,7 +93,7 @@ gnome2_src_unpack() { unpack ${A} cd "${S}" else - die "gnome2_src_unpack is banned from eapi6" + die "gnome2_src_unpack is banned since eapi6" fi } -- 2.26.2
[gentoo-dev] [PATCH] gnome2.eclass: Add EAPI=7 support
Mostly by porting away from ltprune.eclass. Signed-off-by: Matt Turner --- eclass/gnome2.eclass | 19 +-- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/eclass/gnome2.eclass b/eclass/gnome2.eclass index 341802f8c80..4d8dc6c08d6 100644 --- a/eclass/gnome2.eclass +++ b/eclass/gnome2.eclass @@ -4,7 +4,7 @@ # @ECLASS: gnome2.eclass # @MAINTAINER: # gn...@gentoo.org -# @SUPPORTED_EAPIS: 5 6 +# @SUPPORTED_EAPIS: 5 6 7 # @BLURB: Provides phases for Gnome/Gtk+ based packages. # @DESCRIPTION: # Exports portage base functions used by ebuilds written for packages using the @@ -17,13 +17,14 @@ GNOME2_EAUTORECONF=${GNOME2_EAUTORECONF:-""} [[ ${GNOME2_EAUTORECONF} == 'yes' ]] && inherit autotools -inherit eutils libtool ltprune gnome.org gnome2-utils xdg +[[ ${EAPI} == [56] ]] && inherit eutils +inherit libtool gnome.org gnome2-utils xdg case ${EAPI:-0} in 5) EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install pkg_preinst pkg_postinst pkg_postrm ;; - 6) + 6|7) EXPORT_FUNCTIONS src_prepare src_configure src_compile src_install pkg_preinst pkg_postinst pkg_postrm ;; *) die "EAPI=${EAPI} is not supported" ;; @@ -70,12 +71,11 @@ fi # @ECLASS-VARIABLE: GNOME2_LA_PUNT # @DESCRIPTION: -# It relies on prune_libtool_files (from ltprune.eclass) -# for this. Available values for GNOME2_LA_PUNT: +# Available values for GNOME2_LA_PUNT: # - "no": will not clean any .la files -# - "yes": will run prune_libtool_files --modules -# - If it is not set, it will run prune_libtool_files -GNOME2_LA_PUNT=${GNOME2_LA_PUNT:-""} +# - "yes": will run "find "${ED}" -name '*.la' -delete" +# - If it is not set, it will prune libtool files +GNOME2_LA_PUNT=${GNOME2_LA_PUNT:-"yes"} # @FUNCTION: gnome2_src_unpack # @DESCRIPTION: @@ -265,9 +265,8 @@ gnome2_src_install() { # Delete all .la files case "${GNOME2_LA_PUNT}" in - yes)prune_libtool_files --modules;; no) ;; - *) prune_libtool_files;; + *) find "${ED}" -name '*.la' -delete || die;; esac } -- 2.26.2
[gentoo-dev] [PATCH] gnome2-utils.eclass: Drop EAPI < 5 support
Closes: https://bugs.gentoo.org/566728 Signed-off-by: Matt Turner --- eclass/gnome2-utils.eclass | 25 +++-- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/eclass/gnome2-utils.eclass b/eclass/gnome2-utils.eclass index 06643db0f60..bc1f8f20777 100644 --- a/eclass/gnome2-utils.eclass +++ b/eclass/gnome2-utils.eclass @@ -4,7 +4,7 @@ # @ECLASS: gnome2-utils.eclass # @MAINTAINER: # gn...@gentoo.org -# @SUPPORTED_EAPIS: 0 1 2 3 4 5 6 7 +# @SUPPORTED_EAPIS: 5 6 7 # @BLURB: Auxiliary functions commonly used by Gnome packages. # @DESCRIPTION: # This eclass provides a set of auxiliary functions needed by most Gnome @@ -14,13 +14,13 @@ # * GConf schemas management # * scrollkeeper (old Gnome help system) management -[[ ${EAPI:-0} == [012345] ]] && inherit multilib +[[ ${EAPI} == 5 ]] && inherit multilib # eutils.eclass: emktemp # xdg-utils.eclass: xdg_environment_reset, xdg_icon_cache_update inherit eutils xdg-utils -case "${EAPI:-0}" in - 0|1|2|3|4|5|6|7) ;; +case ${EAPI} in + 5|6|7) ;; *) die "EAPI=${EAPI} is not supported" ;; esac @@ -95,7 +95,7 @@ gnome2_environment_reset() { # Ensure we don't rely on dconf/gconf while building, bug #511946 export GSETTINGS_BACKEND="memory" - if has ${EAPI:-0} 6 7; then + if has ${EAPI} 6 7; then # Try to cover the packages honoring this variable, bug #508124 export GST_INSPECT="$(type -P true)" @@ -110,7 +110,6 @@ gnome2_environment_reset() { # in the GNOME2_ECLASS_SCHEMAS environment variable. # This function should be called from pkg_preinst. gnome2_gconf_savelist() { - has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}" pushd "${ED}" > /dev/null || die export GNOME2_ECLASS_SCHEMAS=$(find 'etc/gconf/schemas/' -name '*.schemas' 2> /dev/null) popd > /dev/null || die @@ -122,7 +121,6 @@ gnome2_gconf_savelist() { # using gconftool-2. # This function should be called from pkg_postinst. gnome2_gconf_install() { - has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" local updater="${EROOT%/}${GCONFTOOL_BIN}" if [[ ! -x "${updater}" ]]; then @@ -163,7 +161,6 @@ gnome2_gconf_install() { # Removes schema files previously installed by the current ebuild from Gconf's # database. gnome2_gconf_uninstall() { - has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" local updater="${EROOT%/}${GCONFTOOL_BIN}" if [[ ! -x "${updater}" ]]; then @@ -255,7 +252,6 @@ gnome2_omf_fix() { # in the GNOME2_ECLASS_SCROLLS environment variable. # This function should be called from pkg_preinst. gnome2_scrollkeeper_savelist() { - has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}" pushd "${ED}" > /dev/null || die export GNOME2_ECLASS_SCROLLS=$(find 'usr/share/omf' -type f -name "*.omf" 2> /dev/null) popd > /dev/null || die @@ -266,7 +262,6 @@ gnome2_scrollkeeper_savelist() { # Updates the global scrollkeeper database. # This function should be called from pkg_postinst and pkg_postrm. gnome2_scrollkeeper_update() { - has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" local updater="${EROOT%/}${SCROLLKEEPER_UPDATE_BIN}" if [[ ! -x "${updater}" ]] ; then @@ -291,7 +286,6 @@ gnome2_scrollkeeper_update() { # implementations that call gnome2_schemas_update conditionally. # This function should be called from pkg_preinst. gnome2_schemas_savelist() { - has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}" pushd "${ED}" > /dev/null || die export GNOME2_ECLASS_GLIB_SCHEMAS=$(find 'usr/share/glib-2.0/schemas' -name '*.gschema.xml' 2>/dev/null) popd > /dev/null || die @@ -302,7 +296,6 @@ gnome2_schemas_savelist() { # Updates GSettings schemas. # This function should be called from pkg_postinst and pkg_postrm. gnome2_schemas_update() { - has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" local updater="${EROOT%/}${GLIB_COMPILE_SCHEMAS}" if [[ ! -x ${updater} ]]; then @@ -321,7 +314,6 @@ gnome2_schemas_update() { # GNOME2_ECLASS_GDK_PIXBUF_LOADERS variable. # This function should be called from pkg_preinst. gnome2_gdk_pixbuf_savelist() { - has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}" pushd "${ED}" > /dev/null || die export GNOME2_ECLASS_GDK_PIXBUF_LOADERS=$(find usr/lib*/gdk-pixbuf-2.0 -type f 2>/dev/null) popd > /dev/null || die @@ -332,7 +324,6 @@ gnome2_gdk_pixbuf_savelist() { # Updates gdk-pixbuf loader cache if GNOME2_ECLASS_GDK_PIXBUF_LOADERS has some. # This function should be called from pkg_postinst and pkg_postrm. gnome2_gdk_pixbuf_update() { - has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" local updater="${EROOT%/}/usr/bin/${CHOST}-gdk-pixbuf-query-loaders" if [[ ! -x ${updater} ]]; then @@ -389,7 +380,6 @@ gnome2_query_immodules_gtk3() { # Updates glib's gio modules cache. # This
Re: [gentoo-dev] [PATCH] gnome2-utils: Drop EAPI < 5 support
> On Sun, 06 Dec 2020, Matt Turner wrote: > -[[ ${EAPI:-0} == [012345] ]] && inherit multilib > +[[ ${EAPI:-0} == [5] ]] && inherit multilib Useless brackets. Also you could drop the :-0 here. > case "${EAPI:-0}" in No quotes needed here. > - 0|1|2|3|4|5|6|7) ;; > - *) die "EAPI=${EAPI} is not supported" ;; > + 5|6|7) ;; > + 0|1|2|3|4) die "EAPI=${EAPI} is not supported" ;; > esac This should have a * instead of an explicit list of unknown EAPIs. > case ${EAPI:-0} in > -0|1|2|3|4|5|6) > +5|6) See above, :-0 could be dropped. Ulrich signature.asc Description: PGP signature
[gentoo-portage-dev] Re: [PATCH] Use default asyncio event loop implementation in API consumer threads
On 12/6/20 1:46 AM, Zac Medico wrote: > Make the _safe_loop function an alias for the global_event_loop > function, so that the default asyncio event loop implementation > will be used in API consumer threads. This is possible because > global_event_loop has been fixed (bug 758740) to always use > AsyncioEventLoop, and that uses asyncio.get_event_loop() which > returns a new event loop for each thread. I think we may still need a separate _safe_loop function here, since global_event_loop returns a separate loop per pid, but _safe_loop needs to return a separate loop per thread. -- Thanks, Zac signature.asc Description: OpenPGP digital signature
[gentoo-dev] Last-rites: more broken LiveOnlyPackages
# Not keyworded, unmaintained, unbuildable for a long time, EAPI-5. # Removal in ~30 days. List sorted by their bug numbers. # Bugs: #752432, #752435, #752438, #752441, #752444, #752453. media-plugins/kodi-screensaver-crystalmorph media-plugins/kodi-visualization-nastyfft media-plugins/kodi-screensaver-rsxs net-wireless/qradiolink net-libs/liba53 app-emulation/qt-virt-manager OpenPGP_signature Description: OpenPGP digital signature
[gentoo-portage-dev] [PATCH] Use default asyncio event loop implementation in API consumer threads
Make the _safe_loop function an alias for the global_event_loop function, so that the default asyncio event loop implementation will be used in API consumer threads. This is possible because global_event_loop has been fixed (bug 758740) to always use AsyncioEventLoop, and that uses asyncio.get_event_loop() which returns a new event loop for each thread. Bug: https://bugs.gentoo.org/758755 Signed-off-by: Zac Medico --- lib/portage/util/futures/_asyncio/__init__.py | 17 + 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/lib/portage/util/futures/_asyncio/__init__.py b/lib/portage/util/futures/_asyncio/__init__.py index a902ad895..ce3685709 100644 --- a/lib/portage/util/futures/_asyncio/__init__.py +++ b/lib/portage/util/futures/_asyncio/__init__.py @@ -39,6 +39,7 @@ portage.proxy.lazyimport.lazyimport(globals(), from portage.util._eventloop.asyncio_event_loop import AsyncioEventLoop as _AsyncioEventLoop from portage.util._eventloop.global_event_loop import ( global_event_loop as _global_event_loop, + global_event_loop as _safe_loop, ) # pylint: disable=redefined-builtin from portage.util.futures.futures import ( @@ -241,19 +242,3 @@ def _wrap_loop(loop=None): loop = loop or _global_event_loop() return (loop if hasattr(loop, '_asyncio_wrapper') else _AsyncioEventLoop(loop=loop)) - - -def _safe_loop(): - """ - Return an event loop that's safe to use within the current context. - For portage internal callers, this returns a globally shared event - loop instance. For external API consumers, this constructs a - temporary event loop instance that's safe to use in a non-main - thread (it does not override the global SIGCHLD handler). - - @rtype: asyncio.AbstractEventLoop (or compatible) - @return: event loop instance - """ - if portage._internal_caller: - return _global_event_loop() - return _EventLoop(main=False) -- 2.26.2
[gentoo-portage-dev] [PATCH] Use default asyncio event loop implementation in child processes
Use the default asyncio event loop implementation in child processes, instead of portage's internal EventLoop. After fork, instantiate a new asyncio.DefaultEventLoopPolicy as a workaround for https://bugs.python.org/issue22087, which is necessary for RetryTestCase to succeed. Bug: https://bugs.gentoo.org/758740 Signed-off-by: Zac Medico --- lib/portage/__init__.py | 4 lib/portage/util/_eventloop/global_event_loop.py | 7 --- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/portage/__init__.py b/lib/portage/__init__.py index 4d4b590a8..2b821e81a 100644 --- a/lib/portage/__init__.py +++ b/lib/portage/__init__.py @@ -9,6 +9,7 @@ VERSION = "HEAD" # === try: + import asyncio import sys import errno if not hasattr(errno, 'ESTALE'): @@ -373,6 +374,9 @@ class _ForkWatcher: @staticmethod def hook(_ForkWatcher): _ForkWatcher.current_pid = _os.getpid() + # Force instantiation of a new event loop as a workaround for + # https://bugs.python.org/issue22087. + asyncio.set_event_loop_policy(asyncio.DefaultEventLoopPolicy()) _ForkWatcher.hook(_ForkWatcher) diff --git a/lib/portage/util/_eventloop/global_event_loop.py b/lib/portage/util/_eventloop/global_event_loop.py index 21a1d1970..413011178 100644 --- a/lib/portage/util/_eventloop/global_event_loop.py +++ b/lib/portage/util/_eventloop/global_event_loop.py @@ -2,11 +2,8 @@ # Distributed under the terms of the GNU General Public License v2 import portage -from .EventLoop import EventLoop from portage.util._eventloop.asyncio_event_loop import AsyncioEventLoop - -_MAIN_PID = portage.getpid() _instances = {} @@ -22,10 +19,6 @@ def global_event_loop(): return instance constructor = AsyncioEventLoop - # If the default constructor doesn't support multiprocessing, - # then multiprocessing constructor is used in subprocesses. - if not constructor.supports_multiprocessing and pid != _MAIN_PID: - constructor = EventLoop # Use the _asyncio_wrapper attribute, so that unit tests can compare # the reference to one retured from _wrap_loop(), since they should -- 2.26.2