6af58a
%if 0%{?fedora} || 0%{?rhel} > 7
6af58a
%global with_python3 1
6af58a
%endif
6af58a
6af58a
%if 0%{?rhel} > 7
6af58a
%bcond_with python2
6af58a
%else
6af58a
%bcond_without python2
6af58a
%endif
6af58a
6af58a
Name:           python-netaddr
6af58a
Version:        0.7.19
6af58a
Release:        8%{?dist}
6af58a
Summary:        A pure Python network address representation and manipulation library
6af58a
6af58a
License:        BSD
6af58a
URL:            http://github.com/drkjam/netaddr
6af58a
Source0:        https://pypi.python.org/packages/source/n/netaddr/netaddr-%{version}.tar.gz
6af58a
6af58a
BuildArch:      noarch
6af58a
6af58a
Patch0: 0001-fixed-broken-tests-in-issue-149-python-3-regression-.patch
6af58a
Patch1: 0001-Do-not-override-executable-path.patch
6af58a
6af58a
%global desc A network address manipulation library for Python\
6af58a
\
6af58a
Provides support for:\
6af58a
\
6af58a
Layer 3 addresses\
6af58a
\
6af58a
 * IPv4 and IPv6 addresses, subnets, masks, prefixes\
6af58a
 * iterating, slicing, sorting, summarizing and classifying IP networks\
6af58a
 * dealing with various ranges formats (CIDR, arbitrary ranges and globs, nmap)\
6af58a
 * set based operations (unions, intersections etc) over IP addresses and subnets\
6af58a
 * parsing a large variety of different formats and notations\
6af58a
 * looking up IANA IP block information\
6af58a
 * generating DNS reverse lookups\
6af58a
 * supernetting and subnetting\
6af58a
\
6af58a
Layer 2 addresses\
6af58a
\
6af58a
 * representation and manipulation MAC addresses and EUI-64 identifiers\
6af58a
 * looking up IEEE organisational information (OUI, IAB)\
6af58a
 * generating derived IPv6 addresses
6af58a
6af58a
6af58a
%global _description\
6af58a
%{desc}
6af58a
6af58a
%description %_description
6af58a
6af58a
%if %{with python2}
6af58a
%package -n python2-netaddr
6af58a
Summary: %summary
6af58a
%{?python_provide:%python_provide python2-netaddr}
6af58a
BuildRequires:  python2-devel
6af58a
BuildRequires:  python2-setuptools
6af58a
BuildRequires:  python2-sphinx
6af58a
BuildRequires:  python2-pytest
6af58a
6af58a
%description -n python2-netaddr %_description
6af58a
%endif #{with python2}
6af58a
6af58a
%if 0%{?with_python3}
6af58a
%package -n python3-netaddr
6af58a
Summary: A pure Python network address representation and manipulation library
6af58a
BuildRequires:  python3-devel
6af58a
BuildRequires:  python3-setuptools
6af58a
BuildRequires:  python3-sphinx
6af58a
BuildRequires:  python3-pytest
6af58a
6af58a
%description -n python3-netaddr
6af58a
%{desc}
6af58a
%endif
6af58a
6af58a
%prep
6af58a
%setup -q -n netaddr-%{version}
6af58a
%patch0 -p1
6af58a
%patch1 -p1
6af58a
6af58a
# Make rpmlint happy, get rid of DOS line endings
6af58a
sed -i 's/\r//' netaddr/*.py netaddr/ip/*.py netaddr/eui/*.idx
6af58a
6af58a
# Make rpmlint happy, rip out python shebang lines from most python
6af58a
# modules
6af58a
find netaddr -name "*.py" | \
6af58a
  xargs sed -i -e '1 {/^#!\//d}'
6af58a
# Fix python executable
6af58a
%if %{with python2}
6af58a
sed -i -e '1s,/usr/bin/env python,%{__python2} %{?py_shbang_opts},' netaddr/tools/netaddr
6af58a
%else
6af58a
sed -i -e '1s,/usr/bin/env python,%{__python3} %{?py_shbang_opts},' netaddr/tools/netaddr
6af58a
%endif #{with python2}
6af58a
6af58a
# Make rpmlint happy, fix permissions on documentation files
6af58a
chmod 0644 README.md AUTHORS CHANGELOG COPYRIGHT LICENSE PKG-INFO
6af58a
6af58a
%build
6af58a
%if %{with python2}
6af58a
%py2_build
6af58a
%endif #{with python2}
6af58a
6af58a
%if 0%{?with_python3}
6af58a
%py3_build
6af58a
%endif
6af58a
6af58a
#docs
6af58a
pushd docs
6af58a
%if %{with python2}
6af58a
PYTHONPATH='../' sphinx-build -b html -d build/doctrees source html
6af58a
%endif #{with python2}
6af58a
%if 0%{?with_python3}
6af58a
PYTHONPATH='../' sphinx-build-%{python3_version} -b html -d build/doctrees source python3/html
6af58a
%endif
6af58a
popd
6af58a
6af58a
6af58a
%install
6af58a
%if 0%{?with_python3}
6af58a
%py3_install
6af58a
mv %{buildroot}%{_bindir}/netaddr %{buildroot}%{_bindir}/netaddr3
6af58a
%endif
6af58a
6af58a
%if %{with python2}
6af58a
%py2_install
6af58a
%endif #{with python2}
6af58a
6af58a
6af58a
%check
6af58a
%if %{with python2}
6af58a
py.test-%{python2_version}
6af58a
%endif #{with python2}
6af58a
%if 0%{?with_python3}
6af58a
LANG=en_US.UTF-8 py.test-%{python3_version}
6af58a
%endif
6af58a
6af58a
%if %{with python2}
6af58a
%files -n python2-netaddr
6af58a
%license COPYRIGHT LICENSE
6af58a
%doc AUTHORS CHANGELOG
6af58a
%doc README.md docs/html
6af58a
%{python2_sitelib}/*
6af58a
%{_bindir}/netaddr
6af58a
%endif #{with python2}
6af58a
6af58a
%if 0%{?with_python3}
6af58a
%files -n python3-netaddr
6af58a
%license COPYRIGHT
6af58a
%doc AUTHORS CHANGELOG
6af58a
%doc README.md docs/python3/html
6af58a
%{python3_sitelib}/*
6af58a
%{_bindir}/netaddr3
6af58a
%endif
6af58a
6af58a
%changelog
6af58a
* Mon Jul 09 2018 Petr Viktorin <pviktori@redhat.com> - 0.7.19-8
6af58a
- Don't build python2 subpackage on rhel>7
6af58a
  https://bugzilla.redhat.com/show_bug.cgi?id=1567153
6af58a
6af58a
* Mon Feb 19 2018 John Eckersberg <eck@redhat.com> - 0.7.19-7
6af58a
- Fix shebang mangling for python3 (RHBZ#1546800)
6af58a
6af58a
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.7.19-6
6af58a
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
6af58a
6af58a
* Fri Sep 29 2017 Troy Dawson <tdawson@redhat.com> - 0.7.19-5
6af58a
- Cleanup spec file conditionals
6af58a
6af58a
* Sat Aug 19 2017 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 0.7.19-4
6af58a
- Python 2 binary package renamed to python2-netaddr
6af58a
  See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3
6af58a
6af58a
* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.7.19-3
6af58a
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
6af58a
6af58a
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.7.19-2
6af58a
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
6af58a
6af58a
* Tue Jan 17 2017 John Eckersberg <eck@redhat.com> - 0.7.19-1
6af58a
- New upstream release 0.7.19 (RHBZ#1413231)
6af58a
6af58a
* Mon Dec 19 2016 Miro Hrončok <mhroncok@redhat.com> - 0.7.18-10
6af58a
- Rebuild for Python 3.6
6af58a
6af58a
* Sun Nov 13 2016 Orion Poplawski <orion@cora.nwra.com> - 0.7.18-9
6af58a
- Update description
6af58a
- Fix netaddr shebang (bug #1394046)
6af58a
6af58a
* Thu Nov 10 2016 Orion Poplawski <orion@cora.nwra.com> - 0.7.18-8
6af58a
- Use updated python macros
6af58a
- Use %%license
6af58a
6af58a
* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.7.18-7
6af58a
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages
6af58a
6af58a
* Tue Mar  8 2016 John Eckersberg <eck@redhat.com> - 0.7.18-6
6af58a
- Add provides for python2-netaddr (RHBZ#1282129)
6af58a
6af58a
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.7.18-5
6af58a
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
6af58a
6af58a
* Sun Nov 22 2015 Robert Kuska <rkuska@redhat.com> - 0.7.18-4
6af58a
- Rebuilt for https://fedoraproject.org/wiki/Changes/python3.5
6af58a
- Delete file which contains bundled pytest
6af58a
6af58a
* Wed Nov 11 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.7.18-3
6af58a
- Rebuilt for https://fedoraproject.org/wiki/Changes/python3.5
6af58a
6af58a
* Tue Nov 10 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.7.18-2
6af58a
- Rebuilt for https://fedoraproject.org/wiki/Changes/python3.5
6af58a
6af58a
* Fri Sep  4 2015 John Eckersberg <eck@redhat.com> - 0.7.18-1
6af58a
- New upstream release 0.7.18 (RHBZ#1259969)
6af58a
6af58a
* Tue Sep  1 2015 John Eckersberg <eck@redhat.com> - 0.7.17-1
6af58a
- New upstream release 0.7.17
6af58a
6af58a
* Mon Jun 29 2015 John Eckersberg <eck@redhat.com> - 0.7.15-1
6af58a
- New upstream release 0.7.15
6af58a
- Add separate source for tests, see https://github.com/drkjam/netaddr/issues/102
6af58a
- Add patch for broken assertion, see https://github.com/drkjam/netaddr/pull/103
6af58a
6af58a
* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.7.14-2
6af58a
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
6af58a
6af58a
* Wed Apr  1 2015 John Eckersberg <eck@redhat.com> - 0.7.14-1
6af58a
- New upstream release 0.7.14
6af58a
6af58a
* Wed Sep 17 2014 Haïkel Guémar <hguemar@fedoraproject.org> - 0.7.12-1
6af58a
- Upstream 0.7.12
6af58a
- Conditionalize python3 subpackages build on Fedora
6af58a
- Few spec cleanups
6af58a
6af58a
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.7.11-3
6af58a
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
6af58a
6af58a
* Thu May 29 2014 Bohuslav Kabrda <bkabrda@redhat.com> - 0.7.11-2
6af58a
- Rebuilt for https://fedoraproject.org/wiki/Changes/Python_3.4
6af58a
6af58a
* Mon Apr 21 2014 John Eckersberg <jeckersb@redhat.com> - 0.7.11-1
6af58a
- New upstream release 0.7.11
6af58a
- Enabled Python 3 support (bz1070357)
6af58a
6af58a
* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.7.5-7
6af58a
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
6af58a
6af58a
* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.7.5-6
6af58a
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
6af58a
6af58a
* Sat Jul 21 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.7.5-5
6af58a
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
6af58a
6af58a
* Sat Jan 14 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.7.5-4
6af58a
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
6af58a
6af58a
* Mon May 30 2011 Jakub Hrozek <jhrozek@redhat.com> - 0.7.5-3
6af58a
- Do not traceback on invalid IPNetwork input (upstream issues #2, #6, #5, #8)
6af58a
- Remove executable bit from documentation files to make rpmlint happy
6af58a
6af58a
* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.7.5-2
6af58a
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
6af58a
6af58a
* Tue Oct 05 2010 John Eckersberg <jeckersb@redhat.com> - 0.7.5-1
6af58a
- New upstream release 0.7.5
6af58a
- Updated summary and description to match upstream README
6af58a
- Updated URL and source to reflect upstream move to github
6af58a
6af58a
* Thu Jul 22 2010 David Malcolm <dmalcolm@redhat.com> - 0.7.4-2
6af58a
- Rebuilt for https://fedoraproject.org/wiki/Features/Python_2.7/MassRebuild
6af58a
6af58a
* Mon May 17 2010 John Eckersberg <jeckersb@redhat.com> - 0.7.4-1
6af58a
- New upstream release 0.7.4
6af58a
6af58a
* Wed Sep 30 2009 John Eckersberg <jeckersb@redhat.com> - 0.7.3-1
6af58a
- New upstream release 0.7.3
6af58a
6af58a
* Fri Aug 21 2009 John Eckersberg <jeckersb@redhat.com> - 0.7.2-1
6af58a
- New upstream release 0.7.2
6af58a
- Updated Summary and Description with new values provided by upstream
6af58a
6af58a
* Mon Aug 17 2009 John Eckersberg <jeckersb@redhat.com> - 0.7.1-1
6af58a
- New upstream release 0.7.1 fixes naming conflict with 'nash' by
6af58a
  renaming the netaddr shell to 'netaddr'
6af58a
6af58a
* Wed Aug 12 2009 John Eckersberg <jeckersb@redhat.com> - 0.7-1
6af58a
- Upstream release 0.7
6af58a
6af58a
* Sun Jul 26 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.6.3-3
6af58a
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
6af58a
6af58a
* Wed Jul 22 2009 John Eckersberg <jeckersb@redhat.com> - 0.6.3-2
6af58a
- Minor tweaks to spec file aligning with latest Fedora packaging guidelines
6af58a
- Enforce python 2.4 dependency as needed by netaddr >= 0.6.2
6af58a
- Drop BR on python-setuptool as it is not imported in setup.py
6af58a
- Drop BR on dos2unix use sed instead
6af58a
- Align description with that of delivered PKG-INFO
6af58a
- Rip out python shebangs
6af58a
- Add %%check section to enable tests
6af58a
- Thanks to Gareth Armstrong <gareth.armstrong@hp.com>
6af58a
6af58a
* Tue Jun 23 2009 John Eckersberg <jeckersb@redhat.com> - 0.6.3-1
6af58a
- New upstream bugfix release
6af58a
6af58a
* Mon Apr 13 2009 John Eckersberg <jeckersb@redhat.com> - 0.6.2-1
6af58a
- New upstream bugfix release
6af58a
6af58a
* Tue Apr 7 2009 John Eckersberg <jeckersb@redhat.com> - 0.6.1-1
6af58a
- New upstream bugfix release
6af58a
6af58a
* Thu Feb 26 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.6-3
6af58a
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild
6af58a
6af58a
* Wed Feb 18 2009 John Eckersberg <jeckersb@redhat.com> - 0.6-2
6af58a
- Add BuildDepends on dos2unix to clean up some upstream sources
6af58a
6af58a
* Wed Feb 18 2009 John Eckersberg <jeckersb@redhat.com> - 0.6-1
6af58a
- New upstream version
6af58a
6af58a
* Sat Nov 29 2008 Ignacio Vazquez-Abrams <ivazqueznet+rpm@gmail.com> - 0.5.2-2
6af58a
- Rebuild for Python 2.6
6af58a
6af58a
* Fri Oct 10 2008 John Eckersberg <jeckersb@redhat.com> - 0.5.2-1
6af58a
- New upstream version, bug fixes for 0.5.1
6af58a
6af58a
* Tue Sep 23 2008 John Eckersberg <jeckersb@redhat.com> - 0.5.1-1
6af58a
- New upstream version, bug fixes for 0.5
6af58a
6af58a
* Sun Sep 21 2008 John Eckersberg <jeckersb@redhat.com> - 0.5-1
6af58a
- New upstream version
6af58a
6af58a
* Mon Aug 11 2008 John Eckersberg <jeckersb@redhat.com> - 0.4-1
6af58a
- Initial packaging for Fedora
6af58a