%if 0%{?fedora} > 12
%global with_python3 1
%else
%{!?__python2: %global __python2 /usr/bin/python2}
%{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print (get_python_lib())")}
%endif
%global srcname ipgetter
Name: python-ipgetter
Version: 0.6
Release: 1%{?dist}
Summary: A Python module to fetch the external IP address
License: WTFPL
URL: https://github.com/phoemur/ipgetter
Source0: https://pypi.python.org/packages/source/i/%{srcname}/%{srcname}-%{version}.tar.gz
BuildArch: noarch
BuildRequires: python2-devel
BuildRequires: python-setuptools
%if 0%{?with_python3}
BuildRequires: python3-devel
BuildRequires: python3-setuptools
%endif
%description
This module is designed to fetch your external IP address from the
internet. It is used mostly when behind a NAT. It picks your IP randomly
from a server list to minimize request overhead on a single server.
%if 0%{?with_python3}
%package -n python3-%{srcname}
Summary: A Python module to fetch the external IP address
%description -n python3-%{srcname}
This module is designed to fetch your external IP address from the
internet. It is used mostly when behind a NAT. It picks your IP randomly
from a server list to minimize request overhead on a single server.
%endif
%prep
%setup -q -n %{srcname}-%{version}
sed -i -e '/^#!\//, 1d' %{srcname}.py
%if 0%{?with_python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
find %{py3dir} -name '*.py' | xargs sed -i '/^#!\//, 1d'
%endif # with_python3
%build
%{__python2} setup.py build
%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py build
popd
%endif
%install
%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py install --skip-build --root %{buildroot}
popd
%endif
%{__python2} setup.py install --skip-build --root %{buildroot}
%files
%doc
%{python2_sitelib}/*
%if 0%{?with_python3}
%files -n python3-%{srcname}
%doc
%{python3_sitelib}/*
%endif
%changelog
* Fri Mar 06 2015 Fabian Affolter <mail@fabian-affolter.ch> - 0.6-1
- Update to latest upstream release 0.6
* Wed Feb 26 2014 Fabian Affolter <mail@fabian-affolter.ch> - 0.5.2-1
- Initial package for Fedora