Update to 3.1.4 (RHBZ#2175448)

- Drop patches (merged upstream)
- Disable zsh tests (I will re-open upstream issue #447)
- Various edits due to upstream changes
This commit is contained in:
Sandro 2023-11-09 13:17:52 +01:00
parent 2025f6350a
commit d9dd6572e9
No known key found for this signature in database
GPG Key ID: 68D0FF74FE9F382A
6 changed files with 14 additions and 175 deletions

1
.gitignore vendored
View File

@ -23,3 +23,4 @@
/argcomplete-1.12.2.tar.gz
/argcomplete-1.12.3.tar.gz
/argcomplete-2.0.0.tar.gz
/argcomplete-3.1.4.tar.gz

View File

@ -1,64 +0,0 @@
From d0fbcd20a24114fab5b6df71e86065b9a7c7576d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
Date: Thu, 14 Sep 2023 14:20:27 +0200
Subject: [PATCH] Ensure Python 3.12+ compatibility in check_console_script
In f4d046c0cec1dab17f65853442b1da7d341e2915 an assumption was made
(correct at the time), that only the importlib.metadata backport,
`importlib_metadata`, returns a tuple of entry points.
However, importlib.metadata in Python 3.12+ behaves the same.
This caused a KeyError exception to be thrown on Python 3.12,
as reported repeatedly be testers of Fedora Linux 39 in:
https://bugzilla.redhat.com/show_bug.cgi?id=2231593
This change adjusts the conditional used in check_console_script
to assume both the backport and Python 3.12+ return a tuple.
While not obvious from the test failures output,
this change also fixes the following TestBashGlobal tests failures:
- test_console_script_module
- test_console_script_module_wheel
- test_console_script_package
- test_console_script_package_wheel
For the reference, the failures looked like this:
FAIL: test_console_script_module (__main__.TestBashGlobal.test_console_script_module)
Test completing a console_script for a module.
----------------------------------------------------------------------
Traceback (most recent call last):
File ".../argcomplete/test/test.py", line 1376, in test_console_script_module
self._test_console_script()
File ".../argcomplete/test/test.py", line 1370, in _test_console_script
self.assertEqual(self.sh.run_command(command), "arg\r\n")
AssertionError: "usage: test-module [-h] {arg}\r\ntest-mo[66 chars]\r\n" != 'arg\r\n'
+ arg
- usage: test-module [-h] {arg}
- test-module: error: argument arg: invalid choice: 'a' (choose from 'arg')
Fixes https://github.com/kislyuk/argcomplete/issues/440
---
argcomplete/_check_console_script.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/argcomplete/_check_console_script.py b/argcomplete/_check_console_script.py
index 3f838e4..7bbe59a 100644
--- a/argcomplete/_check_console_script.py
+++ b/argcomplete/_check_console_script.py
@@ -38,7 +38,8 @@ def main():
# 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:
+ # Python 3.12+ behaves like the importlib_metadata backport
+ if not use_entry_points_backport and sys.version_info < (3, 12):
entry_points = entry_points["console_scripts"]
entry_points = [ep for ep in entry_points \
--
2.41.0

View File

@ -1,56 +0,0 @@
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

View File

@ -1,25 +0,0 @@
From 0c7610ecd087b5f906772db7f5085db3b38e83c1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hrn=C4=8Diar?= <thrnciar@redhat.com>
Date: Wed, 5 Jan 2022 08:40:21 +0100
Subject: [PATCH] Remove commit hash from Fish version
---
test/test.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/test.py b/test/test.py
index c2396ce..75e281c 100755
--- a/test/test.py
+++ b/test/test.py
@@ -31,7 +31,7 @@ COMP_WORDBREAKS = " \t\n\"'><=;|&(:"
BASH_VERSION = subprocess.check_output(['bash', '-c', 'echo $BASH_VERSION']).decode()
BASH_MAJOR_VERSION = int(BASH_VERSION.split('.')[0])
FISH_VERSION_STR = subprocess.check_output(['fish', '-c', 'echo -n $version']).decode()
-FISH_VERSION_TUPLE = tuple(int(x) for x in FISH_VERSION_STR.split('.'))
+FISH_VERSION_TUPLE = tuple(int(x) for x in FISH_VERSION_STR.split('-',1)[0].split('.'))
class TempDir(object):
--
2.33.1

View File

@ -7,34 +7,18 @@
Name: python-argcomplete
Summary: Bash tab completion for argparse
Version: 2.0.0
Version: 3.1.4
Release: %autorelease
License: Apache-2.0
URL: https://github.com/kislyuk/argcomplete
Source0: %pypi_source argcomplete
# Fish in Fedora contains git hash in version which breaks tests,
# this patch removes it
Patch: Remove-commit-hash-from-Fish-version.patch
# Ensure Python 3.7+ compatibility in check_console_script
# Rebased from https://github.com/kislyuk/argcomplete/commit/f4d046c0ce
# Partial fix for https://bugzilla.redhat.com/2231593
Patch: Ensure-Python-3.7-compatibility-in-check_console_script.patch
# Ensure Python 3.12+ compatibility in check_console_script
# Rebased from https://github.com/kislyuk/argcomplete/pull/448
# A second part of the fix for https://bugzilla.redhat.com/2231593
Patch: Ensure-Python-3.12-compatibility-in-check_console_script.patch
BuildRequires: python3-devel
%if %{with check}
BuildRequires: tcsh
BuildRequires: fish
BuildRequires: /usr/bin/pip
BuildRequires: python3-pexpect
BuildRequires: python3-wheel
BuildRequires: zsh
%endif
BuildArch: noarch
@ -61,8 +45,8 @@ Summary: %{summary}
%prep
%autosetup -p1 -n argcomplete-%{version}
# Remove useless BRs
sed -i -r -e '/tests_require = /s/"(coverage|flake8|wheel)"[, ]*//g' setup.py
# Remove useless BRs (aka linters)
sed -i -r -e '/test = /s/"(coverage|ruff|mypy)"[, ]*//g' pyproject.toml
# https://github.com/kislyuk/argcomplete/issues/255
# https://github.com/kislyuk/argcomplete/issues/256
@ -81,16 +65,16 @@ sed -i -e "s|python |python3 |" test/test.py
# do not attempt to install to %%bash_completions_dir, see https://bugzilla.redhat.com/2211862
install -Dp -m0644 argcomplete/bash_completion.d/%{name} %{buildroot}%{_sysconfdir}/bash_completion.d/%{name}
install -Dp -m0644 argcomplete/bash_completion.d/_%{name} %{buildroot}%{_sysconfdir}/bash_completion.d/_%{name}
%if %{with check}
%check
# workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1914782
# upstream: https://github.com/kislyuk/argcomplete/issues/337
echo "set enable-bracketed-paste off" > .inputrc
export INPUTRC=$PWD/.inputrc
%{python3} setup.py test
# Disable zsh tests. They fail for mysterious reasons.
# https://github.com/kislyuk/argcomplete/issues/447
%{py3_test_envvars} %{python3} test/test.py -v -k "TestArgcomplete"
%{py3_test_envvars} %{python3} test/test.py -v -k "TestBash"
%{py3_test_envvars} %{python3} test/test.py -v -k "TestCheckModule"
%{py3_test_envvars} %{python3} test/test.py -v -k "TestSplitLine"
%endif
%files -n python3-argcomplete -f %{pyproject_files}
@ -98,9 +82,8 @@ export INPUTRC=$PWD/.inputrc
%doc README.rst
%{_bindir}/activate-global-python-argcomplete
%{_bindir}/python-argcomplete-check-easy-install-script
%{_bindir}/python-argcomplete-tcsh
%{_bindir}/register-python-argcomplete
%{_sysconfdir}/bash_completion.d/%{name}
%{_sysconfdir}/bash_completion.d/_%{name}
%changelog
%autochangelog

View File

@ -1 +1 @@
SHA512 (argcomplete-2.0.0.tar.gz) = ef2a551e1372ecf3739006fe2c020e9f7ec53c5809680dcd3d9d552290565d8d09ba22bcc989f40644120a129b101f8e2e8ed34723e947a7d8d7884e9b502c31
SHA512 (argcomplete-3.1.4.tar.gz) = d5108273fb570ec42667acefd1cf397e2fbedb3d4fbc31bb2b3206cdbb3275fde88b4d40e9dc65045b6a94334e6b5b9136054c6291edc21dcd0542f1369fe4b1