No more with python3

There is no point of building this without python3 and this makes
the spec a bit more readable.

Also:

- only have one %python_wheelname (can be split in future if needed)
- use pythonX -m pytest instead of py.test-X.Y
This commit is contained in:
Miro Hrončok 2018-08-15 14:45:08 +02:00
parent 6186a480fa
commit 3e1ef986b4

View File

@ -2,24 +2,12 @@
%bcond_with tests
%bcond_without python2
%bcond_without python3
%if %{without python3}
%bcond_with doc
%else
%bcond_without doc
%endif
%global srcname pip
%global python_wheelname %{srcname}-%{version}-py2.py3-none-any.whl
%global python_wheeldir %{_datadir}/python-wheels
%if %{without bootstrap}
%if %{with python2}
%global python2_wheelname %python_wheelname
%endif
%if %{with python3}
%global python3_wheelname %python_wheelname
%endif
%endif
%if %{with doc}
%global pypa_theme_commit_hash d2e63fbfc62af3b7050f619b2f5bb8658985b931
%endif
@ -189,7 +177,6 @@ Packages" or "Pip Installs Python".
%endif # with python2
%if %{with python3}
%package -n python%{python3_pkgversion}-%{srcname}
Summary: A tool for installing and managing Python3 packages
Group: Development/Libraries
@ -234,8 +221,6 @@ A documentation for a tool for installing and managing Python packages
%endif
%endif # with python3
%if %{without bootstrap}
%package wheel
Summary: The pip wheel
@ -249,11 +234,6 @@ A Python wheel of pip to use with venv.
%endif
%prep
%if %{with doc} && %{without python3}
echo "This combination (with doc, without python3) is unsupported"
exit 1
%endif
%setup -q -n %{srcname}-%{version}
%if %{with tests}
tar -xf %{SOURCE1}
@ -281,13 +261,11 @@ popd
%endif
%endif # with python2
%if %{with python3}
%if %{without bootstrap}
%py3_build_wheel
%else
%py3_build
%endif
%endif # with python3
%if %{with doc}
pushd docs
@ -300,9 +278,8 @@ popd
%install
%if %{with python3}
%if %{without bootstrap}
%py3_install_wheel %{python3_wheelname}
%py3_install_wheel %{python_wheelname}
%else
%py3_install
%endif
@ -310,7 +287,6 @@ popd
# TODO: we have to remove this by hand now, but it'd be nice if we wouldn't have to
# (pip install wheel doesn't overwrite)
rm %{buildroot}%{_bindir}/pip
%endif # with python3
%if %{with doc}
pushd docs/build/man
@ -320,16 +296,14 @@ for MAN in *1; do
install -pm0644 $MAN %{buildroot}%{_mandir}/man1/$MAN
install -pm0644 $MAN %{buildroot}%{_mandir}/man1/${MAN/pip/pip2}
%endif
%if %{with python3}
install -pm0644 $MAN %{buildroot}%{_mandir}/man1/${MAN/pip/pip3}
%endif
done
popd
%endif # with doc
%if %{with python2}
%if %{without bootstrap}
%py2_install_wheel %{python2_wheelname}
%py2_install_wheel %{python_wheelname}
%else
%py2_install
%endif
@ -350,11 +324,9 @@ PYTHONPATH=%{buildroot}%{python2_sitelib} \
%{buildroot}%{_bindir}/pip completion --bash \
> %{buildroot}%{bashcompdir}/pip
%endif
%if %{with python3}
PYTHONPATH=%{buildroot}%{python3_sitelib} \
%{buildroot}%{_bindir}/pip3 completion --bash \
> %{buildroot}%{bashcompdir}/pip3
%endif
pips2=pip
pips3=pip3
for pip in %{buildroot}%{_bindir}/pip*; do
@ -368,21 +340,18 @@ for pip in %{buildroot}%{_bindir}/pip*; do
%endif
;;
%endif
%if %{with python3}
pip3?*)
pips3="$pips3 $pip"
%if 0%{?bashcomp2}
ln -s pip3 %{buildroot}%{bashcompdir}/$pip
%endif
;;
%endif
esac
done
%if %{with python3}
sed -i -e "s/^\\(complete.*\\) pip\$/\\1 $pips3/" \
-e s/_pip_completion/_pip3_completion/ \
%{buildroot}%{bashcompdir}/pip3
%endif
%if %{with python2}
sed -i -e "s/^\\(complete.*\\) pip\$/\\1 $pips2/" \
%{buildroot}%{bashcompdir}/pip
@ -393,10 +362,9 @@ sed -i -e "s/^\\(complete.*\\) pip\$/\\1 $pips2/" \
ln -s ./pip%{python2_version} %{buildroot}%{_bindir}/pip-%{python2_version}
ln -s ./pip-%{python2_version} %{buildroot}%{_bindir}/pip-2
%endif
%if %{with python3}
ln -s ./pip%{python3_version} %{buildroot}%{_bindir}/pip-%{python3_version}
ln -s ./pip-%{python3_version} %{buildroot}%{_bindir}/pip-3
%endif
# Make sure the INSTALLER is not pip, otherwise Patch2 won't work
@ -405,18 +373,13 @@ ln -s ./pip-%{python3_version} %{buildroot}%{_bindir}/pip-3
%if %{with python2}
echo rpm > %{buildroot}%{python2_sitelib}/pip-%{version}.dist-info/INSTALLER
%endif
%if %{with python3}
echo rpm > %{buildroot}%{python3_sitelib}/pip-%{version}.dist-info/INSTALLER
%endif
%endif
%if %{without bootstrap}
mkdir -p %{buildroot}%{python_wheeldir}
%if %{with python3}
install -p dist/%{python3_wheelname} -t %{buildroot}%{python_wheeldir}
%else
install -p dist/%{python2_wheelname} -t %{buildroot}%{python_wheeldir}
%endif
install -p dist/%{python_wheelname} -t %{buildroot}%{python_wheeldir}
%endif
@ -424,11 +387,9 @@ install -p dist/%{python2_wheelname} -t %{buildroot}%{python_wheeldir}
%check
export PYTHONPATH=src
%if %{with python2}
py.test-%{python2_version} -m 'not network'
%endif
%if %{with python3}
py.test-%{python3_version} -m 'not network'
%{__python2} -m pytest -m 'not network'
%endif
%{__python3} -m pytest -m 'not network'
%endif
@ -456,7 +417,6 @@ py.test-%{python3_version} -m 'not network'
%endif
%endif # with python2
%if %{with python3}
%files -n python%{python3_pkgversion}-%{srcname}
%license LICENSE.txt
%doc README.rst
@ -481,18 +441,13 @@ py.test-%{python3_version} -m 'not network'
%doc README.rst
%doc docs/build/html
%endif # with doc
%endif # with python3
%if %{without bootstrap}
%files wheel
%license LICENSE.txt
# we own the dir for simplicity
%dir %{python_wheeldir}/
%if %{with python3}
%{python_wheeldir}/%{python3_wheelname}
%else
%{python_wheeldir}/%{python2_wheelname}
%endif
%{python_wheeldir}/%{python_wheelname}
%endif
%changelog