Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:ALP:Source:Standard:Core:0.1
python-geoip2
0001-Removing-unused-urllib3-dependency-looseni...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-Removing-unused-urllib3-dependency-loosening-request.patch of Package python-geoip2
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__,
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor