mirror of
https://github.com/openembedded/meta-openembedded.git
synced 2026-05-08 05:29:22 +00:00
python3-pytest-runner: remove using pkg_resources
The python3 setuptools 82 dropped pkg_resources module by now. To avoid the failure "No module named 'pkg_resources'", replace the functions from this module with other functions from modules packaging and importlib.metadata. Signed-off-by: Li Zhou <li.zhou@windriver.com> Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
This commit is contained in:
+77
@@ -0,0 +1,77 @@
|
|||||||
|
From 81b0218e390e36aa2c3d1bdaa124d8af175e9cbb Mon Sep 17 00:00:00 2001
|
||||||
|
From: Li Zhou <li.zhou@windriver.com>
|
||||||
|
Date: Thu, 2 Apr 2026 15:44:18 +0800
|
||||||
|
Subject: [PATCH] Not use functions from pkg_resources any more
|
||||||
|
|
||||||
|
The python3 setuptools 82 dropped pkg_resources module by now.
|
||||||
|
To avoid the failure "No module named 'pkg_resources'", replace the
|
||||||
|
functions from this module with other functions from modules
|
||||||
|
packaging and importlib.metadata.
|
||||||
|
|
||||||
|
Upstream-Status: Inactive-Upstream [lastcommit: 2023]
|
||||||
|
Signed-off-by: Li Zhou <li.zhou@windriver.com>
|
||||||
|
---
|
||||||
|
ptr/__init__.py | 23 +++++++++++++----------
|
||||||
|
1 file changed, 13 insertions(+), 10 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/ptr/__init__.py b/ptr/__init__.py
|
||||||
|
index 41192fa..5186059 100644
|
||||||
|
--- a/ptr/__init__.py
|
||||||
|
+++ b/ptr/__init__.py
|
||||||
|
@@ -10,10 +10,12 @@ import operator as _operator
|
||||||
|
import itertools as _itertools
|
||||||
|
import warnings as _warnings
|
||||||
|
|
||||||
|
-import pkg_resources
|
||||||
|
import setuptools.command.test as orig
|
||||||
|
from setuptools import Distribution
|
||||||
|
|
||||||
|
+from importlib.metadata import version
|
||||||
|
+from packaging.version import Version
|
||||||
|
+from packaging.markers import Marker, InvalidMarker
|
||||||
|
|
||||||
|
@_contextlib.contextmanager
|
||||||
|
def _save_argv(repl=None):
|
||||||
|
@@ -121,7 +123,8 @@ class PyTest(orig.test):
|
||||||
|
instead of declaring the dependency in the package
|
||||||
|
metadata, assert the requirement at run time.
|
||||||
|
"""
|
||||||
|
- pkg_resources.require('setuptools>=27.3')
|
||||||
|
+ if Version(version('setuptools')) < Version('27.3'):
|
||||||
|
+ raise RuntimeError("setuptools >= 27.3 is required")
|
||||||
|
|
||||||
|
def finalize_options(self):
|
||||||
|
if self.addopts:
|
||||||
|
@@ -133,11 +136,12 @@ class PyTest(orig.test):
|
||||||
|
Given an environment marker, return True if the marker is valid
|
||||||
|
and matches this environment.
|
||||||
|
"""
|
||||||
|
- return (
|
||||||
|
- not marker
|
||||||
|
- or not pkg_resources.invalid_marker(marker)
|
||||||
|
- and pkg_resources.evaluate_marker(marker)
|
||||||
|
- )
|
||||||
|
+ if not marker:
|
||||||
|
+ return True
|
||||||
|
+ try:
|
||||||
|
+ return Marker(marker).evaluate()
|
||||||
|
+ except InvalidMarker:
|
||||||
|
+ return False
|
||||||
|
|
||||||
|
def install_dists(self, dist):
|
||||||
|
"""
|
||||||
|
@@ -175,9 +179,8 @@ class PyTest(orig.test):
|
||||||
|
"please upgrade to setuptools 30.4 or later or pin to "
|
||||||
|
"pytest-runner < 5."
|
||||||
|
)
|
||||||
|
- ver_str = pkg_resources.get_distribution('setuptools').version
|
||||||
|
- ver = pkg_resources.parse_version(ver_str)
|
||||||
|
- if ver < pkg_resources.parse_version('30.4'):
|
||||||
|
+ ver = Version(version('setuptools'))
|
||||||
|
+ if ver < Version('30.4'):
|
||||||
|
_warnings.warn(msg)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
--
|
||||||
|
2.34.1
|
||||||
|
|
||||||
@@ -5,6 +5,10 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=7a7126e068206290f3fe9f8d6c713ea6"
|
|||||||
|
|
||||||
SRC_URI[sha256sum] = "70d4739585a7008f37bf4933c013fdb327b8878a5a69fcbb3316c88882f0f49b"
|
SRC_URI[sha256sum] = "70d4739585a7008f37bf4933c013fdb327b8878a5a69fcbb3316c88882f0f49b"
|
||||||
|
|
||||||
|
SRC_URI += " \
|
||||||
|
file://0001-Not-use-functions-from-pkg_resources-any-more.patch \
|
||||||
|
"
|
||||||
|
|
||||||
inherit pypi python_setuptools_build_meta
|
inherit pypi python_setuptools_build_meta
|
||||||
|
|
||||||
DEPENDS += " \
|
DEPENDS += " \
|
||||||
|
|||||||
Reference in New Issue
Block a user