Accepting request 1128910 from Application:Geo

OBS-URL: https://build.opensuse.org/request/show/1128910
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-geoip2?expand=0&rev=21
This commit is contained in:
Ana Guerrero 2023-11-27 21:42:36 +00:00 committed by Git OBS Bridge
commit 3221d2aef0
5 changed files with 24 additions and 165 deletions

View File

@ -1,135 +0,0 @@
From a3152e9e77850aa741976e7e492ab98b672be536 Mon Sep 17 00:00:00 2001
From: "Dishy.Dev" <dishy@dev>
Date: Sun, 8 Nov 2020 08:15:57 +0000
Subject: [PATCH] Removing unused urllib3 dependency, loosening requests
version requirement and making aiohttp and requests optional installs
---
.github/workflows/lint.yml | 2 +-
README.rst | 3 +++
geoip2/webservice.py | 46 +++++++++++++++++++++++++++++---------
requirements.txt | 3 ---
setup.cfg | 2 ++
setup.py | 5 +++++
6 files changed, 46 insertions(+), 15 deletions(-)
Index: geoip2-4.6.0/README.rst
===================================================================
--- geoip2-4.6.0.orig/README.rst
+++ geoip2-4.6.0/README.rst
@@ -17,6 +17,9 @@ To install the ``geoip2`` module, type:
.. code-block:: bash
$ pip install geoip2
+ $ pip install geoip2[aiohttp]
+ $ pip install geoip2[requests]
+ $ pip install geoip2[all] # Install both requests and aiohttp support
If you are not able to use pip, you may also use easy_install from the
source directory:
Index: geoip2-4.6.0/geoip2/webservice.py
===================================================================
--- geoip2-4.6.0.orig/geoip2/webservice.py
+++ geoip2-4.6.0/geoip2/webservice.py
@@ -27,12 +27,21 @@ Requests to the web service are always m
import ipaddress
import json
+import sys
from typing import Any, Dict, cast, List, Optional, Type, Union
-import aiohttp
-import aiohttp.http
-import requests
-import requests.utils
+try:
+ import aiohttp
+ import aiohttp.http
+except ImportError:
+ pass
+
+try:
+ import requests
+ import requests.utils
+except ImportError:
+ pass
+
import geoip2
import geoip2.models
@@ -48,13 +57,28 @@ from geoip2.errors import (
from geoip2.models import City, Country, Insights
from geoip2.types import IPAddress
-_AIOHTTP_UA = (
- f"GeoIP2-Python-Client/{geoip2.__version__} {aiohttp.http.SERVER_SOFTWARE}"
-)
-
-_REQUEST_UA = (
- f"GeoIP2-Python-Client/{geoip2.__version__} {requests.utils.default_user_agent()}"
-)
+# If neither requests or aiohttp is installed then inform user how to
+# install them
+if "aiohttp" not in sys.modules and "requests" not in sys.modules:
+ raise ImportError(
+ """To enable geoip2.webservice,
+ install aiohttp or requests support.
+ pip install geoip2[aiohttp]
+ pip install geoip2[requests]
+ pip install geoip2[all]"""
+ )
+
+
+if "aiohttp" in sys.modules:
+ _AIOHTTP_UA = (
+ f"GeoIP2-Python-Client/{geoip2.__version__} {aiohttp.http.SERVER_SOFTWARE}"
+ )
+
+if "requests" in sys.modules:
+ _REQUEST_UA = (
+ f"GeoIP2-Python-Client/{geoip2.__version__}"
+ f" {requests.utils.default_user_agent()}"
+ )
class BaseClient: # pylint: disable=missing-class-docstring, too-few-public-methods
Index: geoip2-4.6.0/requirements.txt
===================================================================
--- geoip2-4.6.0.orig/requirements.txt
+++ geoip2-4.6.0/requirements.txt
@@ -1,4 +1 @@
-aiohttp>=3.6.2,<4.0.0
maxminddb>=2.2.0,<3.0.0
-requests>=2.24.0,<3.0.0
-urllib3>=1.25.2,<2.0.0
Index: geoip2-4.6.0/setup.cfg
===================================================================
--- geoip2-4.6.0.orig/setup.cfg
+++ geoip2-4.6.0/setup.cfg
@@ -26,8 +26,9 @@ deps =
pytest
mocket
commands = pytest tests
+usedevelop = true
+extras = aiohttp, requests
[egg_info]
tag_build =
tag_date = 0
-
Index: geoip2-4.6.0/setup.py
===================================================================
--- geoip2-4.6.0.orig/setup.py
+++ geoip2-4.6.0/setup.py
@@ -26,6 +26,11 @@ setup(
include_package_data=True,
python_requires=">=3.6",
install_requires=requirements,
+ extras_require={
+ "all": ["requests>=2.14.0,<3.0.0", "aiohttp>=3.6.2,<4.0.0"],
+ "requests": "requests>=2.14.0,<3.0.0",
+ "aiohttp": "aiohttp>=3.6.2,<4.0.0",
+ },
tests_require=["mocket>=3.8.9"],
test_suite="tests",
license=geoip2.__license__,

BIN
python-geoip2-4.6.0.tar.gz (Stored with Git LFS)

Binary file not shown.

BIN
python-geoip2-4.7.0.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -1,3 +1,12 @@
-------------------------------------------------------------------
Sun Nov 26 10:29:23 UTC 2023 - Dirk Müller <dmueller@suse.com>
- update to 4.7.0:
* drop support for python 3.6
- drop
0001-Removing-unused-urllib3-dependency-loosening-request.patch
(upstream)
------------------------------------------------------------------- -------------------------------------------------------------------
Fri Jun 9 11:46:37 UTC 2023 - ecsos <ecsos@opensuse.org> Fri Jun 9 11:46:37 UTC 2023 - ecsos <ecsos@opensuse.org>
@ -7,7 +16,7 @@ Fri Jun 9 11:46:37 UTC 2023 - ecsos <ecsos@opensuse.org>
Wed Feb 15 19:57:56 UTC 2023 - Dirk Müller <dmueller@suse.com> Wed Feb 15 19:57:56 UTC 2023 - Dirk Müller <dmueller@suse.com>
- fix tests on python 3.8 as well with newer python-mocket by skipping - fix tests on python 3.8 as well with newer python-mocket by skipping
the tests/test_webservice which need porting to new python-mocket the tests/test_webservice which need porting to new python-mocket
------------------------------------------------------------------- -------------------------------------------------------------------
Mon Jan 23 16:42:49 UTC 2023 - Daniel Garcia <daniel.garcia@suse.com> Mon Jan 23 16:42:49 UTC 2023 - Daniel Garcia <daniel.garcia@suse.com>
@ -28,7 +37,7 @@ Mon Jul 4 07:11:02 UTC 2022 - Paolo Stivanin <info@paolostivanin.com>
- The AddressNotFoundError class now has an ip_address attribute - The AddressNotFoundError class now has an ip_address attribute
with the lookup address and network property for the empty network with the lookup address and network property for the empty network
in the database containing the IP address. These are only available in the database containing the IP address. These are only available
when using a database, not the web service. when using a database, not the web service.
- Rebase 0001-Removing-unused-urllib3-dependency-loosening-request.patch - Rebase 0001-Removing-unused-urllib3-dependency-loosening-request.patch
------------------------------------------------------------------- -------------------------------------------------------------------
@ -79,7 +88,7 @@ Fri May 14 16:10:51 UTC 2021 - Sebastian Wagner <sebix+novell.com@sebix.at>
Thu Dec 10 01:27:35 UTC 2020 - Benjamin Greiner <code@bnavigator.de> Thu Dec 10 01:27:35 UTC 2020 - Benjamin Greiner <code@bnavigator.de>
- replace deprecated setup.py test call by pyunittest macro so that - replace deprecated setup.py test call by pyunittest macro so that
pip does not try to download stuff pip does not try to download stuff
------------------------------------------------------------------- -------------------------------------------------------------------
Wed Nov 4 15:56:32 UTC 2020 - Paolo Stivanin <info@paolostivanin.com> Wed Nov 4 15:56:32 UTC 2020 - Paolo Stivanin <info@paolostivanin.com>
@ -88,7 +97,7 @@ Wed Nov 4 15:56:32 UTC 2020 - Paolo Stivanin <info@paolostivanin.com>
* Added the is_residential_proxy attribute to geoip2.model.AnonymousIP * Added the is_residential_proxy attribute to geoip2.model.AnonymousIP
and geoip2.record.Traits. and geoip2.record.Traits.
* HTTPError now provides the decoded response content in the * HTTPError now provides the decoded response content in the
decoded_content attribute. decoded_content attribute.
------------------------------------------------------------------- -------------------------------------------------------------------
Tue Jul 28 18:55:20 UTC 2020 - Sebastian Wagner <sebix+novell.com@sebix.at> Tue Jul 28 18:55:20 UTC 2020 - Sebastian Wagner <sebix+novell.com@sebix.at>
@ -121,7 +130,7 @@ Thu Jul 23 20:21:35 UTC 2020 - Sebastian Wagner <sebix+novell.com@sebix.at>
------------------------------------------------------------------- -------------------------------------------------------------------
Thu Apr 16 17:45:00 UTC 2020 - Marcus Rueckert <mrueckert@suse.de> Thu Apr 16 17:45:00 UTC 2020 - Marcus Rueckert <mrueckert@suse.de>
- match buildrequires to requirements.txt - match buildrequires to requirements.txt
------------------------------------------------------------------- -------------------------------------------------------------------
Wed Mar 4 07:46:22 UTC 2020 - Paolo Stivanin <info@paolostivanin.com> Wed Mar 4 07:46:22 UTC 2020 - Paolo Stivanin <info@paolostivanin.com>

View File

@ -18,26 +18,22 @@
%{?sle15_python_module_pythons} %{?sle15_python_module_pythons}
Name: python-geoip2 Name: python-geoip2
Version: 4.6.0 Version: 4.7.0
Release: 0 Release: 0
Summary: MaxMind GeoIP2 Python API Summary: MaxMind GeoIP2 Python API
License: Apache-2.0 License: Apache-2.0
Group: Development/Languages/Python Group: Development/Languages/Python
URL: https://github.com/maxmind/GeoIP2-python URL: https://github.com/maxmind/GeoIP2-python
Source: https://files.pythonhosted.org/packages/source/g/geoip2/geoip2-%{version}.tar.gz#/%{name}-%{version}.tar.gz Source: https://files.pythonhosted.org/packages/source/g/geoip2/geoip2-%{version}.tar.gz#/%{name}-%{version}.tar.gz
# PATCH-FIX-OPENSUSE 0001-Removing-unused-urllib3-dependency-loosening-request.patch -- Removing unused urllib3 dependency loosening requests version based on https://github.com/maxmind/GeoIP2-python/pull/104.patch BuildRequires: %{python_module base >= 3.7}
Patch0: 0001-Removing-unused-urllib3-dependency-loosening-request.patch
BuildRequires: %{python_module setuptools} BuildRequires: %{python_module setuptools}
BuildRequires: fdupes BuildRequires: fdupes
BuildRequires: python-rpm-macros BuildRequires: python-rpm-macros
# SECTION test requirements # SECTION test requirements
BuildRequires: %{python_module aiohttp >= 3.6.2} BuildRequires: %{python_module aiohttp >= 3.6.2}
BuildRequires: %{python_module maxminddb >= 2.2.0} BuildRequires: %{python_module maxminddb >= 2.3.0}
# mocket currently does not work with 3.11. See these issues: BuildRequires: %{python_module mocket >= 3.11.0}
# gh#maxmind/GeoIP2-python@3b0dbb1eb990 BuildRequires: %{python_module pytest}
# gh#mindflayer/python-mocket#181
# gh#benoitc/http-parser#95
BuildRequires: %{python_module mocket >= 3.8.9 if %python-base < 3.11}
BuildRequires: %{python_module python-magic >= 0.4.18} BuildRequires: %{python_module python-magic >= 0.4.18}
BuildRequires: %{python_module requests >= 2.14.0} BuildRequires: %{python_module requests >= 2.14.0}
# /SECTION # /SECTION
@ -45,9 +41,6 @@ Recommends: python-aiohttp >= 3.6.2
Requires: python-maxminddb >= 2.0.0 Requires: python-maxminddb >= 2.0.0
Requires: python-requests >= 2.14.0 Requires: python-requests >= 2.14.0
BuildArch: noarch BuildArch: noarch
%ifpython2
Recommends: python2-ipaddress
%endif
%python_subpackages %python_subpackages
%description %description
@ -56,7 +49,6 @@ The API also works with MaxMind's free GeoLite2 databases.
%prep %prep
%setup -q -n geoip2-%{version} %setup -q -n geoip2-%{version}
%patch0 -p1
%build %build
%python_build %python_build
@ -66,15 +58,8 @@ The API also works with MaxMind's free GeoLite2 databases.
%python_expand %fdupes %{buildroot}%{$python_sitelib} %python_expand %fdupes %{buildroot}%{$python_sitelib}
%check %check
python38_tests="tests/models_test.py tests/database_test.py" rm -v tests/webservice_test.py
python39_tests=$python38_tests %pytest
python310_tests=$python38_tests
# mocket currently does not work with 3.11. See these issues:
# gh#maxmind/GeoIP2-python@3b0dbb1eb990
# gh#mindflayer/python-mocket#181
# gh#benoitc/http-parser#95
python311_tests="tests/models_test.py tests/database_test.py"
%pyunittest -v ${$python_tests}
%files %{python_files} %files %{python_files}
%license LICENSE %license LICENSE