Accepting request 906077 from home:glaubitz:branches:Application:Geo
- 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 OBS-URL: https://build.opensuse.org/request/show/906077 OBS-URL: https://build.opensuse.org/package/show/Application:Geo/python-geoip2?expand=0&rev=19
This commit is contained in:
parent
b17ec08559
commit
30d8190b59
120
0001-Removing-unused-urllib3-dependency-loosening-request.patch
Normal file
120
0001-Removing-unused-urllib3-dependency-loosening-request.patch
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
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
|
||||||
|
|
||||||
|
diff -Nru geoip2-4.2.0.orig/geoip2/webservice.py geoip2-4.2.0/geoip2/webservice.py
|
||||||
|
--- geoip2-4.2.0.orig/geoip2/webservice.py 2020-12-10 18:47:00.000000000 +0100
|
||||||
|
+++ geoip2-4.2.0/geoip2/webservice.py 2021-07-13 11:55:41.952344432 +0200
|
||||||
|
@@ -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 -Nru geoip2-4.2.0.orig/README.rst geoip2-4.2.0/README.rst
|
||||||
|
--- geoip2-4.2.0.orig/README.rst 2021-05-12 18:10:23.000000000 +0200
|
||||||
|
+++ geoip2-4.2.0/README.rst 2021-07-13 11:55:41.952344432 +0200
|
||||||
|
@@ -19,6 +19,9 @@
|
||||||
|
.. 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 -Nru geoip2-4.2.0.orig/requirements.txt geoip2-4.2.0/requirements.txt
|
||||||
|
--- geoip2-4.2.0.orig/requirements.txt 2020-07-28 19:27:21.000000000 +0200
|
||||||
|
+++ geoip2-4.2.0/requirements.txt 2021-07-13 11:55:41.952344432 +0200
|
||||||
|
@@ -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 -Nru geoip2-4.2.0.orig/setup.cfg geoip2-4.2.0/setup.cfg
|
||||||
|
--- geoip2-4.2.0.orig/setup.cfg 2021-05-12 18:12:14.163335000 +0200
|
||||||
|
+++ geoip2-4.2.0/setup.cfg 2021-07-13 11:57:15.737814093 +0200
|
||||||
|
@@ -22,8 +22,9 @@
|
||||||
|
pytest
|
||||||
|
mocket
|
||||||
|
commands = pytest tests
|
||||||
|
+usedevelop = true
|
||||||
|
+extras = aiohttp, requests
|
||||||
|
|
||||||
|
[egg_info]
|
||||||
|
tag_build =
|
||||||
|
tag_date = 0
|
||||||
|
-
|
||||||
|
diff -Nru geoip2-4.2.0.orig/setup.py geoip2-4.2.0/setup.py
|
||||||
|
--- geoip2-4.2.0.orig/setup.py 2020-09-25 17:00:20.000000000 +0200
|
||||||
|
+++ geoip2-4.2.0/setup.py 2021-07-13 11:55:41.952344432 +0200
|
||||||
|
@@ -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__,
|
@ -1,3 +1,10 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Tue Jul 13 09:58:29 UTC 2021 - John Paul Adrian Glaubitz <adrian.glaubitz@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
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Fri May 14 16:10:51 UTC 2021 - Sebastian Wagner <sebix+novell.com@sebix.at>
|
Fri May 14 16:10:51 UTC 2021 - Sebastian Wagner <sebix+novell.com@sebix.at>
|
||||||
|
|
||||||
|
@ -26,8 +26,8 @@ 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
|
||||||
|
Patch0: 0001-Removing-unused-urllib3-dependency-loosening-request.patch
|
||||||
BuildRequires: %{python_module setuptools}
|
BuildRequires: %{python_module setuptools}
|
||||||
BuildRequires: %{python_module urllib3 >= 1.25.2}
|
|
||||||
BuildRequires: fdupes
|
BuildRequires: fdupes
|
||||||
BuildRequires: python-rpm-macros
|
BuildRequires: python-rpm-macros
|
||||||
# SECTION test requirements
|
# SECTION test requirements
|
||||||
@ -35,12 +35,11 @@ BuildRequires: %{python_module aiohttp >= 3.6.2}
|
|||||||
BuildRequires: %{python_module maxminddb >= 2.0.0}
|
BuildRequires: %{python_module maxminddb >= 2.0.0}
|
||||||
BuildRequires: %{python_module mocket >= 3.8.9}
|
BuildRequires: %{python_module mocket >= 3.8.9}
|
||||||
BuildRequires: %{python_module python-magic >= 0.4.18}
|
BuildRequires: %{python_module python-magic >= 0.4.18}
|
||||||
BuildRequires: %{python_module requests >= 2.24.0}
|
BuildRequires: %{python_module requests >= 2.14.0}
|
||||||
# /SECTION
|
# /SECTION
|
||||||
Requires: python-aiohttp >= 3.6.2
|
Requires: python-aiohttp >= 3.6.2
|
||||||
Requires: python-maxminddb >= 2.0.0
|
Requires: python-maxminddb >= 2.0.0
|
||||||
Requires: python-requests >= 2.24.0
|
Requires: python-requests >= 2.14.0
|
||||||
Requires: python-urllib3 >= 1.25.2
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
%ifpython2
|
%ifpython2
|
||||||
Recommends: python2-ipaddress
|
Recommends: python2-ipaddress
|
||||||
@ -53,6 +52,7 @@ 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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user