Conditionalize the Python 2/Python 3 parts using bcond
This commit is contained in:
parent
a25c536b5e
commit
c7fdae32e2
@ -1,13 +1,20 @@
|
||||
%global with_python2 1
|
||||
%if 0%{?rhel} && 0%{?rhel} >= 8
|
||||
%global with_python2 0
|
||||
# disable python2 by default
|
||||
%bcond_with python2
|
||||
%else
|
||||
# enable python2 by default
|
||||
%bcond_without python2
|
||||
%endif
|
||||
|
||||
%if 0%{?fedora} || 0%{?rhel} >= 8
|
||||
%global with_python3 1
|
||||
# enable python3 by default
|
||||
%bcond_without python3
|
||||
%else
|
||||
# disable python3 by default
|
||||
%bcond_with python3
|
||||
%endif
|
||||
|
||||
%if ( 0%{?fedora} >= 31 ) || ( 0%{?with_python2} == 0 )
|
||||
%if %{with python3} && ( 0%{?fedora} >= 31 || %{without python2} )
|
||||
# link /usr/bin/alembic to /usr/bin/alembic-3
|
||||
# (https://fedoraproject.org/wiki/Changes/Python_means_Python3)
|
||||
%global python_version 3
|
||||
@ -32,7 +39,7 @@ BuildArch: noarch
|
||||
|
||||
BuildRequires: help2man
|
||||
|
||||
%if 0%{?with_python2}
|
||||
%if %{with python2}
|
||||
BuildRequires: python2-devel
|
||||
BuildRequires: python2-mako
|
||||
BuildRequires: python2-setuptools
|
||||
@ -56,7 +63,7 @@ BuildRequires: python2-psycopg2
|
||||
BuildRequires: python2-mysql
|
||||
%endif
|
||||
|
||||
%if 0%{?with_python3}
|
||||
%if %{with python3}
|
||||
BuildRequires: python3-devel
|
||||
BuildRequires: python2-tools
|
||||
BuildRequires: python3-sqlalchemy >= 0.7.4
|
||||
@ -86,7 +93,7 @@ Documentation and status of Alembic is at http://readthedocs.org/docs/alembic/
|
||||
|
||||
%description %_description
|
||||
|
||||
%if 0%{?with_python2}
|
||||
%if %{with python2}
|
||||
%package -n python2-alembic
|
||||
Summary: %summary
|
||||
|
||||
@ -107,7 +114,7 @@ Requires: python2-mako
|
||||
%description -n python2-alembic %_description
|
||||
%endif
|
||||
|
||||
%if 0%{?with_python3}
|
||||
%if %{with python3}
|
||||
%package -n python3-alembic
|
||||
Summary: %summary
|
||||
|
||||
@ -129,7 +136,7 @@ Conflicts: python2-alembic < 1.0.11-2
|
||||
%prep
|
||||
%autosetup -p1 -n %{modname}-%{version}
|
||||
|
||||
%if 0%{?with_python3}
|
||||
%if %{with python3}
|
||||
rm -rf %{py3dir}
|
||||
cp -a . %{py3dir}
|
||||
%endif
|
||||
@ -141,17 +148,17 @@ mv setup.py.tmp setup.py
|
||||
%endif
|
||||
|
||||
%build
|
||||
%if 0%{?with_python2}
|
||||
%if %{with python2}
|
||||
%{__python2} setup.py build
|
||||
%endif
|
||||
|
||||
%if 0%{?with_python3}
|
||||
%if %{with python3}
|
||||
pushd %{py3dir}
|
||||
%{__python3} setup.py build
|
||||
popd
|
||||
%endif
|
||||
|
||||
%if 0%{?with_python2}
|
||||
%if %{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
|
||||
@ -164,7 +171,7 @@ mv bin/alembic bin/python2-alembic
|
||||
%endif
|
||||
%endif
|
||||
|
||||
%if 0%{?with_python3}
|
||||
%if %{with python3}
|
||||
pushd %{py3dir}
|
||||
%{__mkdir_p} bin
|
||||
echo 'python3 -c "import alembic.config; alembic.config.main()" $*' > bin/alembic
|
||||
@ -178,7 +185,7 @@ popd
|
||||
|
||||
install -d -m 0755 %{buildroot}%{_mandir}/man1
|
||||
|
||||
%if 0%{?with_python3}
|
||||
%if %{with python3}
|
||||
pushd %{py3dir}
|
||||
%{__python3} setup.py install --skip-build --root=%{buildroot}
|
||||
mv %{buildroot}/%{_bindir}/%{modname} %{buildroot}/%{_bindir}/%{modname}-3
|
||||
@ -188,7 +195,7 @@ ln -s alembic-3.1 %{buildroot}%{_mandir}/man1/alembic-%{python3_version}.1
|
||||
popd
|
||||
%endif
|
||||
|
||||
%if 0%{?with_python2}
|
||||
%if %{with python2}
|
||||
%{__python2} setup.py install -O1 --skip-build --root=%{buildroot}
|
||||
mv %{buildroot}/%{_bindir}/%{modname} %{buildroot}/%{_bindir}/%{modname}-2
|
||||
ln -s %{modname}-2 %{buildroot}/%{_bindir}/%{modname}-%{python2_version}
|
||||
@ -210,18 +217,18 @@ sed -i -e "s|__requires__ = 'alembic==0.4.2'|__requires__ = ['alembic==0.4.2', '
|
||||
%endif
|
||||
|
||||
%check
|
||||
%if 0%{?with_python2}
|
||||
%if %{with python2}
|
||||
%{__python2} setup.py test
|
||||
%endif
|
||||
|
||||
%if 0%{?with_python3}
|
||||
%if %{with python3}
|
||||
pushd %{py3dir}
|
||||
%{__python3} setup.py test
|
||||
popd
|
||||
%endif
|
||||
|
||||
|
||||
%if 0%{?with_python2}
|
||||
%if %{with python2}
|
||||
%files -n python2-alembic
|
||||
%doc README.rst LICENSE CHANGES docs
|
||||
%{python2_sitelib}/%{modname}/
|
||||
@ -242,7 +249,7 @@ popd
|
||||
%endif
|
||||
%endif
|
||||
|
||||
%if 0%{?with_python3}
|
||||
%if %{with python3}
|
||||
%files -n python3-%{modname}
|
||||
%doc LICENSE README.rst CHANGES docs
|
||||
%{python3_sitelib}/%{modname}/
|
||||
@ -263,6 +270,7 @@ popd
|
||||
- Make /usr/bin/alembic point to alembic-3 on Fedora 31+
|
||||
See https://fedoraproject.org/wiki/Changes/Python_means_Python3
|
||||
- Avoid absolute symlinks
|
||||
- Conditionalize the Python 2/Python 3 parts with bcond
|
||||
|
||||
* Sun Jun 30 2019 Kevin Fenzi <kevin@scrye.com> - 1.0.11-1
|
||||
- Update to 1.0.11. Fixes bug #1723981
|
||||
|
Loading…
Reference in New Issue
Block a user