Make python2 optional

This commit is contained in:
Stephen Smoogen 2019-07-19 19:48:13 +00:00 committed by Petr Viktorin
parent 4c64425545
commit ff2ff58db3

View File

@ -1,3 +1,8 @@
%global with_python2 1
%if 0%{?rhel} && 0%{?rhel} >= 8
%global with_python2 0
%endif
%if 0%{?fedora} || 0%{?rhel} >= 8
%global with_python3 1
%endif
@ -6,7 +11,7 @@
Name: python-alembic
Version: 1.0.11
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Database migration tool for SQLAlchemy
License: MIT
@ -16,6 +21,8 @@ Source0: %pypi_source alembic
BuildArch: noarch
BuildRequires: help2man
%if 0%{?with_python2}
BuildRequires: python2-devel
BuildRequires: python2-mako
BuildRequires: python2-setuptools
@ -37,6 +44,7 @@ BuildRequires: python2-sqlalchemy >= 0.7.4
# Just for the tests
BuildRequires: python2-psycopg2
BuildRequires: python2-mysql
%endif
%if 0%{?with_python3}
BuildRequires: python3-devel
@ -68,6 +76,7 @@ Documentation and status of Alembic is at http://readthedocs.org/docs/alembic/
%description %_description
%if 0%{?with_python2}
%package -n python2-alembic
Summary: %summary
@ -86,6 +95,7 @@ Requires: python2-mako
%{?python_provide:%python_provide python2-alembic}
%description -n python2-alembic %_description
%endif
%if 0%{?with_python3}
%package -n python3-alembic
@ -116,7 +126,9 @@ mv setup.py.tmp setup.py
%endif
%build
%if 0%{?with_python2}
%{__python2} setup.py build
%endif
%if 0%{?with_python3}
pushd %{py3dir}
@ -124,6 +136,7 @@ pushd %{py3dir}
popd
%endif
%if 0%{?with_python2}
# Hack around setuptools so we can get access to help strings for help2man
# Credit for this goes to Toshio Kuratomi
%if 0%{?rhel} && 0%{?rhel} <= 6
@ -134,6 +147,7 @@ chmod 0755 bin/alembic
help2man --version-string %{version} --no-info -s 1 bin/alembic > python2-alembic.1
mv bin/alembic bin/python2-alembic
%endif
%endif
%if 0%{?with_python3}
pushd %{py3dir}
@ -159,12 +173,14 @@ ln -s %{_mandir}/man1/alembic-3.1 %{buildroot}%{_mandir}/man1/alembic-%{python3_
popd
%endif
%if 0%{?with_python2}
%{__python2} setup.py install -O1 --skip-build --root=%{buildroot}
ln -s %{_bindir}/%{modname} %{buildroot}/%{_bindir}/%{modname}-2
ln -s %{_bindir}/%{modname} %{buildroot}/%{_bindir}/%{modname}-%{python2_version}
install -m 0644 python2-alembic.1 %{buildroot}%{_mandir}/man1/alembic.1
ln -s %{_mandir}/man1/alembic.1 %{buildroot}%{_mandir}/man1/alembic-2.1
ln -s %{_mandir}/man1/alembic.1 %{buildroot}%{_mandir}/man1/alembic-%{python2_version}.1
%endif
%if 0%{?rhel} && 0%{?rhel} <= 6
# Modify /usr/bin/alembic to require SQLAlchemy>=0.6
@ -177,7 +193,9 @@ sed -i -e "s|__requires__ = 'alembic==0.4.2'|__requires__ = ['alembic==0.4.2', '
%endif
%check
%if 0%{?with_python2}
%{__python2} setup.py test
%endif
%if 0%{?with_python3}
pushd %{py3dir}
@ -186,6 +204,7 @@ popd
%endif
%if 0%{?with_python2}
%files -n python2-alembic
%doc README.rst LICENSE CHANGES docs
%{python2_sitelib}/%{modname}/
@ -200,6 +219,7 @@ popd
%{_mandir}/man1/alembic-2.1*
%{_mandir}/man1/alembic-%{python2_version}.1*
%endif
%endif
%if 0%{?with_python3}
%files -n python3-%{modname}
@ -217,6 +237,10 @@ popd
* Sun Jun 30 2019 Kevin Fenzi <kevin@scrye.com> - 1.0.11-1
- Update to 1.0.11. Fixes bug #1723981
* Wed Jun 19 2019 Troy Dawson <tdawson@redhat.com> - 1.0.10-1.1
- Make python2 optional
- Do not build python2 on RHEL8
* Wed Jun 05 2019 Randy Barlow <bowlofeggs@fedoraproject.org> - 1.0.10-1
- Update to 1.0.10 (#1700050).
- https://alembic.sqlalchemy.org/en/latest/changelog.html#change-1.0.10