#18 [F39] Fix KeyError: 'console_scripts'
Closed 9 months ago by churchyard. Opened 9 months ago by churchyard.
rpms/ churchyard/python-argcomplete keyerror  into  f39

@@ -0,0 +1,56 @@ 

+ From 999d3b16dd40a3b8b70c3c21a08365da6cfe867b Mon Sep 17 00:00:00 2001

+ From: Alex <76689481+flu0r1ne@users.noreply.github.com>

+ Date: Sun, 4 Jun 2023 20:43:41 -0500

+ Subject: [PATCH] Ensure Python 3.7 compatibility in check_console_script

+  (#436)

+ 

+ * Ensure Py3.7 compatibility in check_console_script

+ 

+ The importlib backport, `importlib_metadata`, returns a tuple of

+ entry points instead of a dictionary keyed by entry group. This inconsistency

+ caused a KeyError exception to be thrown. To resolve this issue, the script has

+ been adjusted to maintain compatibility with Python 3.7, as specified in

+ `setup.py`.

+ ---

+  argcomplete/_check_console_script.py | 16 +++++++++++++++-

+  1 file changed, 15 insertions(+), 1 deletion(-)

+ 

+ diff --git a/argcomplete/_check_console_script.py b/argcomplete/_check_console_script.py

+ index fdfb88f..3f838e4 100644

+ --- a/argcomplete/_check_console_script.py

+ +++ b/argcomplete/_check_console_script.py

+ @@ -16,8 +16,12 @@ import sys

+  

+  try:

+      from importlib.metadata import entry_points as importlib_entry_points

+ +    from importlib.metadata import EntryPoint

+ +    use_entry_points_backport = False

+  except ImportError:

+      from importlib_metadata import entry_points as importlib_entry_points

+ +    from importlib_metadata import EntryPoint

+ +    use_entry_points_backport = True

+  

+  from ._check_module import ArgcompleteMarkerNotFound, find

+  

+ @@ -29,7 +33,17 @@ def main():

+      # Find the module and function names that correspond to this

+      # assuming it is actually a console script.

+      name = os.path.basename(script_path)

+ -    entry_points = [ep for ep in importlib_entry_points()["console_scripts"] if ep.name == name]

+ +

+ +    entry_points = importlib_entry_points()

+ +

+ +    # The importlib_metadata backport returns a tuple of entry point objects

+ +    # whereas the official library returns a SelectableGroups object

+ +    if not use_entry_points_backport:

+ +        entry_points = entry_points["console_scripts"]

+ +

+ +    entry_points = [ep for ep in entry_points \

+ +            if ep.name == name and ep.group == "console_scripts" ]

+ +

+      if not entry_points:

+          raise ArgcompleteMarkerNotFound('no entry point found matching script')

+      entry_point = entry_points[0]

+ -- 

+ 2.40.1

+ 

file modified
+10 -1
@@ -8,7 +8,7 @@ 

  Name:          python-argcomplete

  Summary:       Bash tab completion for argparse

  Version:       2.0.0

- Release:       10%{?dist}

+ Release:       11%{?dist}

  License:       ASL 2.0

  URL:           https://github.com/kislyuk/argcomplete

  Source0:       %pypi_source argcomplete
@@ -22,6 +22,11 @@ 

  # Upstream already skips those on MacOS, so we skip them as well

  Patch2:        0002-Skip-tests-that-fail-on-Python-3.12.patch

  

+ # Ensure Python 3.7+ compatibility in check_console_script

+ # Rebased from https://github.com/kislyuk/argcomplete/commit/f4d046c0ce

+ # Should fix https://bugzilla.redhat.com/2231593

+ Patch3:        0003-Ensure-Python-3.7-compatibility-in-check_console_script.patch

+ 

  BuildRequires: python3-devel

  BuildRequires: python3-setuptools

  
@@ -96,6 +101,10 @@ 

  %{_sysconfdir}/bash_completion.d/%{name}

  

  %changelog

+ * Sun Aug 13 2023 Miro Hrončok <mhroncok@redhat.com> - 2.0.0-11

+ - Fix KeyError: 'console_scripts'

+ - Fixes: rhbz#2231593

+ 

  * Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.0-10

  - Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

  

no initial comment

Pull-Request has been closed by churchyard

9 months ago