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