Add bootstrap macro and python2 conditions

This commit is contained in:
Honza Horak 2018-12-10 08:26:32 +01:00
parent eb3d96b97e
commit c0b8e836ca

View File

@ -4,6 +4,9 @@
%filter_setup
}
%global bootstrap 0
%bcond_without python2
Name: python-pymongo
Version: 3.7.1
Release: 2%{?dist}
@ -22,14 +25,18 @@ BuildRequires: gcc
%ifnarch armv7hl ppc64 s390 s390x
# These are needed for tests, and the tests don't work on armv7hl.
# MongoDB server is not available on big endian arches (ppc64, s390(x)).
%if 0%{!?bootstrap:1}
BuildRequires: mongodb-server
BuildRequires: python3-sphinx
%endif
BuildRequires: net-tools
BuildRequires: procps-ng
%endif
BuildRequires: python2-tools
BuildRequires: python3-tools
%if %{with python2}
BuildRequires: python2-devel
BuildRequires: python2-setuptools
BuildRequires: python2-sphinx
%endif
BuildRequires: python3-devel
BuildRequires: python3-setuptools
@ -47,6 +54,7 @@ Summary: Documentation for python-pymongo
Documentation for python-pymongo.
%if %{with python2}
%package -n python2-bson
Summary: Python bson library
%{?python_provide:%python_provide python2-bson}
@ -56,6 +64,7 @@ Summary: Python bson library
BSON is a binary-encoded serialization of JSON-like documents. BSON is designed
to be lightweight, traversable, and efficient. BSON, like JSON, supports the
embedding of objects and arrays within other objects and arrays.
%endif
%package -n python3-bson
@ -70,6 +79,7 @@ embedding of objects and arrays within other objects and arrays. This package
contains the python3 version of this module.
%if %{with python2}
%package -n python2-pymongo
Summary: Python driver for MongoDB
@ -82,6 +92,7 @@ Obsoletes: pymongo <= 2.1.1-4
%description -n python2-pymongo
The Python driver for MongoDB. This package contains the python2 version of
this module.
%endif
%package -n python3-pymongo
@ -95,6 +106,7 @@ The Python driver for MongoDB. This package contains the python3 version of
this module.
%if %{with python2}
%package -n python2-pymongo-gridfs
Summary: Python GridFS driver for MongoDB
Requires: python2-pymongo%{?_isa} = %{version}-%{release}
@ -105,6 +117,7 @@ Obsoletes: pymongo-gridfs <= 2.1.1-4
%description -n python2-pymongo-gridfs
GridFS is a storage specification for large objects in MongoDB.
%endif
%package -n python3-pymongo-gridfs
@ -127,40 +140,57 @@ contains the python3 version of this module.
# standard library.
rm pymongo/ssl_match_hostname.py
%if %{with python2}
rm -rf %{py3dir}
cp -a . %{py3dir}
%endif
%build
%if %{with python2}
%py2_build
%endif
%if %{with python2}
pushd %{py3dir}
%endif
%py3_build
%if %{with python2}
popd
%endif
%if 0%{!?bootstrap:1}
pushd doc
make %{?_smp_mflags} html
popd
%endif
%install
%if %{with python2}
%py2_install
# Fix permissions
chmod 755 %{buildroot}%{python2_sitearch}/bson/*.so
chmod 755 %{buildroot}%{python2_sitearch}/pymongo/*.so
%endif
%if %{with python2}
pushd %{py3dir}
%endif
%py3_install
# Fix permissions
chmod 755 %{buildroot}%{python3_sitearch}/bson/*.so
chmod 755 %{buildroot}%{python3_sitearch}/pymongo/*.so
%if %{with python2}
popd
%endif
%check
# For some reason, the tests never think they can connect to mongod on armv7hl even though netstat
# says it's listening. mongod is not available on big endian arches (ppc64, s390(x)).
%ifnarch armv7hl ppc64 s390 s390x
%if 0%{!?bootstrap:1}
if [ "$(netstat -ln | grep :27017)" != "" ]
then
@ -175,25 +205,36 @@ do
sleep 1
done
%if %{with python2}
python2 setup.py test || (pkill mongod && exit 1)
%endif
%if %{with python2}
pushd %{py3dir}
%endif
python3 setup.py test || (pkill mongod && exit 1)
%if %{with python2}
popd
%endif
pkill mongod
%endif
%endif
%files doc
%license LICENSE
%if 0%{!?bootstrap:1}
%doc doc/_build/html/*
%endif
%if %{with python2}
%files -n python2-bson
%license LICENSE
%doc README.rst
%{python2_sitearch}/bson
%endif
%files -n python3-bson
@ -202,11 +243,13 @@ pkill mongod
%{python3_sitearch}/bson
%if %{with python2}
%files -n python2-pymongo
%license LICENSE
%doc README.rst
%{python2_sitearch}/pymongo
%{python2_sitearch}/pymongo-%{version}-*.egg-info
%endif
%files -n python3-pymongo
@ -216,10 +259,12 @@ pkill mongod
%{python3_sitearch}/pymongo-%{version}-*.egg-info
%if %{with python2}
%files -n python2-pymongo-gridfs
%license LICENSE
%doc README.rst
%{python2_sitearch}/gridfs
%endif
%files -n python3-pymongo-gridfs
@ -229,6 +274,9 @@ pkill mongod
%changelog
* Mon Dec 10 2018 Honza Horak <hhorak@redhat.com> - 3.7.1-3
- Add bootstrap macro and python2 condition
* Tue Jul 31 2018 Florian Weimer <fweimer@redhat.com> - 3.7.1-2
- Rebuild with fixed binutils