python3-jsonrpcserver: add patch to use importlib.resources instead of pkg_resources
PATCH 1/1 python3-jsonrpcserver: add patch to use importlib.resources instead of pkg_resources
From: Sam Van Den Berge <[email protected]>
Currently jsonrpcserver has a runtime dependency to setuptools because it uses pkg_resources. Setuptools however is not listed in the RDEPENDS of python3-jsonrpcserver. We could add setuptools to RDEPENDS but since pkg_resources is discouraged anyway [1], I posted a patch upstream to replace pkg_resources by importlib.resources.
Until the upstream patch is accepted and released, add it here as a patch so python3-jsonrpcserver is usable without the setuptools dependency.
Upstream-Status: Submitted [https://github.com/explodinglabs/jsonrpcserver/pull/235]
--- ...b.resources-instead-of-pkg_resources.patch | 44 +++++++++++++++++++ .../python/python3-jsonrpcserver_%.bbappend | 5 +++ 2 files changed, 49 insertions(+) create mode 100644 recipes-devtools/python/python3-jsonrpcserver/0001-Use-importlib.resources-instead-of-pkg_resources.patch create mode 100644 recipes-devtools/python/python3-jsonrpcserver_%.bbappend
recipes-devtools/python/python3-jsonrpcserver/0001-Use-importlib.resources-instead-of-pkg_resources.patch new file +44 -0
@@ -0,0 +1,44 @@ +From 4220c6a02bc03ff8c6cc4b3bee168a1351a3ce39 Mon Sep 17 00:00:00 2001 +From: Sam Van Den Berge <[email protected]> +Date: Fri, 29 Jul 2022 15:53:37 +0200 +Subject: [PATCH] Use importlib.resources instead of pkg_resources + +From the setuptools website [1]: + +Use of pkg_resources is discouraged in favor of importlib.resources, +importlib.metadata, and their backports (importlib_resources, +importlib_metadata). Please consider using those libraries instead of +pkg_resources. + +[1]: https://setuptools.pypa.io/en/latest/pkg_resources.html + +Signed-off-by: Sam Van Den Berge <[email protected]> +--- + jsonrpcserver/main.py | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/jsonrpcserver/main.py b/jsonrpcserver/main.py +index 0397a58..ac1855f 100644 +--- a/jsonrpcserver/main.py ++++ b/jsonrpcserver/main.py +@@ -13,7 +13,7 @@ from typing import Any, Callable, Dict, List, Optional, Union, cast + import json + + from jsonschema.validators import validator_for # type: ignore +-from pkg_resources import resource_string ++import importlib.resources + + from .dispatcher import dispatch_to_response_pure, Deserialized + from .methods import Methods, global_methods +@@ -26,7 +26,7 @@ default_deserializer = json.loads + + # Prepare the jsonschema validator. This is global so it loads only once, not every + # time dispatch is called. +-schema = json.loads(resource_string(__name__, "request-schema.json")) ++schema = json.loads(importlib.resources.read_text(__package__, "request-schema.json")) + klass = validator_for(schema) + klass.check_schema(schema) + default_validator = klass(schema).validate +-- +2.34.1 +
recipes-devtools/python/python3-jsonrpcserver_%.bbappend new file +5 -0
@@ -0,0 +1,5 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" + +SRC_URI = "\ + file://0001-Use-importlib.resources-instead-of-pkg_resources.patch \ +"
Signature · 1 line
2.34.1
Hi Sam,
Sam Van Den Berge <[email protected]> escreveu no dia terça, 2/08/2022 à(s) 14:27:
Quoted 8 lines
From: Sam Van Den Berge <[email protected]>
Currently jsonrpcserver has a runtime dependency to setuptools because it uses
pkg_resources. Setuptools however is not listed in the RDEPENDS of python3-jsonrpcserver. We could add setuptools to RDEPENDS but sincepkg_resourcesis discouraged anyway [1], I posted a patch upstream to replacepkg_resourcesby importlib.resources.
Quoted 6 lines
Until the upstream patch is accepted and released, add it here as a patch so python3-jsonrpcserver is usable without the setuptools dependency.
Upstream-Status: Submitted [
https://github.com/explodinglabs/jsonrpcserver/pull/235]
Thanks for the patch but the Upstream-Status is placed on the commit of the attached patch
and not here.
Quoted 23 lines
--- ...b.resources-instead-of-pkg_resources.patch | 44 +++++++++++++++++++ .../python/python3-jsonrpcserver_%.bbappend | 5 +++ 2 files changed, 49 insertions(+) create mode 100644 recipes-devtools/python/python3-jsonrpcserver/0001-Use-importlib.resources-instead-of-pkg_resources.patch create mode 100644recipes-devtools/python/python3-jsonrpcserver_%.bbappend
diff --git
a/recipes-devtools/python/python3-jsonrpcserver/0001-Use-importlib.resources-instead-of-pkg_resources.patchb/recipes-devtools/python/python3-jsonrpcserver/0001-Use-importlib.resources-instead-of-pkg_resources.patchnew file mode 100644
index 0000000..2d1a8c9
---/dev/null
+++b/recipes-devtools/python/python3-jsonrpcserver/0001-Use-importlib.resources-instead-of-pkg_resources.patchrecipes-devtools/python/python3-jsonrpcserver/0001-Use-importlib.resources-instead-of-pkg_resources.patch new file +4
-0@@ -0,0 +1,44 @@ +From 4220c6a02bc03ff8c6cc4b3bee168a1351a3ce39 Mon Sep 17 00:00:00 2001 +From: Sam Van Den Berge <[email protected]> +Date: Fri, 29 Jul 2022 15:53:37 +0200 +Subject: [PATCH] Use importlib.resources instead of pkg_resources
recipes-devtools/python/python3-jsonrpcserver/0001-Use-importlib.resources-instead-of-pkg_resources.patch line 14
Quoted 10 lines
recipes-devtools/python/python3-jsonrpcserver/0001-Use-importlib.resources-instead-of-pkg_resources.patch new file +10
-0+ +From the setuptools website [1]: + +Use of pkg_resources is discouraged in favor of importlib.resources, +importlib.metadata, and their backports (importlib_resources, +importlib_metadata). Please consider using those libraries instead of +pkg_resources. + +[1]: https://setuptools.pypa.io/en/latest/pkg_resources.html +
Upstream-Status: Submitted [
https://github.com/explodinglabs/jsonrpcserver/pull/235]
So it goes here ^
Jose
+Signed-off-by: Sam Van Den Berge <[email protected]>
Quoted 60 lines
recipes-devtools/python/python3-jsonrpcserver/0001-Use-importlib.resources-instead-of-pkg_resources.patch new file +9
-0+--- + jsonrpcserver/main.py | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/jsonrpcserver/main.py b/jsonrpcserver/main.py +index 0397a58..ac1855f 100644 +--- a/jsonrpcserver/main.py ++++ b/jsonrpcserver/main.py +@@ -13,7 +13,7 @@ from typing import Any, Callable, Dict, List, Optional,Union, cast
+ import jsonrecipes-devtools/python/python3-jsonrpcserver/0001-Use-importlib.resources-instead-of-pkg_resources.patch new file +10
-0+ + from jsonschema.validators import validator_for # type: ignore +-from pkg_resources import resource_string ++import importlib.resources + + from .dispatcher import dispatch_to_response_pure, Deserialized + from .methods import Methods, global_methods +@@ -26,7 +26,7 @@ default_deserializer = json.loads + + # Prepare the jsonschema validator. This is global so it loads onlyonce, not every
+ # time dispatch is called.
+-schema =json.loads(resource_string(__name__, "request-schema.json"))++schema =json.loads(importlib.resources.read_text(__package__, "request-schema.json"))
+ klass =validator_for(schema)
+klass.check_schema(schema)
+default_validator= klass(schema).validate
+--
+2.34.1(quoted diff) +1
-0+recipes-devtools/python/python3-jsonrpcserver_%.bbappend new file +4
-0@@ -0,0 +1,5 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" + +SRC_URI = "\ +file://0001-Use-importlib.resources-instead-of-pkg_resources.patch \
+"
--
2.34.1-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#98082):
https://lists.openembedded.org/g/openembedded-devel/message/98082
Mute This Topic: https://lists.openembedded.org/mt/92769960/5052612
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Signature · 3 lines
Best regards, José Quaresma