Add conditionals for Python2 and Python3

This commit is contained in:
Tomas Mraz 2018-03-22 11:45:03 +01:00
parent b7e5b94340
commit c7547d1617

View File

@ -1,7 +1,21 @@
%if 0%{?fedora} || 0%{?rhel} > 7
# Enable python3 build by default
%bcond_without python3
%else
%bcond_with python3
%endif
%if 0%{?rhel} > 7 && %{with python3}
# Disable python2 build by default
%bcond_with python2
%else
%bcond_without python2
%endif
Summary: A library for password generation and password quality checking
Name: libpwquality
Version: 1.4.0
Release: 6%{?dist}
Release: 7%{?dist}
# The package is BSD licensed with option to relicense as GPLv2+
# - this option is redundant as the BSD license allows that anyway.
License: BSD or GPLv2+
@ -43,6 +57,7 @@ Files needed for development of applications using the libpwquality
library.
See the pwquality.h header file for the API.
%if %{with python2}
%package -n python2-pwquality
%{?python_provide:%python_provide python2-pwquality}
Group: Development/Libraries
@ -54,7 +69,9 @@ This is pwquality Python module that provides Python bindings
for the libpwquality library. These bindings can be used
for easy password quality checking and generation of random
pronounceable passwords from Python applications.
%endif
%if %{with python3}
%package -n python3-pwquality
Group: Development/Libraries
Summary: Python bindings for the libpwquality library
@ -65,23 +82,30 @@ This is pwquality Python module that provides Python bindings
for the libpwquality library. These bindings can be used
for easy password quality checking and generation of random
pronounceable passwords from Python applications.
%endif
%prep
%setup -q
%if %{with python3} && %{with python2}
rm -rf %{py3dir}
cp -a . %{py3dir}
%endif
%build
%if %{with python2}
%configure \
--with-securedir=%{_moduledir} \
--with-pythonsitedir=%{python_sitearch} \
--with-pythonsitedir=%{python2_sitearch} \
--with-python-binary=%{__python2} \
--disable-static
make %{?_smp_mflags}
%endif
%if %{with python3} && %{with python2}
pushd %{py3dir}
%endif
%if %{with python3}
%configure \
--with-securedir=%{_moduledir} \
--with-pythonsitedir=%{python3_sitearch} \
@ -89,14 +113,19 @@ pushd %{py3dir}
--disable-static
make %{?_smp_mflags}
%endif
%if %{with python3} && %{with python2}
popd
%endif
%install
make install DESTDIR=$RPM_BUILD_ROOT INSTALL='install -p'
%if %{with python3} && %{with python2}
pushd %{py3dir}
make -C python install DESTDIR=$RPM_BUILD_ROOT INSTALL='install -p'
popd
%endif
%if "%{_pwqlibdir}" != "%{_libdir}"
pushd $RPM_BUILD_ROOT%{_libdir}
@ -138,17 +167,24 @@ mkdir $RPM_BUILD_ROOT%{_secconfdir}/pwquality.conf.d
%{_libdir}/pkgconfig/*.pc
%{_mandir}/man3/*
%if %{with python2}
%files -n python2-pwquality
%defattr(-,root,root,-)
%{python_sitearch}/pwquality.so
%{python_sitearch}/*.egg-info
%endif
%if %{with python3}
%files -n python3-pwquality
%defattr(-,root,root,-)
%{python3_sitearch}/*.so
%{python3_sitearch}/*.egg-info
%endif
%changelog
* Thu Mar 22 2018 Tomáš Mráz <tmraz@redhat.com> 1.4.0-7
- Add conditionals for Python2 and Python3
* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.0-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild