From 29ed77b8325e99ac67fd37ddac1d9a50d9d957ce3d68a5d6bf73c741bfc72f81 Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Wed, 12 Apr 2023 04:59:38 +0000 Subject: [PATCH] - Update to 1.7.4: * Remove aud enforcement from deserialize function * Reduce length of comment line * Update minimum pyjwt * Remove use of six - Drop patch python-scitokens-no-six.patch, included upstream - Add patch use-importlib-metadata.patch: * Use importlib.metadata, rather than pkg_resources. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-scitokens?expand=0&rev=11 --- python-scitokens-no-six.patch | 78 ----------------------------------- python-scitokens.changes | 12 ++++++ python-scitokens.spec | 19 ++++----- scitokens-1.7.2.tar.gz | 3 -- scitokens-1.7.4.tar.gz | 3 ++ use-importlib-metadata.patch | 61 +++++++++++++++++++++++++++ 6 files changed, 83 insertions(+), 93 deletions(-) delete mode 100644 python-scitokens-no-six.patch delete mode 100644 scitokens-1.7.2.tar.gz create mode 100644 scitokens-1.7.4.tar.gz create mode 100644 use-importlib-metadata.patch diff --git a/python-scitokens-no-six.patch b/python-scitokens-no-six.patch deleted file mode 100644 index fb904b4..0000000 --- a/python-scitokens-no-six.patch +++ /dev/null @@ -1,78 +0,0 @@ -Index: scitokens-1.7.2/requirements.txt -=================================================================== ---- scitokens-1.7.2.orig/requirements.txt -+++ scitokens-1.7.2/requirements.txt -@@ -1,3 +1,2 @@ - cryptography - PyJWT>=1.6.1 --six -Index: scitokens-1.7.2/setup.py -=================================================================== ---- scitokens-1.7.2.orig/setup.py -+++ scitokens-1.7.2/setup.py -@@ -64,7 +64,6 @@ setuptools.setup( - install_requires=[ - 'cryptography', - 'PyJWT>=1.6.1', -- 'six', - 'setuptools' - ], - # classifiers -Index: scitokens-1.7.2/src/scitokens/scitokens.py -=================================================================== ---- scitokens-1.7.2.orig/src/scitokens/scitokens.py -+++ scitokens-1.7.2/src/scitokens/scitokens.py -@@ -12,7 +12,6 @@ import os - import jwt - from . import urltools - import logging --from six import string_types - - LOGGER = logging.getLogger("scitokens") - import uuid -@@ -697,7 +696,7 @@ class Enforcer(object): - return True - - def _validate_scope(self, value): -- if not isinstance(value, string_types): -+ if not isinstance(value, str): - raise InvalidAuthorizationResource("Scope is invalid. Must be a space separated string") - if self._test_access: - if not self._test_path: -Index: scitokens-1.7.2/src/scitokens/utils/config.py -=================================================================== ---- scitokens-1.7.2.orig/src/scitokens/utils/config.py -+++ scitokens-1.7.2/src/scitokens/utils/config.py -@@ -5,8 +5,7 @@ Module for configuration management - - - # Config parser is renamed in python 3 --from six.moves import configparser --import six -+import configparser - import logging - import logging.handlers - -@@ -30,7 +29,7 @@ def set_config(config = None): - """ - global configuration # pylint: disable=C0103 - -- if isinstance(config, six.string_types): -+ if isinstance(config, str): - configuration = configparser.ConfigParser(CONFIG_DEFAULTS) - configuration.read([config]) - elif isinstance(config, configparser.RawConfigParser): -Index: scitokens-1.7.2/tests/test_config.py -=================================================================== ---- scitokens-1.7.2.orig/tests/test_config.py -+++ scitokens-1.7.2/tests/test_config.py -@@ -8,8 +8,7 @@ import tempfile - import logging - import scitokens - import scitokens.utils.config -- --from six.moves import configparser -+import configparser - - class TestConfig(unittest.TestCase): - """ diff --git a/python-scitokens.changes b/python-scitokens.changes index c53dead..52cf487 100644 --- a/python-scitokens.changes +++ b/python-scitokens.changes @@ -1,3 +1,15 @@ +------------------------------------------------------------------- +Wed Apr 12 04:56:08 UTC 2023 - Steve Kowalik + +- Update to 1.7.4: + * Remove aud enforcement from deserialize function + * Reduce length of comment line + * Update minimum pyjwt + * Remove use of six +- Drop patch python-scitokens-no-six.patch, included upstream +- Add patch use-importlib-metadata.patch: + * Use importlib.metadata, rather than pkg_resources. + ------------------------------------------------------------------- Mon Nov 14 08:47:39 UTC 2022 - pgajdos@suse.com diff --git a/python-scitokens.spec b/python-scitokens.spec index 6f86539..06b77ac 100644 --- a/python-scitokens.spec +++ b/python-scitokens.spec @@ -1,7 +1,7 @@ # # spec file for package python-scitokens # -# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,25 +18,21 @@ %define bname scitokens -%{?!python_module:%define python_module() python-%{**} python3-%{**}} - Name: python-scitokens -Version: 1.7.2 +Version: 1.7.4 Release: 0 Summary: SciToken reference implementation library License: Apache-2.0 URL: https://scitokens.org Source: https://github.com/scitokens/scitokens/archive/refs/tags/v%{version}.tar.gz#/%{bname}-%{version}.tar.gz -# https://github.com/scitokens/scitokens/issues/169 -Patch0: python-scitokens-no-six.patch -BuildRequires: %{python_module PyJWT} +# PATCH-FIX-UPSTREAM Do not use pkg_resources gh#scitokens/scitokens#182 +Patch0: use-importlib-metadata.patch +BuildRequires: %{python_module PyJWT >= 2.2} BuildRequires: %{python_module pytest} BuildRequires: %{python_module setuptools} -BuildRequires: %{python_module six} BuildRequires: fdupes BuildRequires: python-rpm-macros -Requires: python-PyJWT -Requires: python-six +Requires: python-PyJWT >= 2.2 BuildArch: noarch Requires(post): update-alternatives Requires(postun):update-alternatives @@ -50,8 +46,7 @@ federated environment where several otherwise-independent storage endpoints want to delegate trust for an issuer for managing a storage allocation. %prep -%setup -q -n scitokens-%{version} -%patch0 -p1 +%autosetup -p1 -n scitokens-%{version} %build %python_build diff --git a/scitokens-1.7.2.tar.gz b/scitokens-1.7.2.tar.gz deleted file mode 100644 index be121a2..0000000 --- a/scitokens-1.7.2.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:66ff0b5300253ac0a043688071d62a3eb14fdf965e2e320dcaa87de8f2e874c1 -size 51044 diff --git a/scitokens-1.7.4.tar.gz b/scitokens-1.7.4.tar.gz new file mode 100644 index 0000000..3d6fb6f --- /dev/null +++ b/scitokens-1.7.4.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e9685831addb2720a03bbfbb18e8c36a34e5a308c1e67ba003e8aea8e5d1ccfb +size 51476 diff --git a/use-importlib-metadata.patch b/use-importlib-metadata.patch new file mode 100644 index 0000000..7f50ee1 --- /dev/null +++ b/use-importlib-metadata.patch @@ -0,0 +1,61 @@ +From 8f909b3d81fa21af91e1e96a85168e7643faf9d3 Mon Sep 17 00:00:00 2001 +From: Steve Kowalik +Date: Wed, 12 Apr 2023 13:57:02 +1000 +Subject: [PATCH] Use importlib.metadata rather than pkg_resources + +pkg_resources is a deprecated API, and a rather heavyweight one. Since +Python 3.8, the standard library has included importlib.metadata, which +can do the same functionality we're looking for here. Since we continue +to support older versions of Python, fallback to importlib_metadata if +required. +--- + requirements.txt | 1 + + setup.py | 1 + + src/scitokens/utils/keycache.py | 11 ++++++++--- + 3 files changed, 10 insertions(+), 3 deletions(-) + +diff --git a/requirements.txt b/requirements.txt +index d767b78..4e260fe 100644 +--- a/requirements.txt ++++ b/requirements.txt +@@ -1,2 +1,3 @@ + cryptography ++importlib_metadata;python_version<'3.8' + PyJWT>=2.2.0 +diff --git a/setup.py b/setup.py +index ad046e6..0ad28c7 100644 +--- a/setup.py ++++ b/setup.py +@@ -66,6 +66,7 @@ def find_version(path, varname="__version__"): + install_requires=[ + 'cryptography', + 'PyJWT>=1.6.1', ++ "importlib_metadata;python_version<'3.8'", + 'setuptools' + ], + extras_require={ +diff --git a/src/scitokens/utils/keycache.py b/src/scitokens/utils/keycache.py +index 398980f..56385f9 100644 +--- a/src/scitokens/utils/keycache.py ++++ b/src/scitokens/utils/keycache.py +@@ -6,12 +6,17 @@ + import os + import sqlite3 + import time +-import pkg_resources # part of setuptools + import re + import logging ++ ++try: ++ import importlib.metadata as import_meta ++except ImportError: ++ import importlib_metadata as import_meta ++ + try: +- PKG_VERSION = pkg_resources.require("scitokens")[0].version +-except pkg_resources.DistributionNotFound as error: ++ PKG_VERSION = import_meta.version("scitokens") ++except import_meta.PackageNotFoundError: + # During testing, scitokens won't be installed, so requiring it will fail + # Instead, fake it + PKG_VERSION = '1.0.0'