#
# spec file for package python-maxminddb
#
# Copyright (c) 2020 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%bcond_without python2
%define skip_python2 1
Name:           python-maxminddb
Version:        2.0.3
Release:        1.4
Summary:        Reader for the MaxMind DB format
License:        Apache-2.0
URL:            http://www.maxmind.com/
Source:         https://files.pythonhosted.org/packages/source/m/maxminddb/maxminddb-%{version}.tar.gz
BuildRequires:  %{python_module devel >= 3.6}
BuildRequires:  %{python_module setuptools}
BuildRequires:  fdupes
BuildRequires:  libmaxminddb-devel
BuildRequires:  python-rpm-macros
%if %{with python2}
BuildRequires:  python-ipaddress
%endif
# SECTION test requirements
BuildRequires:  %{python_module mock}
BuildRequires:  %{python_module pytest}
# /SECTION
%python_subpackages

%description
This is a Python module for reading MaxMind DB files. The module includes both
a pure Python reader and an optional C extension.

MaxMind DB is a binary file format that stores data indexed by IP address
subnets (IPv4 or IPv6).

%prep
%setup -q -n maxminddb-%{version}
sed -i '/nose/d' setup.py

%build
export CFLAGS="%{optflags}"
%python_build

%install
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitearch}

%check
%pytest_arch

%files %{python_files}
%license LICENSE
%doc README.rst
%{python_sitearch}/*

%changelog
* Sun Nov  1 2020 Sebastian Wagner <sebix+novell.com@sebix.at>
- update to version 2.0.3:
  - The 2.0.0 release unintentionally required Python to be compiled with
    ``mmap`` support for the module to work. ``mmap`` is now optional
    again. Reported by john-heasman-cg. GitHub #76.
* Sun Aug 16 2020 John Vandenberg <jayvdb@gmail.com>
- Replace nose with pytest
* Tue Jul 28 2020 Sebastian Wagner <sebix+novell.com@sebix.at>
- update to version 2.0.2:
  - Added ``py.typed`` file per PEP 561. Reported by Árni Már Jónsson.
* Thu Jul 23 2020 Sebastian Wagner <sebix+novell.com@sebix.at>
- update to version 2.0.1:
  - Fix minimum required python version in ``setup.py``. Pull request by
  Boros Gábor. GitHub #69 & #70.
- update to version 2.0.0:
  - IMPORTANT: Python 3.6 or greater is required. If you are using an older
  version, please use a 1.x.x release.
  - Type hints have been added.
* Thu May  7 2020 Sebastian Wagner <sebix+novell.com@sebix.at>
- update to version 1.5.4:
  - 1.5.3 was missing a test database. This release adds the test file.
  There are no other changes. Reported by Lumír 'Frenzy' Balhar. GitHub #60.
- update to version 1.5.3:
  - Fix a segfault when decoding a database with a corrupt data section.
  Reported by Robert Scott. GitHub #58.
* Sat Mar 14 2020 Tomáš Chvátal <tchvatal@suse.com>
- Fix build without python2
* Wed Jan  1 2020 Sebastian Wagner <sebix+novell.com@sebix.at>
- update to version 1.5.2:
  - Minor performance improvements in the pure Python reader.
* Sun Oct  6 2019 Sebastian Wagner <sebix+novell.com@sebix.at>
- update to version 1.5.1:
  - Fix a possible segfault due to not correctly incrementing the reference
    on a returned object.
- update to version 1.5.0:
  - Python 3.3 and 3.4 are no longer supported.
  - The extension source directory was moved to prevent an ``ImportWarning``
    when importing the module on Python 2 with ``-Wdefault`` set. Reported by
    David Szotten and Craig de Stigter. GitHub #31.
  - The ``get`` method now accepts ``ipaddress.IPv4Address`` and
    ``ipaddress.IPv6Address`` objects in addition to strings.  This works with
    both the pure Python implementation as well as the extension. Based on a
    pull request #48 by Eric Pruitt. GitHub #50.
  - A new method, ``get_with_prefix_len``, was added. This method returns a
    tuple containing the record and the prefix length.
* Wed Aug 29 2018 tchvatal@suse.com
- Update to 1.4.1:
  * Fixes for python 3.7
* Sun May 27 2018 sebix+novell.com@sebix.at
- update to version 1.4.0:
  * IMPORTANT: Previously, the pure Python reader would allow
  `ipaddress.IPv4Address` and `ipaddress.IPv6Address` objects when calling
  `.get()`. This would fail with the C extension. The fact that these objects
  worked at all was an implementation detail and has varied with different
  releases. This release makes the pure Python implementation consistent
  with the extension. A `TypeError` will now be thrown if you attempt to
  use these types with either the pure Python implementation or the
  extension. The IP address passed to `.get()` should be a string type.
  * Fix issue where incorrect size was used when unpacking some types with the
  pure Python reader. Reported by Lee Symes. GitHub #30.
  * You may now pass in the database via a file descriptor rather than a file
  name when creating a new ``maxminddb.Reader`` object using ``MODE_FD``.
  This will read the database from the file descriptor into memory. Pull
  request by nkinkade. GitHub #33.
* Thu May 25 2017 sebix+novell.com@sebix.at
- initial package