diff mbox series

[meta-python,2/2] python3-html5lib: fix build with setuptools 82

Message ID 20260314130102.282943-2-peter.marko@siemens.com
State New
Headers show
Series [meta-networking,1/2] ntp: fix build with glibc 2.43 | expand

Commit Message

Marko, Peter March 14, 2026, 1:01 p.m. UTC
From: Peter Marko <peter.marko@siemens.com>

Signed-off-by: Peter Marko <peter.marko@siemens.com>
---
 ...g_resources-import-optional-for-Pyth.patch | 44 +++++++++++++++++++
 .../python/python3-html5lib_1.1.bb            |  1 +
 2 files changed, 45 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-html5lib/0001-setup.py-make-pkg_resources-import-optional-for-Pyth.patch
diff mbox series

Patch

diff --git a/meta-python/recipes-devtools/python/python3-html5lib/0001-setup.py-make-pkg_resources-import-optional-for-Pyth.patch b/meta-python/recipes-devtools/python/python3-html5lib/0001-setup.py-make-pkg_resources-import-optional-for-Pyth.patch
new file mode 100644
index 0000000000..f791b663f2
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-html5lib/0001-setup.py-make-pkg_resources-import-optional-for-Pyth.patch
@@ -0,0 +1,44 @@ 
+From 5bae4e7b62996f1ef1b9ee6719581bde115d762c Mon Sep 17 00:00:00 2001
+From: Peter Marko <peter.marko@siemens.com>
+Date: Fri, 13 Mar 2026 13:37:58 +0100
+Subject: [PATCH] setup.py: make pkg_resources import optional for Python 3.12+
+
+pkg_resources has been removed from newer Python/setuptools versions.
+Wrap the import in a try/except block and guard the usage site,
+allowing html5lib to build without pkg_resources present.
+
+Upstream-Status: Pending
+Signed-off-by: Peter Marko <peter.marko@siemens.com>
+---
+ setup.py | 10 +++++++---
+ 1 file changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/setup.py b/setup.py
+index c393c9c..e659e98 100644
+--- a/setup.py
++++ b/setup.py
+@@ -6,9 +6,13 @@ import sys
+ 
+ from os.path import join, dirname
+ from setuptools import setup, find_packages, __version__ as setuptools_version
+-from pkg_resources import parse_version
+ 
+-import pkg_resources
++try:
++    from pkg_resources import parse_version
++    import pkg_resources
++except ImportError:
++    parse_version = None
++    pkg_resources = None
+ 
+ try:
+     import _markerlib.markers
+@@ -49,7 +53,7 @@ if _markerlib and sys.version_info[0] == 3:
+ # Avoid the very buggy pkg_resources.parser, which doesn't consistently
+ # recognise the markers needed by this setup.py
+ # Change this to setuptools 20.10.0 to support all markers.
+-if pkg_resources:
++if pkg_resources and parse_version:
+     if parse_version(setuptools_version) < parse_version('18.5'):
+         MarkerEvaluation = pkg_resources.MarkerEvaluation
+ 
diff --git a/meta-python/recipes-devtools/python/python3-html5lib_1.1.bb b/meta-python/recipes-devtools/python/python3-html5lib_1.1.bb
index 3d7e44b87e..9c92164546 100644
--- a/meta-python/recipes-devtools/python/python3-html5lib_1.1.bb
+++ b/meta-python/recipes-devtools/python/python3-html5lib_1.1.bb
@@ -3,6 +3,7 @@  LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://LICENSE;md5=1ba5ada9e6fead1fdc32f43c9f10ba7c"
 
 SRC_URI += "file://0001-setup.py-fix-version-parsing-on-Python-3.14-ast.Str-.patch"
+SRC_URI += "file://0001-setup.py-make-pkg_resources-import-optional-for-Pyth.patch"
 SRC_URI[sha256sum] = "b2e5b40261e20f354d198eae92afc10d750afb487ed5e50f9c4eaf07c184146f"
 
 inherit pypi setuptools3