summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kanakarakis <ivan.kanak@gmail.com>2021-10-19 12:20:48 +0300
committerGitHub <noreply@github.com>2021-10-19 12:20:48 +0300
commitcfcaf9c14e7da065144abc89cef36ee24435d18e (patch)
tree1d282ecda9fc520ca673c9764ae8908789f3af76
parentf12ade09aa89211c42b7dc6ed94728f8aa69cffb (diff)
parente1392feda59ed0fdcf10934d57f833c64e99c19a (diff)
downloadpysaml2-cfcaf9c14e7da065144abc89cef36ee24435d18e.tar.gz
Merge pull request #828 from amoralej/master
Use importlib.resources in python >= 3.7
-rw-r--r--setup.cfg2
-rw-r--r--src/saml2/sigver.py7
-rw-r--r--src/saml2/xml/schema/__init__.py7
3 files changed, 13 insertions, 3 deletions
diff --git a/setup.cfg b/setup.cfg
index e04c5520..41ccdd7f 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -53,7 +53,7 @@ install_requires =
pytz
requests >= 1.0.0
six
- importlib_resources
+ importlib_resources;python_version<'3.7'
xmlschema >= 1.2.1
diff --git a/src/saml2/sigver.py b/src/saml2/sigver.py
index 973d6245..c9c66b13 100644
--- a/src/saml2/sigver.py
+++ b/src/saml2/sigver.py
@@ -9,12 +9,12 @@ import logging
import os
import re
import six
+import sys
from uuid import uuid4 as gen_random_key
from time import mktime
from tempfile import NamedTemporaryFile
from subprocess import Popen
from subprocess import PIPE
-from importlib_resources import path as _resource_path
from OpenSSL import crypto
@@ -59,6 +59,11 @@ from saml2.xmlenc import EncryptedData
from saml2.xml.schema import node_to_schema
from saml2.xml.schema import XMLSchemaError
+# importlib.resources was introduced in python 3.7
+if sys.version_info[:2] >= (3, 7):
+ from importlib.resources import path as _resource_path
+else:
+ from importlib_resources import path as _resource_path
logger = logging.getLogger(__name__)
diff --git a/src/saml2/xml/schema/__init__.py b/src/saml2/xml/schema/__init__.py
index 56e08b1c..ce38b807 100644
--- a/src/saml2/xml/schema/__init__.py
+++ b/src/saml2/xml/schema/__init__.py
@@ -1,10 +1,15 @@
-from importlib_resources import path as _resource_path
+import sys
from xmlschema import XMLSchema as _XMLSchema
from xmlschema.exceptions import XMLSchemaException as XMLSchemaError
import saml2.data.schemas as _data_schemas
+# importlib.resources was introduced in python 3.7
+if sys.version_info[:2] >= (3, 7):
+ from importlib.resources import path as _resource_path
+else:
+ from importlib_resources import path as _resource_path
def _create_xml_schema_validator(source, **kwargs):
kwargs = {