Switch macros to bcond's
To facilitate building the Python 2 and Python 3 modules.
This commit is contained in:
parent
e27aaa21f1
commit
a096270f29
@ -1,11 +1,12 @@
|
||||
%global with_python3 1
|
||||
%global build_wheel 1
|
||||
%global with_tests 0
|
||||
%bcond_with bootstrap
|
||||
%bcond_with tests
|
||||
|
||||
%bcond_without python3
|
||||
|
||||
%global srcname pip
|
||||
%if 0%{?build_wheel}
|
||||
%if %{without bootstrap}
|
||||
%global python2_wheelname %{srcname}-%{version}-py2.py3-none-any.whl
|
||||
%if 0%{?with_python3}
|
||||
%if %{with python3}
|
||||
%global python3_wheelname %python2_wheelname
|
||||
%endif
|
||||
%endif
|
||||
@ -30,7 +31,7 @@ BuildArch: noarch
|
||||
# to get tests:
|
||||
# git clone https://github.com/pypa/pip && cd pip
|
||||
# git checkout 9.0.1 && tar -czvf ../pip-9.0.1-tests.tar.gz tests/
|
||||
%if 0%{?with_tests}
|
||||
%if %{with tests}
|
||||
Source1: pip-9.0.1-tests.tar.gz
|
||||
%endif
|
||||
|
||||
@ -55,7 +56,7 @@ Summary: A tool for installing and managing Python 2 packages
|
||||
Group: Development/Libraries
|
||||
BuildRequires: python2-devel
|
||||
BuildRequires: python-setuptools
|
||||
%if 0%{?with_tests}
|
||||
%if %{with tests}
|
||||
BuildRequires: git
|
||||
BuildRequires: bzr
|
||||
BuildRequires: python-mock
|
||||
@ -66,7 +67,7 @@ BuildRequires: python-pytest-capturelog
|
||||
BuildRequires: python-scripttest
|
||||
BuildRequires: python-virtualenv
|
||||
%endif
|
||||
%if 0%{?build_wheel}
|
||||
%if %{without bootstrap}
|
||||
BuildRequires: python2-pip
|
||||
BuildRequires: python-wheel
|
||||
%endif
|
||||
@ -80,7 +81,7 @@ written in Python. Many packages can be found in the Python Package Index
|
||||
Packages" or "Pip Installs Python".
|
||||
|
||||
|
||||
%if 0%{?with_python3}
|
||||
%if %{with python3}
|
||||
%package -n python%{python3_pkgversion}-%{srcname}
|
||||
Summary: A tool for installing and managing Python3 packages
|
||||
Group: Development/Libraries
|
||||
@ -88,7 +89,7 @@ Group: Development/Libraries
|
||||
BuildRequires: python%{python3_pkgversion}-devel
|
||||
BuildRequires: python%{python3_pkgversion}-setuptools
|
||||
BuildRequires: bash-completion
|
||||
%if 0%{?with_tests}
|
||||
%if %{with tests}
|
||||
BuildRequires: python%{python3_pkgversion}-mock
|
||||
BuildRequires: python%{python3_pkgversion}-pytest
|
||||
BuildRequires: python%{python3_pkgversion}-pretend
|
||||
@ -97,7 +98,7 @@ BuildRequires: python%{python3_pkgversion}-pytest-capturelog
|
||||
BuildRequires: python%{python3_pkgversion}-scripttest
|
||||
BuildRequires: python%{python3_pkgversion}-virtualenv
|
||||
%endif
|
||||
%if 0%{?build_wheel}
|
||||
%if %{without bootstrap}
|
||||
BuildRequires: python%{python3_pkgversion}-pip
|
||||
BuildRequires: python%{python3_pkgversion}-wheel
|
||||
%endif
|
||||
@ -110,12 +111,12 @@ written in Python. Many packages can be found in the Python Package Index
|
||||
(PyPI). pip is a recursive acronym that can stand for either "Pip Installs
|
||||
Packages" or "Pip Installs Python".
|
||||
|
||||
%endif # with_python3
|
||||
%endif # with python3
|
||||
|
||||
|
||||
%prep
|
||||
%setup -q -n %{srcname}-%{version}
|
||||
%if 0%{?with_tests}
|
||||
%if %{with tests}
|
||||
tar -xf %{SOURCE1}
|
||||
%endif
|
||||
|
||||
@ -126,34 +127,35 @@ sed -i '1d' pip/__init__.py
|
||||
|
||||
|
||||
%build
|
||||
%if 0%{?build_wheel}
|
||||
%if %{without bootstrap}
|
||||
%py2_build_wheel
|
||||
%else
|
||||
%py2_build
|
||||
%endif
|
||||
|
||||
%if 0%{?with_python3}
|
||||
%if 0%{?build_wheel}
|
||||
%if %{with python3}
|
||||
%if %{without bootstrap}
|
||||
%py3_build_wheel
|
||||
%else
|
||||
%py3_build
|
||||
%endif
|
||||
%endif # with_python3
|
||||
%endif # with python3
|
||||
|
||||
|
||||
%install
|
||||
%if 0%{?with_python3}
|
||||
%if 0%{?build_wheel}
|
||||
%if %{with python3}
|
||||
%if %{without bootstrap}
|
||||
%py3_install_wheel %{python3_wheelname}
|
||||
# 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
|
||||
%else
|
||||
%py3_install
|
||||
%endif
|
||||
%endif # with_python3
|
||||
|
||||
%if 0%{?build_wheel}
|
||||
# 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 %{without bootstrap}
|
||||
%py2_install_wheel %{python2_wheelname}
|
||||
%else
|
||||
%py2_install
|
||||
@ -163,7 +165,7 @@ mkdir -p %{buildroot}%{bashcompdir}
|
||||
PYTHONPATH=%{buildroot}%{python_sitelib} \
|
||||
%{buildroot}%{_bindir}/pip completion --bash \
|
||||
> %{buildroot}%{bashcompdir}/pip
|
||||
%if 0%{?with_python3}
|
||||
%if %{with python3}
|
||||
PYTHONPATH=%{buildroot}%{python3_sitelib} \
|
||||
%{buildroot}%{_bindir}/pip3 completion --bash \
|
||||
> %{buildroot}%{bashcompdir}/pip3
|
||||
@ -179,7 +181,7 @@ for pip in %{buildroot}%{_bindir}/pip*; do
|
||||
ln -s pip %{buildroot}%{bashcompdir}/$pip
|
||||
%endif
|
||||
;;
|
||||
%if 0%{?with_python3}
|
||||
%if %{with python3}
|
||||
pip3?*)
|
||||
pips3="$pips3 $pip"
|
||||
%if 0%{?bashcomp2}
|
||||
@ -189,7 +191,7 @@ for pip in %{buildroot}%{_bindir}/pip*; do
|
||||
%endif
|
||||
esac
|
||||
done
|
||||
%if 0%{?with_python3}
|
||||
%if %{with python3}
|
||||
sed -i -e "s/^\\(complete.*\\) pip\$/\\1 $pips3/" \
|
||||
-e s/_pip_completion/_pip3_completion/ \
|
||||
%{buildroot}%{bashcompdir}/pip3
|
||||
@ -204,7 +206,7 @@ ln -s ./pip-%{python2_version} %{buildroot}%{_bindir}/pip-2
|
||||
ln -s ./pip-%{python3_version} %{buildroot}%{_bindir}/pip-3
|
||||
|
||||
|
||||
%if 0%{?with_tests}
|
||||
%if %{with tests}
|
||||
%check
|
||||
py.test -m 'not network'
|
||||
py.test-%{python3_version} -m 'not network'
|
||||
@ -221,14 +223,14 @@ py.test-%{python3_version} -m 'not network'
|
||||
%{_bindir}/pip-%{python2_version}
|
||||
%{python_sitelib}/pip*
|
||||
%{bashcompdir}
|
||||
%if 0%{?with_python3}
|
||||
%if %{with python3}
|
||||
%exclude %{bashcompdir}/pip3*
|
||||
%endif
|
||||
%if 0%{?bashcomp2}
|
||||
%dir %(dirname %{bashcompdir})
|
||||
%endif
|
||||
|
||||
%if 0%{?with_python3}
|
||||
%if %{with python3}
|
||||
%files -n python%{python3_pkgversion}-%{srcname}
|
||||
%license LICENSE.txt
|
||||
%doc README.rst docs
|
||||
@ -242,7 +244,7 @@ py.test-%{python3_version} -m 'not network'
|
||||
%if 0%{?bashcomp2}
|
||||
%dir %(dirname %{bashcompdir})
|
||||
%endif
|
||||
%endif # with_python3
|
||||
%endif # with python3
|
||||
|
||||
%changelog
|
||||
* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 9.0.1-11
|
||||
|
Loading…
Reference in New Issue
Block a user