python-argcomplete/python-argcomplete.spec
2023-11-09 13:27:22 +01:00

107 lines
3.2 KiB
RPMSpec

# Disable check to avoid pulling unwanted package (fish) into RHEL 9
%if 0%{?rhel} >= 9 && !0%{?epel}
%bcond_with check
%else
%bcond_without check
%endif
Name: python-argcomplete
Summary: Bash tab completion for argparse
Version: 2.0.0
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
%endif
BuildArch: noarch
%global _description %{expand:
Argcomplete provides easy, extensible command line tab completion of
arguments for your Python script.
It makes two assumptions:
* You are using bash as your shell
* You are using argparse to manage your command line arguments/options
Argcomplete is particularly useful if your program has lots of
options or subparsers, and if your program can dynamically suggest
completions for your argument/option values (for example, if the user
is browsing resources over the network).}
%description %_description
%package -n python3-argcomplete
Summary: %{summary}
%description -n python3-argcomplete %_description
%prep
%autosetup -p1 -n argcomplete-%{version}
# Remove useless BRs
sed -i -r -e '/tests_require = /s/"(coverage|flake8|wheel)"[, ]*//g' setup.py
# https://github.com/kislyuk/argcomplete/issues/255
# https://github.com/kislyuk/argcomplete/issues/256
sed -i -e "1s|#!.*python.*|#!%{__python3}|" test/prog scripts/*
sed -i -e "s|python |python3 |" test/test.py
%generate_buildrequires
%pyproject_buildrequires %{?with_check:-x test}
%build
%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files argcomplete
# 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}
%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
%endif
%files -n python3-argcomplete -f %{pyproject_files}
%license LICENSE.rst
%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}
%changelog
%autochangelog