%bcond_with dotests

%global __tar /opt/freeware/bin/tar

%global py_minor 16

%global py_major 3.9

%global python_major python%{py_major}

%global pkgname idna 

%global meta_package python3-%{pkgname}

%global python3_sitearch %(%{python_major} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(0))")

Name:           %{python_major}-%{pkgname}
Version:        2.8 
Release:        2
Summary:        Internationalized Domain Names in Applications (IDNA) 
License:        BSD and Python and UnicodexPython 
URL:            https://pypi.python.org/pypi/%{pkgname}
Source0:        https://files.pythonhosted.org/packages/source/i/%{pkgname}/%{pkgname}-%{version}.tar.gz
BuildArch:      noarch


BuildRequires:  %{python_major}-devel >= %{py_major}.%{py_minor}
BuildRequires:  %{python_major}-setuptools >= 65.2.0
Requires:       %{python_major} >= %{py_major}.%{py_minor}


%description
A library to support the Internationalised Domain Names in Applications (IDNA) p
rotocol as specified in RFC 5891 <http://tools.ietf.org/html/rfc5891>. This vers
ion of the protocol is often referred to as "IDNA2008" and can produce different
 results from the earlier standard from 2003. The library is also intended to ac
t as a suitable drop-in replacement for the "encodings.idna" module that comes w
ith the Python standard library but currently only supports the older 2003 speci
fication.


%package -n %{meta_package}
Summary:       Meta-package for %{name}

Requires:      python3 >= %{py_major}.%{py_minor}
Requires:      %{name} = %{version}-%{release}

%description -n %{meta_package}
This is a Meta-package for %{name} package.


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


%build
export PATH=/opt/freeware/bin:$PATH
%{python_major} setup.py build


%install
[ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT}
%{python_major} setup.py install --root %{buildroot}


%check
%if %{with dotests}

#python3 -m venv python_venv
#. ./python_venv/bin/activate
#pip3 install pytest
#pip3 install hypothesis
#ulimit -d unlimited
#ulimit -n unlimited
#ulimit -m unlimited
# ulimit -f unlimited
#( python runtests.py -m 'full' -v || true )
#deactivate

%endif


%clean
[ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT}


%files
%defattr(-,root,system,-)
%license LICENSE.rst
%doc HISTORY.rst PKG-INFO README.rst 
%{python3_sitearch}/*

%files -n %{meta_package}
%defattr(-,root,system,-)

%changelog
* Thu Jan 12 2023 Sangeetha Bandi <sanbandi@in.ibm.com> -  2.8-2
- idna for python 3.9

* Thu Nov 14 2019 Baanu Tumma <btumma15@in.ibm.com> - 2.8-1
- First version for AIX, built with python3
