commit python-argcomplete for openSUSE:Factory
Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-argcomplete for openSUSE:Factory checked in at 2024-10-30 17:33:05 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-argcomplete (Old) and /work/SRC/openSUSE:Factory/.python-argcomplete.new.2020 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "python-argcomplete" Wed Oct 30 17:33:05 2024 rev:38 rq:1219176 version:3.5.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-argcomplete/python-argcomplete.changes 2024-10-08 17:16:28.853205359 +0200 +++ /work/SRC/openSUSE:Factory/.python-argcomplete.new.2020/python-argcomplete.changes 2024-10-30 17:33:12.665178069 +0100 @@ -1,0 +2,11 @@ +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 +- Add _multibuild (to make testing against fully installed package) + +------------------------------------------------------------------- Old: ---- argcomplete-3.4.0.tar.gz argparse-3_12_7.patch New: ---- _multibuild argcomplete-3.5.1.tar.gz BETA DEBUG BEGIN: Old:- Remove upstreamed patches: - argparse-3_12_7.patch - Add _multibuild (to make testing against fully installed package) BETA DEBUG END: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-argcomplete.spec ++++++ --- /var/tmp/diff_new_pack.okt5Zh/_old 2024-10-30 17:33:13.577216271 +0100 +++ /var/tmp/diff_new_pack.okt5Zh/_new 2024-10-30 17:33:13.577216271 +0100 @@ -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 @@ %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 + $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,6 +113,8 @@ %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 ++++++ _multibuild ++++++ <multibuild> <package>test</package> </multibuild> ++++++ argcomplete-3.4.0.tar.gz -> argcomplete-3.5.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-3.4.0/.github/workflows/ci.yml new/argcomplete-3.5.1/.github/workflows/ci.yml --- old/argcomplete-3.4.0/.github/workflows/ci.yml 2023-12-29 02:33:45.000000000 +0100 +++ new/argcomplete-3.5.1/.github/workflows/ci.yml 2024-08-05 01:55:57.000000000 +0200 @@ -8,7 +8,7 @@ strategy: fail-fast: false matrix: - os: [ubuntu-20.04, ubuntu-22.04, macos-11, macos-12] + os: [ubuntu-20.04, ubuntu-22.04, macos-12, macos-14] python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: @@ -29,6 +29,7 @@ - run: make lint - run: make test - uses: codecov/codecov-action@v3 + if: ${{matrix.python-version == '3.12' && matrix.os == 'ubuntu-22.04'}} black: runs-on: ubuntu-22.04 steps: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-3.4.0/Changes.rst new/argcomplete-3.5.1/Changes.rst --- old/argcomplete-3.4.0/Changes.rst 2024-06-16 09:06:51.000000000 +0200 +++ new/argcomplete-3.5.1/Changes.rst 2024-10-07 06:00:12.000000000 +0200 @@ -1,3 +1,15 @@ +Changes for v3.5.1 (2024-10-06) +=============================== + +- Restore compatibility with argparse in Python 3.12.7+ (#508) + +Changes for v3.5.0 (2024-08-06) +=============================== + +- Use project.scripts instead of setuptools scripts (#498) + +- Test infrastructure improvements + Changes for v3.4.0 (2024-06-16) =============================== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-3.4.0/Makefile new/argcomplete-3.5.1/Makefile --- old/argcomplete-3.4.0/Makefile 2023-10-23 23:31:16.000000000 +0200 +++ new/argcomplete-3.5.1/Makefile 2024-08-04 21:20:00.000000000 +0200 @@ -4,9 +4,9 @@ python -m pip install .[test] lint: - for dir in $$(dirname */__init__.py); do ruff $$dir; done - for script in scripts/*[^cmd]; do if grep -q python $$script; then ruff $$script; fi; done - mypy --install-types --non-interactive --check-untyped-defs argcomplete + for dir in $$(dirname */__init__.py); do ruff check $$dir; done + for script in scripts/*[^cmd]; do if grep -q python $$script; then ruff check $$script; fi; done + mypy --install-types --non-interactive argcomplete test: coverage run --source=argcomplete --omit=argcomplete/packages/_shlex.py ./test/test.py -v diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-3.4.0/PKG-INFO new/argcomplete-3.5.1/PKG-INFO --- old/argcomplete-3.4.0/PKG-INFO 2024-06-16 09:07:02.136315300 +0200 +++ new/argcomplete-3.5.1/PKG-INFO 2024-10-07 06:00:27.670457100 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: argcomplete -Version: 3.4.0 +Version: 3.5.1 Summary: Bash tab completion for argparse Home-page: https://github.com/kislyuk/argcomplete Author: Andrey Kislyuk @@ -9,7 +9,7 @@ Project-URL: Documentation, https://kislyuk.github.io/argcomplete Project-URL: Source Code, https://github.com/kislyuk/argcomplete Project-URL: Issue Tracker, https://github.com/kislyuk/argcomplete/issues -Project-URL: Change Log, https://github.com/kislyuk/argcomplete/blob/master/Changes.rst +Project-URL: Change Log, https://github.com/kislyuk/argcomplete/blob/develop/Changes.rst Platform: MacOS X Platform: Posix Classifier: Environment :: Console diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-3.4.0/argcomplete/bash_completion.d/_python-argcomplete new/argcomplete-3.5.1/argcomplete/bash_completion.d/_python-argcomplete --- old/argcomplete-3.4.0/argcomplete/bash_completion.d/_python-argcomplete 2024-06-16 05:20:34.000000000 +0200 +++ new/argcomplete-3.5.1/argcomplete/bash_completion.d/_python-argcomplete 2024-06-18 04:45:43.000000000 +0200 @@ -1,5 +1,6 @@ #compdef -default- +# argcomplete global completion loader for zsh and bash # Copyright 2012-2023, Andrey Kislyuk and argcomplete contributors. # Licensed under the Apache License. See https://github.com/kislyuk/argcomplete for more info. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-3.4.0/argcomplete/completers.py new/argcomplete-3.5.1/argcomplete/completers.py --- old/argcomplete-3.4.0/argcomplete/completers.py 2023-10-23 23:31:16.000000000 +0200 +++ new/argcomplete-3.5.1/argcomplete/completers.py 2024-06-16 09:16:32.000000000 +0200 @@ -22,7 +22,7 @@ def __call__( self, *, prefix: str, action: argparse.Action, parser: argparse.ArgumentParser, parsed_args: argparse.Namespace - ): + ) -> None: raise NotImplementedError("This method should be implemented by a subclass.") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-3.4.0/argcomplete/finders.py new/argcomplete-3.5.1/argcomplete/finders.py --- old/argcomplete-3.4.0/argcomplete/finders.py 2024-01-29 18:14:15.000000000 +0100 +++ new/argcomplete-3.5.1/argcomplete/finders.py 2024-06-17 00:09:25.000000000 +0200 @@ -7,10 +7,10 @@ import os import sys from collections.abc import Mapping -from typing import Callable, Dict, List, Optional, Sequence, Union +from typing import Callable, Dict, List, Optional, Sequence, TextIO, Union from . import io as _io -from .completers import ChoicesCompleter, FilesCompleter, SuppressCompleter +from .completers import BaseCompleter, ChoicesCompleter, FilesCompleter, SuppressCompleter from .io import debug, mute_stderr from .lexers import split_line from .packages._argparse import IntrospectiveArgumentParser, action_is_greedy, action_is_open, action_is_satisfied @@ -66,13 +66,13 @@ argument_parser: argparse.ArgumentParser, always_complete_options: Union[bool, str] = True, exit_method: Callable = os._exit, - output_stream=None, + output_stream: Optional[TextIO] = None, exclude: Optional[Sequence[str]] = None, validator: Optional[Callable] = None, print_suppressed: bool = False, append_space: Optional[bool] = None, - default_completer=FilesCompleter(), - ): + default_completer: BaseCompleter = FilesCompleter(), + ) -> None: """ :param argument_parser: The argument parser to autocomplete on :param always_complete_options: @@ -132,6 +132,8 @@ debug("Unable to open fd 8 for writing, quitting") exit_method(1) + assert output_stream is not None + ifs = os.environ.get("_ARGCOMPLETE_IFS", "\013") if len(ifs) != 1: debug("Invalid value for IFS, quitting [{v}]".format(v=ifs)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-3.4.0/argcomplete/packages/_argparse.py new/argcomplete-3.5.1/argcomplete/packages/_argparse.py --- old/argcomplete-3.4.0/argcomplete/packages/_argparse.py 2024-04-14 23:11:57.000000000 +0200 +++ new/argcomplete-3.5.1/argcomplete/packages/_argparse.py 2024-10-07 05:58:42.000000000 +0200 @@ -162,6 +162,8 @@ def consume_optional(start_index): # get the optional identified at this index option_tuple = option_string_indices[start_index] + if isinstance(option_tuple, list): # Python 3.12.7+ + option_tuple = option_tuple[0] if len(option_tuple) == 3: action, option_string, explicit_arg = option_tuple else: # Python 3.11.9+, 3.12.3+, 3.13+ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-3.4.0/argcomplete/scripts/activate_global_python_argcomplete.py new/argcomplete-3.5.1/argcomplete/scripts/activate_global_python_argcomplete.py --- old/argcomplete-3.4.0/argcomplete/scripts/activate_global_python_argcomplete.py 1970-01-01 01:00:00.000000000 +0100 +++ new/argcomplete-3.5.1/argcomplete/scripts/activate_global_python_argcomplete.py 2024-08-05 01:45:54.000000000 +0200 @@ -0,0 +1,168 @@ +#!/usr/bin/env python3 +# PYTHON_ARGCOMPLETE_OK + +# Copyright 2012-2023, Andrey Kislyuk and argcomplete contributors. +# Licensed under the Apache License. See https://github.com/kislyuk/argcomplete for more info. + +""" +Activate the generic bash-completion script or zsh completion autoload function for the argcomplete module. +""" + +import argparse +import os +import shutil +import site +import subprocess +import sys + +import argcomplete + +# PEP 366 +__package__ = "argcomplete.scripts" + +zsh_shellcode = """ +# Begin added by argcomplete +fpath=( {zsh_fpath} "${{fpath[@]}}" ) +# End added by argcomplete +""" + +bash_shellcode = """ +# Begin added by argcomplete +source "{activator}" +# End added by argcomplete +""" + +parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) +parser.add_argument("-y", "--yes", help="automatically answer yes for all questions", action="store_true") +parser.add_argument("--dest", help='Specify the shell completion modules directory to install into, or "-" for stdout') +parser.add_argument("--user", help="Install into user directory", action="store_true") +argcomplete.autocomplete(parser) +args = None + + +def get_local_dir(): + try: + return subprocess.check_output(["brew", "--prefix"]).decode().strip() + except (FileNotFoundError, subprocess.CalledProcessError): + return "/usr/local" + + +def get_zsh_system_dir(): + return f"{get_local_dir()}/share/zsh/site-functions" + + +def get_bash_system_dir(): + if "BASH_COMPLETION_COMPAT_DIR" in os.environ: + return os.environ["BASH_COMPLETION_COMPAT_DIR"] + elif sys.platform == "darwin": + return f"{get_local_dir()}/etc/bash_completion.d" # created by homebrew + else: + return "/etc/bash_completion.d" # created by bash-completion + + +def get_activator_dir(): + return os.path.join(os.path.abspath(os.path.dirname(argcomplete.__file__)), "bash_completion.d") + + +def get_activator_path(): + return os.path.join(get_activator_dir(), "_python-argcomplete") + + +def install_to_destination(dest): + activator = get_activator_path() + if dest == "-": + with open(activator) as fh: + sys.stdout.write(fh.read()) + return + destdir = os.path.dirname(dest) + if not os.path.exists(destdir): + try: + os.makedirs(destdir, exist_ok=True) + except Exception as e: + parser.error(f"path {destdir} does not exist and could not be created: {e}") + try: + print(f"Installing {activator} to {dest}...", file=sys.stderr) + shutil.copy(activator, dest) + print("Installed.", file=sys.stderr) + except Exception as e: + parser.error( + f"while installing to {dest}: {e}. Please run this command using sudo, or see --help for more options." + ) + + +def get_consent(): + assert args is not None + if args.yes is True: + return True + while True: + res = input("OK to proceed? [y/n] ") + if res.lower() not in {"y", "n", "yes", "no"}: + print('Please answer "yes" or "no".', file=sys.stderr) + elif res.lower() in {"y", "yes"}: + return True + else: + return False + + +def append_to_config_file(path, shellcode): + if os.path.exists(path): + with open(path, 'r') as fh: + if shellcode in fh.read(): + print(f"The code already exists in the file {path}.", file=sys.stderr) + return + print(f"argcomplete needs to append to the file {path}. The following code will be appended:", file=sys.stderr) + for line in shellcode.splitlines(): + print(">", line, file=sys.stderr) + if not get_consent(): + print("Not added.", file=sys.stderr) + return + print(f"Adding shellcode to {path}...", file=sys.stderr) + with open(path, "a") as fh: + fh.write(shellcode) + print("Added.", file=sys.stderr) + + +def link_user_rcfiles(): + # TODO: warn if running as superuser + zsh_rcfile = os.path.join(os.path.expanduser(os.environ.get("ZDOTDIR", "~")), ".zshenv") + append_to_config_file(zsh_rcfile, zsh_shellcode.format(zsh_fpath=get_activator_dir())) + + bash_completion_user_file = os.path.expanduser("~/.bash_completion") + append_to_config_file(bash_completion_user_file, bash_shellcode.format(activator=get_activator_path())) + + +def main(): + global args + args = parser.parse_args() + + destinations = [] + + if args.dest: + if args.dest != "-" and not os.path.exists(args.dest): + parser.error(f"directory {args.dest} was specified via --dest, but it does not exist") + destinations.append(args.dest) + elif site.ENABLE_USER_SITE and site.USER_SITE and site.USER_SITE in argcomplete.__file__: + print( + "Argcomplete was installed in the user site local directory. Defaulting to user installation.", + file=sys.stderr, + ) + link_user_rcfiles() + elif sys.prefix != sys.base_prefix: + print("Argcomplete was installed in a virtual environment. Defaulting to user installation.", file=sys.stderr) + link_user_rcfiles() + elif args.user: + link_user_rcfiles() + else: + print("Defaulting to system-wide installation.", file=sys.stderr) + destinations.append(f"{get_zsh_system_dir()}/_python-argcomplete") + destinations.append(f"{get_bash_system_dir()}/python-argcomplete") + + for destination in destinations: + install_to_destination(destination) + + if args.dest is None: + print("Please restart your shell or source the installed file to activate it.", file=sys.stderr) + + +if __name__ == "__main__": + sys.exit(main()) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-3.4.0/argcomplete/scripts/python_argcomplete_check_easy_install_script.py new/argcomplete-3.5.1/argcomplete/scripts/python_argcomplete_check_easy_install_script.py --- old/argcomplete-3.4.0/argcomplete/scripts/python_argcomplete_check_easy_install_script.py 1970-01-01 01:00:00.000000000 +0100 +++ new/argcomplete-3.5.1/argcomplete/scripts/python_argcomplete_check_easy_install_script.py 2024-08-05 01:45:54.000000000 +0200 @@ -0,0 +1,84 @@ +#!/usr/bin/env python3 + +# Copyright 2012-2023, Andrey Kislyuk and argcomplete contributors. +# Licensed under the Apache License. See https://github.com/kislyuk/argcomplete for more info. + +""" +This script is part of the Python argcomplete package (https://github.com/kislyuk/argcomplete). +It is used to check if an EASY-INSTALL-SCRIPT wrapper redirects to a script that contains the string +"PYTHON_ARGCOMPLETE_OK". If you have enabled global completion in argcomplete, the completion hook will run it every +time you press <TAB> in your shell. + +Usage: + python-argcomplete-check-easy-install-script <input executable file> +""" + +import sys + +# PEP 366 +__package__ = "argcomplete.scripts" + + +def main(): + if len(sys.argv) != 2: + sys.exit(__doc__) + + sys.tracebacklimit = 0 + + with open(sys.argv[1]) as fh: + line1, head = fh.read(1024).split("\n", 1)[:2] + if line1.startswith("#") and ("py" in line1 or "Py" in line1): + import re + + lines = head.split("\n", 12) + for line in lines: + if line.startswith("# EASY-INSTALL-SCRIPT"): + import pkg_resources + + re_match = re.match("# EASY-INSTALL-SCRIPT: '(.+)','(.+)'", line) + assert re_match is not None + dist, script = re_match.groups() + if "PYTHON_ARGCOMPLETE_OK" in pkg_resources.get_distribution(dist).get_metadata( + "scripts/" + script + ): + return 0 + elif line.startswith("# EASY-INSTALL-ENTRY-SCRIPT"): + re_match = re.match("# EASY-INSTALL-ENTRY-SCRIPT: '(.+)','(.+)','(.+)'", line) + assert re_match is not None + dist, group, name = re_match.groups() + import pkgutil + + import pkg_resources + + entry_point_info = pkg_resources.get_distribution(dist).get_entry_info(group, name) + assert entry_point_info is not None + module_name = entry_point_info.module_name + with open(pkgutil.get_loader(module_name).get_filename()) as mod_fh: # type: ignore + if "PYTHON_ARGCOMPLETE_OK" in mod_fh.read(1024): + return 0 + elif line.startswith("# EASY-INSTALL-DEV-SCRIPT"): + for line2 in lines: + if line2.startswith("__file__"): + re_match = re.match("__file__ = '(.+)'", line2) + assert re_match is not None + filename = re_match.group(1) + with open(filename) as mod_fh: + if "PYTHON_ARGCOMPLETE_OK" in mod_fh.read(1024): + return 0 + elif line.startswith("# PBR Generated"): + re_match = re.search("from (.*) import", head) + assert re_match is not None + module = re_match.groups()[0] + import pkgutil + + import pkg_resources + + with open(pkgutil.get_loader(module).get_filename()) as mod_fh: # type: ignore + if "PYTHON_ARGCOMPLETE_OK" in mod_fh.read(1024): + return 0 + + return 1 + + +if __name__ == "__main__": + sys.exit(main()) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-3.4.0/argcomplete/scripts/register_python_argcomplete.py new/argcomplete-3.5.1/argcomplete/scripts/register_python_argcomplete.py --- old/argcomplete-3.4.0/argcomplete/scripts/register_python_argcomplete.py 1970-01-01 01:00:00.000000000 +0100 +++ new/argcomplete-3.5.1/argcomplete/scripts/register_python_argcomplete.py 2024-08-05 01:45:54.000000000 +0200 @@ -0,0 +1,79 @@ +#!/usr/bin/env python3 +# PYTHON_ARGCOMPLETE_OK + +# Copyright 2012-2023, Andrey Kislyuk and argcomplete contributors. +# Licensed under the Apache License. See https://github.com/kislyuk/argcomplete for more info. + +""" +Register a Python executable for use with the argcomplete module. + +To perform the registration, source the output of this script in your bash shell +(quote the output to avoid interpolation). + +Example: + + $ eval "$(register-python-argcomplete my-favorite-script.py)" + +For Tcsh + + $ eval `register-python-argcomplete --shell tcsh my-favorite-script.py` + +For Fish + + $ register-python-argcomplete --shell fish my-favourite-script.py > ~/.config/fish/my-favourite-script.py.fish +""" + +import argparse +import sys + +import argcomplete + +# PEP 366 +__package__ = "argcomplete.scripts" + + +def main(): + parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) + + parser.add_argument( + "--no-defaults", + dest="use_defaults", + action="store_false", + default=True, + help="when no matches are generated, do not fallback to readline's default completion (affects bash only)", + ) + parser.add_argument( + "--complete-arguments", + nargs=argparse.REMAINDER, + help="arguments to call complete with; use of this option discards default options (affects bash only)", + ) + parser.add_argument( + "-s", + "--shell", + choices=("bash", "zsh", "tcsh", "fish", "powershell"), + default="bash", + help="output code for the specified shell", + ) + parser.add_argument( + "-e", "--external-argcomplete-script", help="external argcomplete script for auto completion of the executable" + ) + + parser.add_argument("executable", nargs="+", help="executable to completed (when invoked by exactly this name)") + + argcomplete.autocomplete(parser) + + if len(sys.argv) == 1: + parser.print_help() + sys.exit(1) + + args = parser.parse_args() + + sys.stdout.write( + argcomplete.shellcode( + args.executable, args.use_defaults, args.shell, args.complete_arguments, args.external_argcomplete_script + ) + ) + + +if __name__ == "__main__": + sys.exit(main()) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-3.4.0/argcomplete.egg-info/PKG-INFO new/argcomplete-3.5.1/argcomplete.egg-info/PKG-INFO --- old/argcomplete-3.4.0/argcomplete.egg-info/PKG-INFO 2024-06-16 09:07:02.000000000 +0200 +++ new/argcomplete-3.5.1/argcomplete.egg-info/PKG-INFO 2024-10-07 06:00:27.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: argcomplete -Version: 3.4.0 +Version: 3.5.1 Summary: Bash tab completion for argparse Home-page: https://github.com/kislyuk/argcomplete Author: Andrey Kislyuk @@ -9,7 +9,7 @@ Project-URL: Documentation, https://kislyuk.github.io/argcomplete Project-URL: Source Code, https://github.com/kislyuk/argcomplete Project-URL: Issue Tracker, https://github.com/kislyuk/argcomplete/issues -Project-URL: Change Log, https://github.com/kislyuk/argcomplete/blob/master/Changes.rst +Project-URL: Change Log, https://github.com/kislyuk/argcomplete/blob/develop/Changes.rst Platform: MacOS X Platform: Posix Classifier: Environment :: Console diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-3.4.0/argcomplete.egg-info/SOURCES.txt new/argcomplete-3.5.1/argcomplete.egg-info/SOURCES.txt --- old/argcomplete-3.4.0/argcomplete.egg-info/SOURCES.txt 2024-06-16 09:07:02.000000000 +0200 +++ new/argcomplete-3.5.1/argcomplete.egg-info/SOURCES.txt 2024-10-07 06:00:27.000000000 +0200 @@ -26,6 +26,7 @@ argcomplete.egg-info/PKG-INFO argcomplete.egg-info/SOURCES.txt argcomplete.egg-info/dependency_links.txt +argcomplete.egg-info/entry_points.txt argcomplete.egg-info/not-zip-safe argcomplete.egg-info/requires.txt argcomplete.egg-info/top_level.txt @@ -33,6 +34,10 @@ argcomplete/packages/__init__.py argcomplete/packages/_argparse.py argcomplete/packages/_shlex.py +argcomplete/scripts/__init__.py +argcomplete/scripts/activate_global_python_argcomplete.py +argcomplete/scripts/python_argcomplete_check_easy_install_script.py +argcomplete/scripts/register_python_argcomplete.py contrib/README.rst docs/changelog.rst docs/conf.py @@ -40,9 +45,6 @@ docs/index.rst docs/toc.html docs/examples/describe_github_user.py -scripts/activate-global-python-argcomplete -scripts/python-argcomplete-check-easy-install-script -scripts/register-python-argcomplete test/__init__.py test/inputrc test/prog diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-3.4.0/argcomplete.egg-info/entry_points.txt new/argcomplete-3.5.1/argcomplete.egg-info/entry_points.txt --- old/argcomplete-3.4.0/argcomplete.egg-info/entry_points.txt 1970-01-01 01:00:00.000000000 +0100 +++ new/argcomplete-3.5.1/argcomplete.egg-info/entry_points.txt 2024-10-07 06:00:27.000000000 +0200 @@ -0,0 +1,4 @@ +[console_scripts] +activate-global-python-argcomplete = argcomplete.scripts.activate_global_python_argcomplete:main +python-argcomplete-check-easy-install-script = argcomplete.scripts.python_argcomplete_check_easy_install_script:main +register-python-argcomplete = argcomplete.scripts.register_python_argcomplete:main diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-3.4.0/pyproject.toml new/argcomplete-3.5.1/pyproject.toml --- old/argcomplete-3.4.0/pyproject.toml 2024-04-14 23:01:41.000000000 +0200 +++ new/argcomplete-3.5.1/pyproject.toml 2024-09-29 07:02:08.000000000 +0200 @@ -34,6 +34,11 @@ "Topic :: Terminals", ] +[project.scripts] +activate-global-python-argcomplete = "argcomplete.scripts.activate_global_python_argcomplete:main" +python-argcomplete-check-easy-install-script = "argcomplete.scripts.python_argcomplete_check_easy_install_script:main" +register-python-argcomplete = "argcomplete.scripts.register_python_argcomplete:main" + [project.optional-dependencies] test = ["coverage", "pexpect", "wheel", "ruff", "mypy"] @@ -41,7 +46,7 @@ "Documentation"= "https://kislyuk.github.io/argcomplete" "Source Code"= "https://github.com/kislyuk/argcomplete" "Issue Tracker"= "https://github.com/kislyuk/argcomplete/issues" -"Change Log"= "https://github.com/kislyuk/argcomplete/blob/master/Changes.rst" +"Change Log"= "https://github.com/kislyuk/argcomplete/blob/develop/Changes.rst" [tool.setuptools_scm] @@ -66,6 +71,8 @@ files = [ "argcomplete" ] +check_untyped_defs = true +disallow_incomplete_defs = true [[tool.mypy.overrides]] module = "importlib.*" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-3.4.0/scripts/activate-global-python-argcomplete new/argcomplete-3.5.1/scripts/activate-global-python-argcomplete --- old/argcomplete-3.4.0/scripts/activate-global-python-argcomplete 2023-12-03 02:13:18.000000000 +0100 +++ new/argcomplete-3.5.1/scripts/activate-global-python-argcomplete 1970-01-01 01:00:00.000000000 +0100 @@ -1,154 +0,0 @@ -#!/usr/bin/env python -# PYTHON_ARGCOMPLETE_OK - -# Copyright 2012-2023, Andrey Kislyuk and argcomplete contributors. -# Licensed under the Apache License. See https://github.com/kislyuk/argcomplete for more info. - -""" -Activate the generic bash-completion script or zsh completion autoload function for the argcomplete module. -""" - -import argparse -import os -import shutil -import site -import subprocess -import sys - -import argcomplete - -zsh_shellcode = """ -# Begin added by argcomplete -fpath=( {zsh_fpath} "${{fpath[@]}}" ) -# End added by argcomplete -""" - -bash_shellcode = """ -# Begin added by argcomplete -source "{activator}" -# End added by argcomplete -""" - - -def get_local_dir(): - try: - return subprocess.check_output(["brew", "--prefix"]).decode().strip() - except (FileNotFoundError, subprocess.CalledProcessError): - return "/usr/local" - - -def get_zsh_system_dir(): - return f"{get_local_dir()}/share/zsh/site-functions" - - -def get_bash_system_dir(): - if "BASH_COMPLETION_COMPAT_DIR" in os.environ: - return os.environ["BASH_COMPLETION_COMPAT_DIR"] - elif sys.platform == "darwin": - return f"{get_local_dir()}/etc/bash_completion.d" # created by homebrew - else: - return "/etc/bash_completion.d" # created by bash-completion - - -def get_activator_dir(): - return os.path.join(os.path.abspath(os.path.dirname(argcomplete.__file__)), "bash_completion.d") - - -def get_activator_path(): - return os.path.join(get_activator_dir(), "_python-argcomplete") - - -def install_to_destination(dest): - activator = get_activator_path() - if dest == "-": - with open(activator) as fh: - sys.stdout.write(fh.read()) - return - destdir = os.path.dirname(dest) - if not os.path.exists(destdir): - try: - os.makedirs(destdir, exist_ok=True) - except Exception as e: - parser.error(f"path {destdir} does not exist and could not be created: {e}") - try: - print(f"Installing {activator} to {dest}...", file=sys.stderr) - shutil.copy(activator, dest) - print("Installed.", file=sys.stderr) - except Exception as e: - parser.error( - f"while installing to {dest}: {e}. Please run this command using sudo, or see --help for more options." - ) - - -def get_consent(): - if args.yes is True: - return True - while True: - res = input("OK to proceed? [y/n] ") - if res.lower() not in {"y", "n", "yes", "no"}: - print('Please answer "yes" or "no".', file=sys.stderr) - elif res.lower() in {"y", "yes"}: - return True - else: - return False - - -def append_to_config_file(path, shellcode): - if os.path.exists(path): - with open(path, 'r') as fh: - if shellcode in fh.read(): - print(f"The code already exists in the file {path}.", file=sys.stderr) - return - print(f"argcomplete needs to append to the file {path}. The following code will be appended:", file=sys.stderr) - for line in shellcode.splitlines(): - print(">", line, file=sys.stderr) - if not get_consent(): - print("Not added.", file=sys.stderr) - return - print(f"Adding shellcode to {path}...", file=sys.stderr) - with open(path, "a") as fh: - fh.write(shellcode) - print("Added.", file=sys.stderr) - - -def link_user_rcfiles(): - # TODO: warn if running as superuser - zsh_rcfile = os.path.join(os.path.expanduser(os.environ.get("ZDOTDIR", "~")), ".zshenv") - append_to_config_file(zsh_rcfile, zsh_shellcode.format(zsh_fpath=get_activator_dir())) - - bash_completion_user_file = os.path.expanduser("~/.bash_completion") - append_to_config_file(bash_completion_user_file, bash_shellcode.format(activator=get_activator_path())) - - -parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) -parser.add_argument("-y", "--yes", help="automatically answer yes for all questions", action="store_true") -parser.add_argument("--dest", help='Specify the shell completion modules directory to install into, or "-" for stdout') -parser.add_argument("--user", help="Install into user directory", action="store_true") -argcomplete.autocomplete(parser) -args = parser.parse_args() -destinations = [] - -if args.dest: - if args.dest != "-" and not os.path.exists(args.dest): - parser.error(f"directory {args.dest} was specified via --dest, but it does not exist") - destinations.append(args.dest) -elif site.ENABLE_USER_SITE and site.USER_SITE in argcomplete.__file__: - print( - "Argcomplete was installed in the user site local directory. Defaulting to user installation.", file=sys.stderr - ) - link_user_rcfiles() -elif sys.prefix != sys.base_prefix: - print("Argcomplete was installed in a virtual environment. Defaulting to user installation.", file=sys.stderr) - link_user_rcfiles() -elif args.user: - link_user_rcfiles() -else: - print("Defaulting to system-wide installation.", file=sys.stderr) - destinations.append(f"{get_zsh_system_dir()}/_python-argcomplete") - destinations.append(f"{get_bash_system_dir()}/python-argcomplete") - -for destination in destinations: - install_to_destination(destination) - -if args.dest is None: - print("Please restart your shell or source the installed file to activate it.", file=sys.stderr) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-3.4.0/scripts/python-argcomplete-check-easy-install-script new/argcomplete-3.5.1/scripts/python-argcomplete-check-easy-install-script --- old/argcomplete-3.4.0/scripts/python-argcomplete-check-easy-install-script 2023-10-23 23:31:17.000000000 +0200 +++ new/argcomplete-3.5.1/scripts/python-argcomplete-check-easy-install-script 1970-01-01 01:00:00.000000000 +0100 @@ -1,63 +0,0 @@ -#!/usr/bin/env python - -# Copyright 2012-2023, Andrey Kislyuk and argcomplete contributors. -# Licensed under the Apache License. See https://github.com/kislyuk/argcomplete for more info. - -""" -This script is part of the Python argcomplete package (https://github.com/kislyuk/argcomplete). -It is used to check if an EASY-INSTALL-SCRIPT wrapper redirects to a script that contains the string -"PYTHON_ARGCOMPLETE_OK". If you have enabled global completion in argcomplete, the completion hook will run it every -time you press <TAB> in your shell. - -Usage: - python-argcomplete-check-easy-install-script <input executable file> -""" - -import sys - -if len(sys.argv) != 2: - sys.exit(__doc__) - -sys.tracebacklimit = 0 - -with open(sys.argv[1]) as fh: - line1, head = fh.read(1024).split("\n", 1)[:2] - if line1.startswith("#") and ("py" in line1 or "Py" in line1): - import re - - lines = head.split("\n", 12) - for line in lines: - if line.startswith("# EASY-INSTALL-SCRIPT"): - import pkg_resources - - dist, script = re.match("# EASY-INSTALL-SCRIPT: '(.+)','(.+)'", line).groups() - if "PYTHON_ARGCOMPLETE_OK" in pkg_resources.get_distribution(dist).get_metadata("scripts/" + script): - exit(0) - elif line.startswith("# EASY-INSTALL-ENTRY-SCRIPT"): - dist, group, name = re.match("# EASY-INSTALL-ENTRY-SCRIPT: '(.+)','(.+)','(.+)'", line).groups() - import pkgutil - - import pkg_resources - - module_name = pkg_resources.get_distribution(dist).get_entry_info(group, name).module_name - with open(pkgutil.get_loader(module_name).get_filename()) as mod_fh: - if "PYTHON_ARGCOMPLETE_OK" in mod_fh.read(1024): - exit(0) - elif line.startswith("# EASY-INSTALL-DEV-SCRIPT"): - for line2 in lines: - if line2.startswith("__file__"): - filename = re.match("__file__ = '(.+)'", line2).group(1) - with open(filename) as mod_fh: - if "PYTHON_ARGCOMPLETE_OK" in mod_fh.read(1024): - exit(0) - elif line.startswith("# PBR Generated"): - module = re.search("from (.*) import", head).groups()[0] - import pkgutil - - import pkg_resources - - with open(pkgutil.get_loader(module).get_filename()) as mod_fh: - if "PYTHON_ARGCOMPLETE_OK" in mod_fh.read(1024): - exit(0) - -exit(1) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-3.4.0/scripts/register-python-argcomplete new/argcomplete-3.5.1/scripts/register-python-argcomplete --- old/argcomplete-3.4.0/scripts/register-python-argcomplete 2023-10-23 23:31:17.000000000 +0200 +++ new/argcomplete-3.5.1/scripts/register-python-argcomplete 1970-01-01 01:00:00.000000000 +0100 @@ -1,71 +0,0 @@ -#!/usr/bin/env python3 -# PYTHON_ARGCOMPLETE_OK - -# Copyright 2012-2023, Andrey Kislyuk and argcomplete contributors. -# Licensed under the Apache License. See https://github.com/kislyuk/argcomplete for more info. - -""" -Register a Python executable for use with the argcomplete module. - -To perform the registration, source the output of this script in your bash shell -(quote the output to avoid interpolation). - -Example: - - $ eval "$(register-python-argcomplete my-favorite-script.py)" - -For Tcsh - - $ eval `register-python-argcomplete --shell tcsh my-favorite-script.py` - -For Fish - - $ register-python-argcomplete --shell fish my-favourite-script.py > ~/.config/fish/my-favourite-script.py.fish -""" - -import argparse -import sys - -import argcomplete - -parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) - -parser.add_argument( - "--no-defaults", - dest="use_defaults", - action="store_false", - default=True, - help="when no matches are generated, do not fallback to readline's default completion (affects bash only)", -) -parser.add_argument( - "--complete-arguments", - nargs=argparse.REMAINDER, - help="arguments to call complete with; use of this option discards default options (affects bash only)", -) -parser.add_argument( - "-s", - "--shell", - choices=("bash", "zsh", "tcsh", "fish", "powershell"), - default="bash", - help="output code for the specified shell", -) -parser.add_argument( - "-e", "--external-argcomplete-script", help="external argcomplete script for auto completion of the executable" -) - -parser.add_argument("executable", nargs="+", help="executable to completed (when invoked by exactly this name)") - -argcomplete.autocomplete(parser) - -if len(sys.argv) == 1: - parser.print_help() - sys.exit(1) - -args = parser.parse_args() - - -sys.stdout.write( - argcomplete.shellcode( - args.executable, args.use_defaults, args.shell, args.complete_arguments, args.external_argcomplete_script - ) -) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-3.4.0/setup.py new/argcomplete-3.5.1/setup.py --- old/argcomplete-3.4.0/setup.py 2024-04-14 07:42:07.000000000 +0200 +++ new/argcomplete-3.5.1/setup.py 2024-08-05 00:42:13.000000000 +0200 @@ -7,7 +7,6 @@ setup( url="https://github.com/kislyuk/argcomplete", packages=find_packages(exclude=["test", "test.*"]), - scripts=glob.glob("scripts/*"), package_data={"argcomplete": ["bash_completion.d/_python-argcomplete", "py.typed"]}, zip_safe=False, include_package_data=True, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-3.4.0/test/test.py new/argcomplete-3.5.1/test/test.py --- old/argcomplete-3.4.0/test/test.py 2024-06-16 05:20:34.000000000 +0200 +++ new/argcomplete-3.5.1/test/test.py 2024-08-04 21:19:49.000000000 +0200 @@ -65,6 +65,7 @@ def _repl_sh(command, args, non_printable_insert): os.environ["PS1"] = "$" + os.environ["TERM"] = "" child = pexpect.spawn(command, args, echo=False, encoding="utf-8") ps1 = PEXPECT_PROMPT[:5] + non_printable_insert + PEXPECT_PROMPT[5:] ps2 = PEXPECT_CONTINUATION_PROMPT[:5] + non_printable_insert + PEXPECT_CONTINUATION_PROMPT[5:] @@ -79,7 +80,7 @@ def zsh_repl(command="zsh"): - sh = _repl_sh(command, ["--no-rcs", "-V"], non_printable_insert="%(!..)") + sh = _repl_sh(command, ["--no-rcs", "--no-globalrcs", "-V"], non_printable_insert="%(!..)") # Require two tabs to print all options (some tests rely on this). sh.run_command("setopt BASH_AUTO_LIST") return sh
participants (1)
-
Source-Sync