Handle alternate executable names for cases this isn't the main Python
This is based on work in f1b86318fc
and https://src.fedoraproject.org/rpms/python-pip/pull-request/71 (not merged)
With one notable difference: The Bash completion function has no dot in it now.
I believe that having a dot in it breaks it: https://issues.redhat.com/browse/RHEL-99083
[skip changelog]
This commit is contained in:
parent
435a2e9aa1
commit
5802dc6818
1 changed files with 36 additions and 23 deletions
|
|
@ -249,13 +249,28 @@ export PYTHONPATH=./src/
|
|||
%pyproject_install
|
||||
%pyproject_save_files -l pip
|
||||
|
||||
# We'll install pip as pip3.X
|
||||
# Later we'll provide symbolic links, manpage links and bashcompletion fixes for alternative names
|
||||
%if "%{python3_pkgversion}" == "3"
|
||||
%global alternate_names pip-%{python3_version} pip-3 pip3 pip
|
||||
%else
|
||||
%global alternate_names pip-%{python3_version}
|
||||
%endif
|
||||
|
||||
# Provide symlinks to executables
|
||||
mv %{buildroot}%{_bindir}/pip %{buildroot}%{_bindir}/pip%{python3_version}
|
||||
rm %{buildroot}%{_bindir}/pip3
|
||||
for pip in %{alternate_names}; do
|
||||
ln -s ./pip%{python3_version} %{buildroot}%{_bindir}/$pip
|
||||
done
|
||||
|
||||
%if %{with man}
|
||||
pushd docs/build/man
|
||||
install -d %{buildroot}%{_mandir}/man1
|
||||
for MAN in *1; do
|
||||
install -pm0644 $MAN %{buildroot}%{_mandir}/man1/$MAN
|
||||
for pip in "pip3" "pip-3" "pip%{python3_version}" "pip-%{python3_version}"; do
|
||||
echo ".so $MAN" > %{buildroot}%{_mandir}/man1/${MAN/pip/$pip}
|
||||
install -pm0644 $MAN %{buildroot}%{_mandir}/man1/${MAN/pip/pip%{python3_version}}
|
||||
for pip in %{alternate_names}; do
|
||||
echo ".so ${MAN/pip/pip%{python3_version}}" > %{buildroot}%{_mandir}/man1/${MAN/pip/$pip}
|
||||
done
|
||||
done
|
||||
popd
|
||||
|
|
@ -263,19 +278,13 @@ popd
|
|||
|
||||
mkdir -p %{buildroot}%{bash_completions_dir}
|
||||
PYTHONPATH=%{buildroot}%{python3_sitelib} \
|
||||
%{buildroot}%{_bindir}/pip completion --bash \
|
||||
> %{buildroot}%{bash_completions_dir}/pip3
|
||||
|
||||
# Make bash completion apply to all the 5 symlinks we install
|
||||
sed -i -e "s/^\\(complete.*\\) pip\$/\\1 pip pip{,-}{3,%{python3_version}}/" \
|
||||
-e s/_pip_completion/_pip3_completion/ \
|
||||
%{buildroot}%{bash_completions_dir}/pip3
|
||||
|
||||
|
||||
# Provide symlinks to executables to comply with Fedora guidelines for Python
|
||||
ln -s ./pip%{python3_version} %{buildroot}%{_bindir}/pip-%{python3_version}
|
||||
ln -s ./pip-%{python3_version} %{buildroot}%{_bindir}/pip-3
|
||||
%{buildroot}%{_bindir}/pip%{python3_version} completion --bash \
|
||||
> %{buildroot}%{bash_completions_dir}/pip%{python3_version}
|
||||
|
||||
# Make bash completion apply to all alternate names symlinks we install
|
||||
sed -i -e "s/^\\(complete.*\\) pip%{python3_version}\$/\\1 pip%{python3_version} %{alternate_names}/" \
|
||||
-e s/_pip_completion/_pip%{python3_version_nodots}_completion/ \
|
||||
%{buildroot}%{bash_completions_dir}/pip%{python3_version}
|
||||
|
||||
mkdir -p %{buildroot}%{python_wheel_dir}
|
||||
install -p %{_pyproject_wheeldir}/%{python_wheel_name} -t %{buildroot}%{python_wheel_dir}
|
||||
|
|
@ -290,9 +299,9 @@ grep "exe$" %{pyproject_files} && exit 1 || true
|
|||
grep "pem$" %{pyproject_files} && exit 1 || true
|
||||
|
||||
# Verify we can at least run basic commands without crashing
|
||||
%{py3_test_envvars} %{buildroot}%{_bindir}/pip --help
|
||||
%{py3_test_envvars} %{buildroot}%{_bindir}/pip list
|
||||
%{py3_test_envvars} %{buildroot}%{_bindir}/pip show pip
|
||||
%{py3_test_envvars} %{buildroot}%{_bindir}/pip%{python3_version} --help
|
||||
%{py3_test_envvars} %{buildroot}%{_bindir}/pip%{python3_version} list
|
||||
%{py3_test_envvars} %{buildroot}%{_bindir}/pip%{python3_version} show pip
|
||||
|
||||
%if %{with tests}
|
||||
# Upstream tests
|
||||
|
|
@ -318,18 +327,22 @@ pytest_k="$pytest_k and not test_check_unsupported"
|
|||
%files -n python%{python3_pkgversion}-%{srcname} -f %{pyproject_files}
|
||||
%doc README.rst
|
||||
%if %{with man}
|
||||
%{_mandir}/man1/pip.*
|
||||
%{_mandir}/man1/pip-*.*
|
||||
%{_mandir}/man1/pip3.*
|
||||
%{_mandir}/man1/pip3-*.*
|
||||
%if "%{python3_pkgversion}" == "3"
|
||||
%{_mandir}/man1/pip{,3,-3}.1.*
|
||||
%{_mandir}/man1/pip{,3,-3}-[^3]*.1.*
|
||||
%endif
|
||||
%{_mandir}/man1/pip{,-}%{python3_version}.1.*
|
||||
%{_mandir}/man1/pip{,-}%{python3_version}-*.1.*
|
||||
%endif
|
||||
%if "%{python3_pkgversion}" == "3"
|
||||
%{_bindir}/pip
|
||||
%{_bindir}/pip3
|
||||
%{_bindir}/pip-3
|
||||
%endif
|
||||
%{_bindir}/pip%{python3_version}
|
||||
%{_bindir}/pip-%{python3_version}
|
||||
%dir %{bash_completions_dir}
|
||||
%{bash_completions_dir}/pip3
|
||||
%{bash_completions_dir}/pip%{python3_version}
|
||||
|
||||
|
||||
%files -n %{python_wheel_pkg_prefix}-%{srcname}-wheel
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue