Make Python 2 optional
To facilitate building the Python 2 and Python 3 modules.
This commit is contained in:
parent
a096270f29
commit
222c069cc5
@ -1,13 +1,17 @@
|
|||||||
%bcond_with bootstrap
|
%bcond_with bootstrap
|
||||||
%bcond_with tests
|
%bcond_with tests
|
||||||
|
|
||||||
|
%bcond_without python2
|
||||||
%bcond_without python3
|
%bcond_without python3
|
||||||
|
|
||||||
%global srcname pip
|
%global srcname pip
|
||||||
|
%global python_wheelname %{srcname}-%{version}-py2.py3-none-any.whl
|
||||||
%if %{without bootstrap}
|
%if %{without bootstrap}
|
||||||
%global python2_wheelname %{srcname}-%{version}-py2.py3-none-any.whl
|
%if %{with python2}
|
||||||
|
%global python2_wheelname %python_wheelname
|
||||||
|
%endif
|
||||||
%if %{with python3}
|
%if %{with python3}
|
||||||
%global python3_wheelname %python2_wheelname
|
%global python3_wheelname %python_wheelname
|
||||||
%endif
|
%endif
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
@ -18,7 +22,7 @@
|
|||||||
|
|
||||||
Name: python-%{srcname}
|
Name: python-%{srcname}
|
||||||
Version: 9.0.1
|
Version: 9.0.1
|
||||||
Release: 11%{?dist}
|
Release: 12%{?dist}
|
||||||
Summary: A tool for installing and managing Python packages
|
Summary: A tool for installing and managing Python packages
|
||||||
|
|
||||||
Group: Development/Libraries
|
Group: Development/Libraries
|
||||||
@ -28,6 +32,9 @@ Source0: https://files.pythonhosted.org/packages/source/p/%{srcname}/%{sr
|
|||||||
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
|
|
||||||
|
BuildRequires: git
|
||||||
|
BuildRequires: bzr
|
||||||
|
|
||||||
# to get tests:
|
# to get tests:
|
||||||
# git clone https://github.com/pypa/pip && cd pip
|
# git clone https://github.com/pypa/pip && cd pip
|
||||||
# git checkout 9.0.1 && tar -czvf ../pip-9.0.1-tests.tar.gz tests/
|
# git checkout 9.0.1 && tar -czvf ../pip-9.0.1-tests.tar.gz tests/
|
||||||
@ -51,14 +58,13 @@ written in Python. Many packages can be found in the Python Package Index
|
|||||||
Packages" or "Pip Installs Python".
|
Packages" or "Pip Installs Python".
|
||||||
|
|
||||||
|
|
||||||
|
%if %{with python2}
|
||||||
%package -n python2-%{srcname}
|
%package -n python2-%{srcname}
|
||||||
Summary: A tool for installing and managing Python 2 packages
|
Summary: A tool for installing and managing Python 2 packages
|
||||||
Group: Development/Libraries
|
Group: Development/Libraries
|
||||||
BuildRequires: python2-devel
|
BuildRequires: python2-devel
|
||||||
BuildRequires: python-setuptools
|
BuildRequires: python-setuptools
|
||||||
%if %{with tests}
|
%if %{with tests}
|
||||||
BuildRequires: git
|
|
||||||
BuildRequires: bzr
|
|
||||||
BuildRequires: python-mock
|
BuildRequires: python-mock
|
||||||
BuildRequires: pytest
|
BuildRequires: pytest
|
||||||
BuildRequires: python-pretend
|
BuildRequires: python-pretend
|
||||||
@ -80,6 +86,8 @@ 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
|
(PyPI). pip is a recursive acronym that can stand for either "Pip Installs
|
||||||
Packages" or "Pip Installs Python".
|
Packages" or "Pip Installs Python".
|
||||||
|
|
||||||
|
%endif # with python2
|
||||||
|
|
||||||
|
|
||||||
%if %{with python3}
|
%if %{with python3}
|
||||||
%package -n python%{python3_pkgversion}-%{srcname}
|
%package -n python%{python3_pkgversion}-%{srcname}
|
||||||
@ -127,11 +135,13 @@ sed -i '1d' pip/__init__.py
|
|||||||
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
|
%if %{with python2}
|
||||||
%if %{without bootstrap}
|
%if %{without bootstrap}
|
||||||
%py2_build_wheel
|
%py2_build_wheel
|
||||||
%else
|
%else
|
||||||
%py2_build
|
%py2_build
|
||||||
%endif
|
%endif
|
||||||
|
%endif # with python2
|
||||||
|
|
||||||
%if %{with python3}
|
%if %{with python3}
|
||||||
%if %{without bootstrap}
|
%if %{without bootstrap}
|
||||||
@ -155,16 +165,20 @@ sed -i '1d' pip/__init__.py
|
|||||||
rm %{buildroot}%{_bindir}/pip
|
rm %{buildroot}%{_bindir}/pip
|
||||||
%endif # with python3
|
%endif # with python3
|
||||||
|
|
||||||
|
%if %{with python2}
|
||||||
%if %{without bootstrap}
|
%if %{without bootstrap}
|
||||||
%py2_install_wheel %{python2_wheelname}
|
%py2_install_wheel %{python2_wheelname}
|
||||||
%else
|
%else
|
||||||
%py2_install
|
%py2_install
|
||||||
%endif
|
%endif
|
||||||
|
%endif # with python2
|
||||||
|
|
||||||
mkdir -p %{buildroot}%{bashcompdir}
|
mkdir -p %{buildroot}%{bashcompdir}
|
||||||
PYTHONPATH=%{buildroot}%{python_sitelib} \
|
%if %{with python2}
|
||||||
|
PYTHONPATH=%{buildroot}%{python2_sitelib} \
|
||||||
%{buildroot}%{_bindir}/pip completion --bash \
|
%{buildroot}%{_bindir}/pip completion --bash \
|
||||||
> %{buildroot}%{bashcompdir}/pip
|
> %{buildroot}%{bashcompdir}/pip
|
||||||
|
%endif
|
||||||
%if %{with python3}
|
%if %{with python3}
|
||||||
PYTHONPATH=%{buildroot}%{python3_sitelib} \
|
PYTHONPATH=%{buildroot}%{python3_sitelib} \
|
||||||
%{buildroot}%{_bindir}/pip3 completion --bash \
|
%{buildroot}%{_bindir}/pip3 completion --bash \
|
||||||
@ -175,12 +189,14 @@ pips3=pip3
|
|||||||
for pip in %{buildroot}%{_bindir}/pip*; do
|
for pip in %{buildroot}%{_bindir}/pip*; do
|
||||||
pip=$(basename $pip)
|
pip=$(basename $pip)
|
||||||
case $pip in
|
case $pip in
|
||||||
|
%if %{with python2}
|
||||||
pip2*)
|
pip2*)
|
||||||
pips2="$pips2 $pip"
|
pips2="$pips2 $pip"
|
||||||
%if 0%{?bashcomp2}
|
%if 0%{?bashcomp2}
|
||||||
ln -s pip %{buildroot}%{bashcompdir}/$pip
|
ln -s pip %{buildroot}%{bashcompdir}/$pip
|
||||||
%endif
|
%endif
|
||||||
;;
|
;;
|
||||||
|
%endif
|
||||||
%if %{with python3}
|
%if %{with python3}
|
||||||
pip3?*)
|
pip3?*)
|
||||||
pips3="$pips3 $pip"
|
pips3="$pips3 $pip"
|
||||||
@ -196,23 +212,34 @@ sed -i -e "s/^\\(complete.*\\) pip\$/\\1 $pips3/" \
|
|||||||
-e s/_pip_completion/_pip3_completion/ \
|
-e s/_pip_completion/_pip3_completion/ \
|
||||||
%{buildroot}%{bashcompdir}/pip3
|
%{buildroot}%{bashcompdir}/pip3
|
||||||
%endif
|
%endif
|
||||||
|
%if %{with python2}
|
||||||
sed -i -e "s/^\\(complete.*\\) pip\$/\\1 $pips2/" \
|
sed -i -e "s/^\\(complete.*\\) pip\$/\\1 $pips2/" \
|
||||||
%{buildroot}%{bashcompdir}/pip
|
%{buildroot}%{bashcompdir}/pip
|
||||||
|
%endif
|
||||||
|
|
||||||
# Provide symlinks to executables to comply with Fedora guidelines for Python
|
# Provide symlinks to executables to comply with Fedora guidelines for Python
|
||||||
|
%if %{with python2}
|
||||||
ln -s ./pip%{python2_version} %{buildroot}%{_bindir}/pip-%{python2_version}
|
ln -s ./pip%{python2_version} %{buildroot}%{_bindir}/pip-%{python2_version}
|
||||||
ln -s ./pip%{python3_version} %{buildroot}%{_bindir}/pip-%{python3_version}
|
|
||||||
ln -s ./pip-%{python2_version} %{buildroot}%{_bindir}/pip-2
|
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
|
ln -s ./pip-%{python3_version} %{buildroot}%{_bindir}/pip-3
|
||||||
|
%endif
|
||||||
|
|
||||||
|
|
||||||
%if %{with tests}
|
%if %{with tests}
|
||||||
%check
|
%check
|
||||||
py.test -m 'not network'
|
%if %{with python2}
|
||||||
|
py.test-%{python2_version} -m 'not network'
|
||||||
|
%endif
|
||||||
|
%if %{with python3}
|
||||||
py.test-%{python3_version} -m 'not network'
|
py.test-%{python3_version} -m 'not network'
|
||||||
%endif
|
%endif
|
||||||
|
%endif
|
||||||
|
|
||||||
|
|
||||||
|
%if %{with python2}
|
||||||
%files -n python2-%{srcname}
|
%files -n python2-%{srcname}
|
||||||
%license LICENSE.txt
|
%license LICENSE.txt
|
||||||
%doc README.rst docs
|
%doc README.rst docs
|
||||||
@ -221,14 +248,14 @@ py.test-%{python3_version} -m 'not network'
|
|||||||
%{_bindir}/pip-2
|
%{_bindir}/pip-2
|
||||||
%{_bindir}/pip%{python2_version}
|
%{_bindir}/pip%{python2_version}
|
||||||
%{_bindir}/pip-%{python2_version}
|
%{_bindir}/pip-%{python2_version}
|
||||||
%{python_sitelib}/pip*
|
%{python2_sitelib}/pip*
|
||||||
%{bashcompdir}
|
%dir %{bashcompdir}
|
||||||
%if %{with python3}
|
%{bashcompdir}/pip
|
||||||
%exclude %{bashcompdir}/pip3*
|
%{bashcompdir}/pip2*
|
||||||
%endif
|
|
||||||
%if 0%{?bashcomp2}
|
%if 0%{?bashcomp2}
|
||||||
%dir %(dirname %{bashcompdir})
|
%dir %(dirname %{bashcompdir})
|
||||||
%endif
|
%endif
|
||||||
|
%endif # with python2
|
||||||
|
|
||||||
%if %{with python3}
|
%if %{with python3}
|
||||||
%files -n python%{python3_pkgversion}-%{srcname}
|
%files -n python%{python3_pkgversion}-%{srcname}
|
||||||
@ -247,6 +274,10 @@ py.test-%{python3_version} -m 'not network'
|
|||||||
%endif # with python3
|
%endif # with python3
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Aug 29 2017 Tomas Orsava <torsava@redhat.com> - 9.0.1-12
|
||||||
|
- Switch macros to bcond's and make Python 2 optional to facilitate building
|
||||||
|
the Python 2 and Python 3 modules
|
||||||
|
|
||||||
* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 9.0.1-11
|
* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 9.0.1-11
|
||||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user