15
0

- Update to the version 3.5.1:

- Restore compatibility with argparse in Python 3.12.7+
  - Use project.scripts instead of setuptools scripts
  - Test infrastructure improvements
- Remove upstreamed patches:
  - argparse-3_12_7.patch

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-argcomplete?expand=0&rev=80
This commit is contained in:
2024-10-29 17:08:44 +00:00
committed by Git OBS Bridge
parent 749886ae5f
commit c33f4bc810
5 changed files with 176 additions and 12 deletions

Binary file not shown.

3
argcomplete-3.5.1.tar.gz Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:eb1ee355aa2557bd3d0145de7b06b2a45b0ce461e1e7813f5d066039ab4177b4
size 82280

View File

@@ -1,3 +1,13 @@
-------------------------------------------------------------------
Tue Oct 29 17:07:05 UTC 2024 - Matej Cepl <mcepl@cepl.eu>
- Update to the version 3.5.1:
- Restore compatibility with argparse in Python 3.12.7+
- Use project.scripts instead of setuptools scripts
- Test infrastructure improvements
- Remove upstreamed patches:
- argparse-3_12_7.patch
-------------------------------------------------------------------
Sun Oct 6 21:27:22 UTC 2024 - Matej Cepl <mcepl@cepl.eu>

View File

@@ -18,27 +18,36 @@
%{?sle15_python_module_pythons}
Name: python-argcomplete
Version: 3.4.0
%global flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == "test"
%define psuffix -test
%bcond_without test
%else
%define psuffix %{nil}
%bcond_with test
%endif
Name: python-argcomplete%{psuffix}
Version: 3.5.1
Release: 0
Summary: Bash tab completion for argparse
License: Apache-2.0
Group: Development/Languages/Python
URL: https://github.com/kislyuk/argcomplete
Source: https://files.pythonhosted.org/packages/source/a/argcomplete/argcomplete-%{version}.tar.gz
# PATCH-FIX-OPENSUSE argparse-3_12_7.patch gh#kislyuk/argcomplete#507 mcepl@suse.com
# fix the incompatibility with Python 3.12.7+
Patch0: argparse-3_12_7.patch
BuildRequires: %{python_module base >= 3.8}
BuildRequires: %{python_module pexpect}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools >= 67.2}
BuildRequires: %{python_module setuptools_scm >= 6.2}
BuildRequires: %{python_module wheel}
BuildRequires: ca-certificates-mozilla
BuildRequires: fdupes
BuildRequires: python-rpm-macros
%if %{with test}
BuildRequires: %{python_module argcomplete == %{version}}
BuildRequires: %{python_module pexpect}
BuildRequires: ca-certificates-mozilla
BuildRequires: fish
BuildRequires: zsh
%endif
Requires(post): update-alternatives
Requires(postun): update-alternatives
BuildArch: noarch
@@ -62,31 +71,40 @@ resources over the network).
%autosetup -p1 -n argcomplete-%{version}
%build
%if %{without test}
%pyproject_wheel
%endif
%install
%if %{without test}
%pyproject_install
%python_clone -a %{buildroot}%{_bindir}/activate-global-python-argcomplete
%python_clone -a %{buildroot}%{_bindir}/register-python-argcomplete
%python_clone -a %{buildroot}%{_bindir}/python-argcomplete-check-easy-install-script
rm %{buildroot}%{_bindir}/activate-global-python-argcomplete
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%endif
%check
%if %{with test}
export LANG=en_US.UTF-8
export TERM=xterm-mono
%{python_expand \
# https://github.com/kislyuk/argcomplete/issues/255
# https://github.com/kislyuk/argcomplete/issues/299
sed -i -e "1s|#!.*python.*|#!%{__$python}|" test/prog test/*.py scripts/*
sed -i -e "1s|#!.*python.*|#!%{__$python}|" test/prog test/*.py
sed -i -e "s|python3 |$python |g" test/test.py
PYTHONPATH=%{buildroot}%{$python_sitelib} $python ./test/test.py -v
}
%endif
%if %{without test}
%post
%python_install_alternative activate-global-python-argcomplete
%python_install_alternative register-python-argcomplete
%python_install_alternative python-argcomplete-check-easy-install-script
%postun
%python_uninstall_alternative activate-global-python-argcomplete
%python_uninstall_alternative register-python-argcomplete
%python_uninstall_alternative python-argcomplete-check-easy-install-script
@@ -95,7 +113,9 @@ export TERM=xterm-mono
%license LICENSE.rst
%{python_sitelib}/argcomplete-%{version}.dist-info
%{python_sitelib}/argcomplete
%python_alternative %{_bindir}/activate-global-python-argcomplete
%python_alternative %{_bindir}/python-argcomplete-check-easy-install-script
%python_alternative %{_bindir}/register-python-argcomplete
%endif
%changelog

View File

@@ -0,0 +1,134 @@
---
test/test.py | 20 +++++++++++---------
test/test_contrib_shells.py | 13 ++++++-------
2 files changed, 17 insertions(+), 16 deletions(-)
--- a/test/test.py
+++ b/test/test.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3.10
import argparse
import contextlib
import os
@@ -19,6 +19,8 @@ TEST_DIR = os.path.abspath(os.path.dirna
BASE_DIR = os.path.dirname(TEST_DIR)
sys.path.insert(0, BASE_DIR)
+py_ver = "%s.%s" % sys.version_info[:2]
+
from argparse import SUPPRESS, ArgumentParser # noqa: E402
import argcomplete # noqa: E402
@@ -1254,7 +1256,7 @@ class TestBashZshBase(TestShellBase):
init_cmd = None
# 'dummy' argument unused; checks multi-command registration works
# by passing 'prog' as the second argument.
- install_cmd = 'eval "$(register-python-argcomplete dummy prog)"'
+ install_cmd = 'eval "$(register-python-argcomplete-{} dummy prog)"'.format(py_ver)
def setUp(self):
sh = self.repl_provider()
@@ -1271,7 +1273,7 @@ class TestBashZshBase(TestShellBase):
self.assertEqual(output, "")
# Register a dummy completion with an external argcomplete script
# to ensure this doesn't overwrite our previous registration.
- output = sh.run_command('eval "$(register-python-argcomplete dummy --external-argcomplete-script dummy)"')
+ output = sh.run_command('eval "$(register-python-argcomplete dummy-{} --external-argcomplete-script dummy)"'.format(py_ver))
self.assertEqual(output, "")
self.sh = sh
@@ -1330,7 +1332,7 @@ class TestZsh(TestBashZshBase, unittest.
class TestBashZshGlobalBase(TestBashZshBase):
- install_cmd = 'eval "$(activate-global-python-argcomplete --dest=-)"'
+ install_cmd = 'eval "$(activate-global-python-argcomplete-{} --dest=-)"'.format(py_ver)
def test_redirection_completion(self):
with TempDir(prefix="test_dir_py", dir="."):
@@ -1343,15 +1345,15 @@ class TestBashZshGlobalBase(TestBashZshB
def test_python_completion(self):
self.sh.run_command("cd " + TEST_DIR)
- self.assertEqual(self.sh.run_command("python3 ./prog basic f\t"), "foo\r\n")
+ self.assertEqual(self.sh.run_command("python{} ./prog basic f\t".format(py_ver)), "foo\r\n")
def test_python_filename_completion(self):
self.sh.run_command("cd " + TEST_DIR)
- self.assertEqual(self.sh.run_command("python3 ./pro\tbasic f\t"), "foo\r\n")
+ self.assertEqual(self.sh.run_command("python{} ./pro\tbasic f\t".format(py_ver)), "foo\r\n")
def test_python_stuck(self):
self.sh.run_command("cd " + TEST_DIR)
- self.sh.run_command("python3 ./stuck no\t-input")
+ self.sh.run_command("python{} ./stuck no\t-input".format(py_ver))
def test_python_not_executable(self):
"""Test completing a script that cannot be run directly."""
@@ -1363,7 +1365,7 @@ class TestBashZshGlobalBase(TestBashZshB
# Ensure prog is no longer able to be run as "./prog".
self.assertIn("<<126>>", self.sh.run_command('./prog; echo "<<$?>>"'))
# Ensure completion still functions when run via python.
- self.assertEqual(self.sh.run_command("python3 ./prog basic f\t"), "foo\r\n")
+ self.assertEqual(self.sh.run_command("python{} ./prog basic f\t".format(py_ver)), "foo\r\n")
def test_python_module(self):
"""Test completing a module run with python -m."""
@@ -1373,7 +1375,7 @@ class TestBashZshGlobalBase(TestBashZshB
open("package/__init__.py", "w").close()
shutil.copy(prog, "package/prog.py")
self.sh.run_command("cd " + os.getcwd())
- self.assertEqual(self.sh.run_command("python3 -m package.prog basic f\t"), "foo\r\n")
+ self.assertEqual(self.sh.run_command("python{} -m package.prog basic f\t".format(py_ver)), "foo\r\n")
def _test_console_script(self, package=False, wheel=False):
with TempDir(prefix="test_dir_py", dir="."):
--- a/test/test_contrib_shells.py
+++ b/test/test_contrib_shells.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3.10
import os
import os.path
import unittest
@@ -6,8 +6,7 @@ import unittest
import pexpect
import pexpect.replwrap
-from .test import BASE_DIR, TEST_DIR, Shell, TestShellBase
-
+from .test import BASE_DIR, TEST_DIR, Shell, TestShellBase, py_ver
@unittest.skip("tcsh is not supported. Enable this test manually if needed.")
class TestTcsh(TestShellBase, unittest.TestCase):
@@ -28,12 +27,12 @@ class TestTcsh(TestShellBase, unittest.T
sh.run_command("setenv PYTHONPATH {0}".format(BASE_DIR))
# 'dummy' argument unused; checks multi-command registration works
# by passing 'prog' as the second argument.
- output = sh.run_command("eval `register-python-argcomplete --shell tcsh dummy prog`")
+ output = sh.run_command("eval `register-python-argcomplete-{} --shell tcsh dummy prog`".format(py_ver))
self.assertEqual(output, "")
# Register a dummy completion with an external argcomplete script
# to ensure this doesn't overwrite our previous registration.
output = sh.run_command(
- "eval `register-python-argcomplete --shell tcsh dummy --external-argcomplete-script dummy`"
+ "eval `register-python-argcomplete-{} --shell tcsh dummy --external-argcomplete-script dummy`.format(py_ver)"
)
self.assertEqual(output, "")
self.sh = sh
@@ -62,12 +61,12 @@ class TestFish(TestShellBase, unittest.T
sh.run_command("set -x PYTHONPATH {0}".format(BASE_DIR))
# 'dummy' argument unused; checks multi-command registration works
# by passing 'prog' as the second argument.
- output = sh.run_command("register-python-argcomplete --shell fish dummy prog | source")
+ output = sh.run_command("register-python-argcomplete-{} --shell fish dummy prog | source".format(py_ver))
self.assertEqual(output, "")
# Register a dummy completion with an external argcomplete script
# to ensure this doesn't overwrite our previous registration.
output = sh.run_command(
- "register-python-argcomplete --shell fish dummy --external-argcomplete-script dummy | source"
+ "register-python-argcomplete-{} --shell fish dummy --external-argcomplete-script dummy | source".format(py_ver)
)
self.assertEqual(output, "")
self.sh = sh