Blob Blame History Raw
# set upstream name variable
%global srcname pycares


%if 0%{?fedora}
%bcond_without python3
%else
%bcond_with python3
%endif

Name:           python-pycares
Version:        2.3.0
Release:        5%{?dist}
Summary:        Python interface for c-ares

License:        MIT
URL:            https://github.com/saghul/pycares
Source0:        https://github.com/saghul/%{srcname}/archive/%{srcname}-%{version}.tar.gz

BuildRequires:  gcc
BuildRequires:  python2-devel
# for docs
BuildRequires:  python2-sphinx
%if %{with python3}
BuildRequires:  python3-devel
%endif # with python3

%description
pycares is a Python module which provides an interface to
c-ares. c-ares is a C library that performs DNS requests and name
resolutions asynchronously.


%package     -n python2-%{srcname}
Summary:        Python interface for c-ares
%{?python_provide:%python_provide python2-%{srcname}}

%description -n python2-%{srcname}
pycares is a Python module which provides an interface to
c-ares. c-ares is a C library that performs DNS requests and name
resolutions asynchronously.


%if %{with python3}
%package     -n python3-%{srcname}
Summary:        Python interface for c-ares
%{?python_provide:%python_provide python3-%{srcname}}

%description -n python3-%{srcname}
pycares is a Python module which provides an interface to
c-ares. c-ares is a C library that performs DNS requests and name
resolutions asynchronously.
%endif # with python3


%package     -n python-%{srcname}-doc
Summary:        Documentation for python-pycares
BuildArch:      noarch
Requires:       python2-%{srcname}

%description -n python-%{srcname}-doc
pycares is a Python module which provides an interface to
c-ares. c-ares is a C library that performs DNS requests and name
resolutions asynchronously.

This package contains documentation in reST and HTML formats.



%prep
%autosetup -n %{srcname}-%{srcname}-%{version}


%build
%py2_build

%if %{with python3}
%py3_build
%endif # with python3

# Build sphinx documentation
pushd docs/
make html
popd # docs


%install
# Must do the python3 install first because the scripts in /usr/bin are
# overwritten with every setup.py install (and we want the python2 version
# to be the default for now).
%if %{with python3}
%py3_install
%endif # with python3
%py2_install

# Install html docs
mkdir -p %{buildroot}%{_pkgdocdir}/
cp -pr docs/_build/html %{buildroot}%{_pkgdocdir}/

# Move sources
mv -f %{buildroot}%{_pkgdocdir}/html/_sources/ %{buildroot}%{_pkgdocdir}/rst/

# Remove buildinfo sphinx documentation
rm -rf %{buildroot}%{_pkgdocdir}/html/.buildinfo

# Fix non-standard modes (775)
chmod 755 %{buildroot}%{python2_sitearch}/%{srcname}/_core.so
chmod 755 %{buildroot}%{python3_sitearch}/%{srcname}/_core.cpython-*.so


%check
%{__python2} setup.py test -s pycares._core

%if %{with python3}
%{__python3} setup.py test -s pycares._core
%endif



%files -n python2-%{srcname}
%license LICENSE
%doc README.rst ChangeLog
# For arch-specific packages: sitearch
%{python2_sitearch}/%{srcname}/
%{python2_sitearch}/%{srcname}-%{version}-*.egg-info/


%if %{with python3}
%files -n python3-%{srcname}
%license LICENSE
%doc README.rst ChangeLog
# For arch-specific packages: sitearch
%{python3_sitearch}/%{srcname}/
%{python3_sitearch}/%{srcname}-%{version}-*.egg-info/
%endif # with python3


%files -n python-%{srcname}-doc
%doc examples/
%{_pkgdocdir}/



%changelog
* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.3.0-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.3.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Tue Jun 19 2018 Miro HronĨok <mhroncok@redhat.com> - 2.3.0-3
- Rebuilt for Python 3.7

* Wed Apr  4 2018 Matthieu Saulnier <fantom@fedoraproject.org> - 2.3.0-2
- Remove useless code duplication step
- Add missing %%python_provide macro in subpackages
- Cleanup rst doc script in %%install section
- Fix file ownership in doc subpackage

* Mon Apr  2 2018 Matthieu Saulnier <fantom@fedoraproject.org> - 2.3.0-1
- Initial package