Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-geoip2 for openSUSE:Factory 
checked in at 2021-07-16 22:12:48
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-geoip2 (Old)
 and      /work/SRC/openSUSE:Factory/.python-geoip2.new.2632 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-geoip2"

Fri Jul 16 22:12:48 2021 rev:14 rq:906185 version:4.2.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-geoip2/python-geoip2.changes      
2021-06-11 22:29:49.222041451 +0200
+++ /work/SRC/openSUSE:Factory/.python-geoip2.new.2632/python-geoip2.changes    
2021-07-16 22:13:20.810573831 +0200
@@ -1,0 +2,7 @@
+Tue Jul 13 09:58:29 UTC 2021 - John Paul Adrian Glaubitz 
<adrian.glaub...@suse.com>
+
+- Add patch to remove urllib3 and relax requests dependencies
+  + 0001-Removing-unused-urllib3-dependency-loosening-request.patch
+- Update BuildRequires and Requires from requirements.txt and setup.py
+
+-------------------------------------------------------------------

New:
----
  0001-Removing-unused-urllib3-dependency-loosening-request.patch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-geoip2.spec ++++++
--- /var/tmp/diff_new_pack.z0FiPx/_old  2021-07-16 22:13:21.266570609 +0200
+++ /var/tmp/diff_new_pack.z0FiPx/_new  2021-07-16 22:13:21.270570580 +0200
@@ -17,7 +17,6 @@
 
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
-%bcond_without test
 Name:           python-geoip2
 Version:        4.2.0
 Release:        0
@@ -26,8 +25,9 @@
 Group:          Development/Languages/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
+# 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
+Patch0:         0001-Removing-unused-urllib3-dependency-loosening-request.patch
 BuildRequires:  %{python_module setuptools}
-BuildRequires:  %{python_module urllib3 >= 1.25.2}
 BuildRequires:  fdupes
 BuildRequires:  python-rpm-macros
 # SECTION test requirements
@@ -35,12 +35,11 @@
 BuildRequires:  %{python_module maxminddb >= 2.0.0}
 BuildRequires:  %{python_module mocket >= 3.8.9}
 BuildRequires:  %{python_module python-magic >= 0.4.18}
-BuildRequires:  %{python_module requests >= 2.24.0}
+BuildRequires:  %{python_module requests >= 2.14.0}
 # /SECTION
-Requires:       python-aiohttp >= 3.6.2
+Recommends:     python-aiohttp >= 3.6.2
 Requires:       python-maxminddb >= 2.0.0
-Requires:       python-requests >= 2.24.0
-Requires:       python-urllib3 >= 1.25.2
+Requires:       python-requests >= 2.14.0
 BuildArch:      noarch
 %ifpython2
 Recommends:     python2-ipaddress
@@ -53,6 +52,7 @@
 
 %prep
 %setup -q -n geoip2-%{version}
+%patch0 -p1
 
 %build
 %python_build

++++++ 0001-Removing-unused-urllib3-dependency-loosening-request.patch ++++++
>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(-)

diff --git a/README.rst b/README.rst
index a17082e..8969781 100644
--- a/README.rst
+++ b/README.rst
@@ -19,6 +19,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:
diff --git a/geoip2/webservice.py b/geoip2/webservice.py
index 4b1fc15..6ab0e84 100644
--- a/geoip2/webservice.py
+++ b/geoip2/webservice.py
@@ -27,12 +27,21 @@
 
 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.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
diff --git a/requirements.txt b/requirements.txt
index af2c6ff..9c772e4 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1 @@
-aiohttp>=3.6.2,<4.0.0
 maxminddb>=2.0.0,<3.0.0
-requests>=2.24.0,<3.0.0
-urllib3>=1.25.2,<2.0.0
diff --git a/setup.cfg b/setup.cfg
index 9d48adc..c77568d 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -22,8 +22,9 @@
        pytest
        mocket
 commands = pytest tests
+usedevelop = true
+extras = aiohttp, requests
 
 [egg_info]
 tag_build = 
 tag_date = 0
-
diff --git a/setup.py b/setup.py
index 2194e8f..14b6d99 100644
--- a/setup.py
+++ b/setup.py
@@ -26,6 +26,11 @@
     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__,

Reply via email to