14
0
forked from pool/python-zeep

- Add patch support-new-httpx.patch:

* Support argument changes with httpx 0.28.0+.

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-zeep?expand=0&rev=22
This commit is contained in:
2024-12-19 05:33:09 +00:00
committed by Git OBS Bridge
parent ac67ad7d26
commit 8699849be9
3 changed files with 140 additions and 2 deletions

View File

@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Thu Dec 19 05:32:24 UTC 2024 - Steve Kowalik <steven.kowalik@suse.com>
- Add patch support-new-httpx.patch:
* Support argument changes with httpx 0.28.0+.
-------------------------------------------------------------------
Tue Nov 12 10:48:13 UTC 2024 - Nico Krapp <nico.krapp@suse.com>

View File

@@ -25,13 +25,14 @@ URL: http://docs.python-zeep.org
Source: https://files.pythonhosted.org/packages/source/z/zeep/zeep-%{version}.tar.gz
# PATCH-FIX-OPENSUSE xfail tests that require network access
Patch0: xfail-network-tests.patch
# PATCH-FIX-UPSTREAM gh#mvantellingen/python-zeep#1447
Patch1: support-new-httpx.patch
BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module wheel}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-attrs >= 17.2.0
Requires: python-cached-property >= 1.3.0
Requires: python-isodate >= 0.5.4
Requires: python-lxml >= 4.6.0
Requires: python-platformdirs >= 1.4.0
@@ -39,6 +40,8 @@ Requires: python-pytz
Requires: python-requests >= 2.7.0
Requires: python-requests-file >= 1.5.1
Requires: python-requests-toolbelt >= 0.7.1
Recommends: python-httpx >= 0.15.0
Recommends: python-packaging
Recommends: python-xmlsec >= 0.6.1
BuildArch: noarch
# SECTION test requirements
@@ -46,10 +49,10 @@ BuildRequires: %{python_module platformdirs >= 1.4.0}
BuildRequires: %{python_module aiohttp >= 1.0}
BuildRequires: %{python_module aioresponses >= 0.4.1}
BuildRequires: %{python_module attrs >= 17.2.0}
BuildRequires: %{python_module cached-property >= 1.3.0}
BuildRequires: %{python_module freezegun >= 0.3.15}
BuildRequires: %{python_module isodate >= 0.5.4}
BuildRequires: %{python_module lxml >= 4.6.0}
BuildRequires: %{python_module packaging}
BuildRequires: %{python_module pretend >= 1.0.9}
BuildRequires: %{python_module pytest >= 6.0.1}
BuildRequires: %{python_module pytest-asyncio}

129
support-new-httpx.patch Normal file
View File

@@ -0,0 +1,129 @@
From 4e2568574271e5e37de5e5c86e4bb12a5e661c6b Mon Sep 17 00:00:00 2001
From: aschollmeier-gcmlp <aschollmeier@gcmlp.com>
Date: Wed, 4 Dec 2024 16:34:22 -0600
Subject: [PATCH 1/3] Update proxy argument in httpx Client/AsyncClient
Ref: https://github.com/encode/httpx/blob/master/CHANGELOG.md#0260-20th-december-2023
---
src/zeep/transports.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/zeep/transports.py b/src/zeep/transports.py
index 2a1ee8bd..0cbb05f2 100644
--- a/src/zeep/transports.py
+++ b/src/zeep/transports.py
@@ -183,15 +183,17 @@ def __init__(
self._close_session = False
self.cache = cache
+ proxy_kwarg_name = "proxy" if httpx.__version__ >= "0.26.0" else "proxies"
+ proxy_kwargs = {proxy_kwarg_name: proxy}
self.wsdl_client = wsdl_client or httpx.Client(
verify=verify_ssl,
- proxies=proxy,
timeout=timeout,
+ **proxy_kwargs,
)
self.client = client or httpx.AsyncClient(
verify=verify_ssl,
- proxies=proxy,
timeout=operation_timeout,
+ **proxy_kwargs,
)
self.logger = logging.getLogger(__name__)
From 411ea4ef7ec4d160dd2cb2d29288c9d34466f286 Mon Sep 17 00:00:00 2001
From: aschollmeier-gcmlp <aschollmeier@gcmlp.com>
Date: Sat, 14 Dec 2024 09:34:53 -0600
Subject: [PATCH 2/3] Correct httpx version comparison
---
pyproject.toml | 5 ++++-
src/zeep/transports.py | 19 +++++++++++++++----
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/pyproject.toml b/pyproject.toml
index c151100a..414e83c2 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -53,7 +53,10 @@ test = [
"flake8-debugger==4.1.2",
"flake8-imports==0.1.1",
]
-async = ["httpx>=0.15.0"]
+async = [
+ "httpx>=0.15.0",
+ "packaging",
+]
xmlsec = ["xmlsec>=0.6.1"]
[build-system]
diff --git a/src/zeep/transports.py b/src/zeep/transports.py
index 0cbb05f2..f1b00565 100644
--- a/src/zeep/transports.py
+++ b/src/zeep/transports.py
@@ -16,6 +16,15 @@
except ImportError:
httpx = None
+try:
+ from packaging.version import Version
+ if Version(httpx.__version__) >= Version("0.26.0"):
+ HTTPX_PROXY_KWARG_NAME = "proxy"
+ else:
+ HTTPX_PROXY_KWARG_NAME = "proxies"
+except ImportError:
+ Version = None
+ HTTPX_PROXY_KWARG_NAME = None
__all__ = ["AsyncTransport", "Transport"]
@@ -178,13 +187,15 @@ def __init__(
verify_ssl=True,
proxy=None,
):
- if httpx is None:
- raise RuntimeError("The AsyncTransport is based on the httpx module")
+ if httpx is None or HTTPX_PROXY_KWARG_NAME is None:
+ raise RuntimeError(
+ "To use AsyncTransport, install zeep with the async extras, "
+ "e.g., `pip install zeep[async]`"
+ )
self._close_session = False
self.cache = cache
- proxy_kwarg_name = "proxy" if httpx.__version__ >= "0.26.0" else "proxies"
- proxy_kwargs = {proxy_kwarg_name: proxy}
+ proxy_kwargs = {HTTPX_PROXY_KWARG_NAME: proxy}
self.wsdl_client = wsdl_client or httpx.Client(
verify=verify_ssl,
timeout=timeout,
From c20b7ba21d815377cb5d5095eb9e9f5918fb678d Mon Sep 17 00:00:00 2001
From: aschollmeier-gcmlp <aschollmeier@gcmlp.com>
Date: Sat, 14 Dec 2024 10:00:17 -0600
Subject: [PATCH 3/3] Avoid potential AttributeError in httpx version check
---
src/zeep/transports.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/zeep/transports.py b/src/zeep/transports.py
index f1b00565..d2136373 100644
--- a/src/zeep/transports.py
+++ b/src/zeep/transports.py
@@ -18,10 +18,10 @@
try:
from packaging.version import Version
- if Version(httpx.__version__) >= Version("0.26.0"):
- HTTPX_PROXY_KWARG_NAME = "proxy"
- else:
+ if httpx is None or Version(httpx.__version__) < Version("0.26.0"):
HTTPX_PROXY_KWARG_NAME = "proxies"
+ else:
+ HTTPX_PROXY_KWARG_NAME = "proxy"
except ImportError:
Version = None
HTTPX_PROXY_KWARG_NAME = None