Name:           python-netaddr
Version:        0.7.19
Release:        16
Summary:        A pure Python network address representation and manipulation library

License:        BSD
URL:            http://github.com/drkjam/netaddr
Source0:        https://pypi.python.org/packages/source/n/netaddr/netaddr-%{version}.tar.gz

BuildArch:      noarch
BuildRequires:  python2-devel python2-setuptools python2-sphinx python2-pytest
BuildRequires:  python3-devel python3-setuptools python3-sphinx python3-pytest

Patch0001:      0001-PEP-479-return-instead-of-raise-StopIteration.patch
Patch0002:      0001-PKG-INFO-metadata-generation-seems-to-be-broken-list.patch

%description
A network address manipulation library for Python
Provides support for:
Layer 3 addresses
 * dealing with various ranges formats (CIDR, arbitrary ranges and globs, nmap)
 * parsing a large variety of different formats and notations
Layer 2 addresses
 * generating derived IPv6 addresses



%package -n python2-netaddr
Summary: Netaddr for 2 matching expressions
%{?python_provide:%python_provide python2-netaddr}

%description -n python2-netaddr
Based on Python2 network address representation and operation library Package

%package -n python3-netaddr
Summary: A pure Python network address representation and manipulation library
%{?python_provide:%python_provide python3-netaddr}

%description -n python3-netaddr
Based on Python3 network address representation and operation library Package




%prep
%autosetup -n netaddr-%{version} -p1

sed -i 's/\r//' netaddr/*.py netaddr/ip/*.py netaddr/eui/*.idx
find netaddr -name "*.py" | xargs sed -i -e '1 {/^#!\//d}'
sed -i -e '1s,/usr/bin/env python,%{__python2} %{?py_shbang_opts},' netaddr/tools/netaddr

%build
%py2_build
%py3_build

#docs
cd docs
PYTHONPATH='../' sphinx-build -b html -d build/doctrees source html
PYTHONPATH='../' sphinx-build-%{python3_version} -b html -d build/doctrees source python3/html


%install
%py3_install
mv %{buildroot}%{_bindir}/netaddr %{buildroot}%{_bindir}/netaddr3
%py2_install

%files -n python2-netaddr
%license COPYRIGHT LICENSE
%doc AUTHORS CHANGELOG README.md docs/html
%{python2_sitelib}/*
%{_bindir}/netaddr

%files -n python3-netaddr
%exclude %{python3_sitelib}/netaddr/eui/oui.txt
%license COPYRIGHT
%doc AUTHORS CHANGELOG README.md docs/python3/html
%{python3_sitelib}/*
%{_bindir}/netaddr3

%changelog
* Fri Dec 22 2023 liubo <liubo1@xfusion.com> - 0.7.19-16
- PKG-INFO metadata generation seems to be broken (lists maintainer as author on PyPI - mutually exclusive?)

* Tue Jun 13 2023 zhangpan<zhangpan103@h-partners.com> - 0.7.19-15
- delete taboo words

* Fri Feb 14 2020 gulining<gulining1@huawei.com> - 0.7.19-14
- Package init
