diff --git a/python-bcrypt.spec b/python-bcrypt.spec index 7896ce7..b663b80 100644 --- a/python-bcrypt.spec +++ b/python-bcrypt.spec @@ -1,4 +1,8 @@ %{!?_licensedir: %global license %%doc} +%if 0%{?fedora} +%global with_python3 1 +%endif + %global modname bcrypt %global sum Modern password hashing for your software and your servers @@ -15,15 +19,21 @@ Source0: https://files.pythonhosted.org/packages/source/b/%{modname}/ BuildRequires: python2-devel BuildRequires: python2-setuptools -BuildRequires: python2-cffi BuildRequires: python2-six BuildRequires: python2-pytest +%if (0%{?fedora} && 0%{?fedora} <= 27) || (0%{?rhel} && 0%{?rhel} <= 7) +BuildRequires: python-cffi +%else +BuildRequires: python2-cffi +%endif +%if 0%{?with_python3} BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-cffi BuildRequires: python3-six BuildRequires: python3-pytest +%endif %description %{sum}. @@ -42,6 +52,7 @@ Obsoletes: py-bcrypt < 0.4-11 %{sum}. +%if 0%{?with_python3} %package -n python3-%{modname} Summary: %{sum} %{?python_provide:%python_provide python3-%{modname}} @@ -54,26 +65,43 @@ Obsoletes: python3-py-bcrypt < 0.4-11 %description -n python3-%{modname} %{sum}. +%endif %prep %autosetup -n %{modname}-%{version} %build -%py2_build +%{__python2} setup.py build + +%if 0%{?with_python3} %py3_build +%endif %install -%py2_install +%if 0%{?with_python3} %py3_install +%endif + +%{__python2} setup.py install --skip-build --root %{buildroot} # Better safe than sorry find %{buildroot}%{python2_sitearch} -name '*.so' -exec chmod 755 {} ';' + +%if 0%{?with_python3} find %{buildroot}%{python3_sitearch} -name '*.so' -exec chmod 755 {} ';' +%endif %check +# Tests can't run on epel7 due to an old pytest +%if (0%{?rhel} && 0%{?rhel} > 7) %{__python2} setup.py test +%endif + +%if 0%{?with_python3} %{__python3} setup.py test +%endif + %files -n python2-%{modname} %doc README.rst @@ -81,11 +109,13 @@ find %{buildroot}%{python3_sitearch} -name '*.so' -exec chmod 755 {} ';' %{python2_sitearch}/%{modname}/ %{python2_sitearch}/%{modname}-%{version}* +%if 0%{?with_python3} %files -n python3-%{modname} %doc README.rst %license LICENSE %{python3_sitearch}/%{modname}/ %{python3_sitearch}/%{modname}-%{version}* +%endif %changelog