Blame SOURCES/0001-Use-importlib.resources-in-python-3.7.patch

rdobuilder c7f380
From e1392feda59ed0fdcf10934d57f833c64e99c19a Mon Sep 17 00:00:00 2001
rdobuilder c7f380
From: Alfredo Moralejo <amoralej@redhat.com>
rdobuilder c7f380
Date: Thu, 30 Sep 2021 09:39:36 +0200
rdobuilder c7f380
Subject: [PATCH] Use importlib.resources in python >= 3.7
rdobuilder c7f380
rdobuilder c7f380
importlib.resources was added to python standard library since python 3.7
rdobuilder c7f380
[1]. This patch is implementing conditional to use it instead of the
rdobuilder c7f380
importlib_resources backport when using python 3.7 or newer.
rdobuilder c7f380
rdobuilder c7f380
[1] https://docs.python.org/3/whatsnew/3.7.html
rdobuilder c7f380
---
rdobuilder c7f380
 setup.cfg                        | 2 +-
rdobuilder c7f380
 src/saml2/sigver.py              | 7 ++++++-
rdobuilder c7f380
 src/saml2/xml/schema/__init__.py | 7 ++++++-
rdobuilder c7f380
 3 files changed, 13 insertions(+), 3 deletions(-)
rdobuilder c7f380
rdobuilder c7f380
diff --git a/setup.cfg b/setup.cfg
rdobuilder c7f380
index e04c5520..41ccdd7f 100644
rdobuilder c7f380
--- a/setup.cfg
rdobuilder c7f380
+++ b/setup.cfg
rdobuilder c7f380
@@ -53,7 +53,7 @@ install_requires =
rdobuilder c7f380
     pytz
rdobuilder c7f380
     requests >= 1.0.0
rdobuilder c7f380
     six
rdobuilder c7f380
-    importlib_resources
rdobuilder c7f380
+    importlib_resources;python_version<'3.7'
rdobuilder c7f380
     xmlschema >= 1.2.1
rdobuilder c7f380
 
rdobuilder c7f380
 
rdobuilder c7f380
diff --git a/src/saml2/sigver.py b/src/saml2/sigver.py
rdobuilder c7f380
index 973d6245..c9c66b13 100644
rdobuilder c7f380
--- a/src/saml2/sigver.py
rdobuilder c7f380
+++ b/src/saml2/sigver.py
rdobuilder c7f380
@@ -9,12 +9,12 @@ import logging
rdobuilder c7f380
 import os
rdobuilder c7f380
 import re
rdobuilder c7f380
 import six
rdobuilder c7f380
+import sys
rdobuilder c7f380
 from uuid import uuid4 as gen_random_key
rdobuilder c7f380
 from time import mktime
rdobuilder c7f380
 from tempfile import NamedTemporaryFile
rdobuilder c7f380
 from subprocess import Popen
rdobuilder c7f380
 from subprocess import PIPE
rdobuilder c7f380
-from importlib_resources import path as _resource_path
rdobuilder c7f380
 
rdobuilder c7f380
 from OpenSSL import crypto
rdobuilder c7f380
 
rdobuilder c7f380
@@ -59,6 +59,11 @@ from saml2.xmlenc import EncryptedData
rdobuilder c7f380
 from saml2.xml.schema import node_to_schema
rdobuilder c7f380
 from saml2.xml.schema import XMLSchemaError
rdobuilder c7f380
 
rdobuilder c7f380
+# importlib.resources was introduced in python 3.7
rdobuilder c7f380
+if sys.version_info[:2] >= (3, 7):
rdobuilder c7f380
+    from importlib.resources import path as _resource_path
rdobuilder c7f380
+else:
rdobuilder c7f380
+    from importlib_resources import path as _resource_path
rdobuilder c7f380
 
rdobuilder c7f380
 logger = logging.getLogger(__name__)
rdobuilder c7f380
 
rdobuilder c7f380
diff --git a/src/saml2/xml/schema/__init__.py b/src/saml2/xml/schema/__init__.py
rdobuilder c7f380
index 56e08b1c..ce38b807 100644
rdobuilder c7f380
--- a/src/saml2/xml/schema/__init__.py
rdobuilder c7f380
+++ b/src/saml2/xml/schema/__init__.py
rdobuilder c7f380
@@ -1,10 +1,15 @@
rdobuilder c7f380
-from importlib_resources import path as _resource_path
rdobuilder c7f380
+import sys
rdobuilder c7f380
 
rdobuilder c7f380
 from xmlschema import XMLSchema as _XMLSchema
rdobuilder c7f380
 from xmlschema.exceptions import XMLSchemaException as XMLSchemaError
rdobuilder c7f380
 
rdobuilder c7f380
 import saml2.data.schemas as _data_schemas
rdobuilder c7f380
 
rdobuilder c7f380
+# importlib.resources was introduced in python 3.7
rdobuilder c7f380
+if sys.version_info[:2] >= (3, 7):
rdobuilder c7f380
+    from importlib.resources import path as _resource_path
rdobuilder c7f380
+else:
rdobuilder c7f380
+    from importlib_resources import path as _resource_path
rdobuilder c7f380
 
rdobuilder c7f380
 def _create_xml_schema_validator(source, **kwargs):
rdobuilder c7f380
     kwargs = {
rdobuilder c7f380
-- 
rdobuilder c7f380
2.26.3
rdobuilder c7f380