Blob Blame History Raw
%if 0%{?fedora} || 0%{?rhel} >= 8
%global with_py3 1
%endif

%global srcname ZODB

Name:           python-%{srcname}
Version:        4.3.1
Release:        2%{?dist}
Summary:        Zope Object Database and persistence

License:        ZPLv2.1
URL:            http://www.zodb.org/
Source0:        https://files.pythonhosted.org/packages/source/Z/%{srcname}/%{srcname}-%{version}.tar.gz
BuildArch:      noarch

BuildRequires:  python2-BTrees
BuildRequires:  python2-devel
BuildRequires:  python2-manuel
BuildRequires:  python2-persistent
BuildRequires:  python2-random2
BuildRequires:  python2-setuptools
BuildRequires:  python2-six
BuildRequires:  python-transaction
BuildRequires:  python-zc-lockfile
BuildRequires:  python2-ZConfig
BuildRequires:  python2-zodbpickle
BuildRequires:  python-zope-testing

%if 0%{?with_py3}
BuildRequires:  python3-BTrees
BuildRequires:  python3-devel
BuildRequires:  python3-manuel
BuildRequires:  python3-persistent
BuildRequires:  python3-random2
BuildRequires:  python3-setuptools
BuildRequires:  python3-six
BuildRequires:  python3-transaction
BuildRequires:  python3-zc-lockfile
BuildRequires:  python3-ZConfig
BuildRequires:  python3-zodbpickle
BuildRequires:  python3-zope-testing
%endif

%global common_desc                                                \
The ZODB package provides a set of tools for using the Zope Object \
Database (ZODB).

%description
%{common_desc}

%package -n python2-%{srcname}
Summary:        Zope Object Database and persistence
Requires:       python2-BTrees
Requires:       python2-persistent
Requires:       python2-setuptools
Requires:       python2-six
Requires:       python-transaction
Requires:       python-zc-lockfile
Requires:       python2-ZConfig
Requires:       python2-zodbpickle

%{?python_provide:%python_provide python2-%{srcname}}

%description -n python2-%{srcname}
%{common_desc}

%if 0%{?with_py3}
%package -n python3-%{srcname}
Summary:        Zope Object Database and persistence
Requires:       python3-BTrees
Requires:       python3-persistent
Requires:       python3-setuptools
Requires:       python3-six
Requires:       python3-transaction
Requires:       python3-zc-lockfile
Requires:       python3-ZConfig
Requires:       python3-zodbpickle

%{?python_provide:%python_provide python3-%{srcname}}

%description -n python3-%{srcname}
%{common_desc}
%endif

%prep
%setup -q -c

# Remove prebuilt egg
rm -fr %{srcname}-%{version}/src/%{srcname}.egg-info

# Remove backup files
find %{srcname}-%{version}/src -name \*~ -exec rm {} +
find %{srcname}-%{version}/src -name \#\*\# -exec rm {} +

# Fix a test
sed -i 's/random/random2/' %{srcname}-%{version}/src/ZODB/tests/testUtils.py

%if 0%{?with_py3}
# Prepare for a python3 build
cp -a %{srcname}-%{version} python3-%{srcname}-%{version}
%endif

%build
# Python 2 build
pushd %{srcname}-%{version}
%py2_build
popd

%if 0%{?with_py3}
# Python 3 build
pushd python3-%{srcname}-%{version}
%py3_build
popd
%endif

%install
%if 0%{?with_py3}
# Python 3 install
pushd python3-%{srcname}-%{version}
%py3_install
popd
for bin in fsdump fsoids fsrefs fstail repozo; do
  mv %{buildroot}%{_bindir}/$bin %{buildroot}%{_bindir}/python3-${bin}
done

# Fix scripts
for script in \
  $(grep -l '^#!' %{buildroot}%{python3_sitelib}/%{srcname}/scripts/*.py); do
  sed 's,%{_bindir}/python,&3,;s,%{_bindir}/env python.*,%{_bindir}/python3,' \
    $script > $script.new
  touch -r $script $script.new
  mv -f $script.new $script
  chmod 0755 $script
done
%endif

# Python 2 install
pushd %{srcname}-%{version}
%py2_install

# Fix scripts
for script in \
  $(grep -l '^#!' %{buildroot}%{python2_sitelib}/%{srcname}/scripts/*.py); do
  sed 's,%{_bindir}/python,&2,;s,%{_bindir}/env python.*,%{_bindir}/python2,' \
    $script > $script.new
  touch -r $script $script.new
  mv -f $script.new $script
  chmod 0755 $script
done
popd

%check
# Python 2 tests
pushd %{srcname}-%{version}
%{__python2} setup.py test
popd

%if 0%{?with_py3}
# Python 3 tests
pushd python3-%{srcname}-%{version}
%{__python3} setup.py test
popd
%endif

%files -n python2-%{srcname}
%license %{srcname}-%{version}/COPYRIGHT.txt %{srcname}-%{version}/LICENSE.txt
%doc %{srcname}-%{version}/doc/storage.pdf %{srcname}-%{version}/doc/*.txt
%doc %{srcname}-%{version}/CHANGES.rst
%{_bindir}/fsdump
%{_bindir}/fsoids
%{_bindir}/fsrefs
%{_bindir}/fstail
%{_bindir}/repozo
%{python2_sitelib}/%{srcname}*

%if 0%{?with_py3}
%files -n python3-%{srcname}
%license %{srcname}-%{version}/COPYRIGHT.txt %{srcname}-%{version}/LICENSE.txt
%doc %{srcname}-%{version}/doc/storage.pdf %{srcname}-%{version}/doc/*.txt
%doc %{srcname}-%{version}/CHANGES.rst
%{_bindir}/python3-fsdump
%{_bindir}/python3-fsoids
%{_bindir}/python3-fsrefs
%{_bindir}/python3-fstail
%{_bindir}/python3-repozo
%{python3_sitelib}/%{srcname}*
%endif

%changelog
* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.3.1-2
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages

* Fri Jun 10 2016 Jerry James <loganjerry@gmail.com> - 4.3.1-1
- New upstream release

* Wed Jun  1 2016 Jerry James <loganjerry@gmail.com> - 4.3.0-1
- New upstream release

* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 4.2.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Mon Feb  1 2016 Jerry James <loganjerry@gmail.com> - 4.2.0-3
- Comply with latest python packaging guidelines

* Tue Nov 10 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.2.0-3
- Rebuilt for https://fedoraproject.org/wiki/Changes/python3.5

* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.2.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Tue Jun  9 2015 Jerry James <loganjerry@gmail.com> - 4.2.0-1
- New upstream release

* Mon Jan 12 2015 Jerry James <loganjerry@gmail.com> - 4.1.0-1
- New upstream release

* Wed Aug  6 2014 Jerry James <loganjerry@gmail.com> - 4.0.1-1
- New upstream release

* Wed Jun 11 2014 Jerry James <loganjerry@gmail.com> - 4.0.0-1
- Initial RPM