setup.py: handle missing pkg_resources import#592
setup.py: handle missing pkg_resources import#592chenrui333 wants to merge 1 commit intohtml5lib:masterfrom
Conversation
Signed-off-by: Rui Chen <rui@chenrui.dev>
git clean -xdf
tar zcvf ../python-html5lib_1.1.orig.tar.gz --exclude=.git .
debuild -uc -us
cp python-html5lib.spec ../python-html5lib_1.1-1.spec
cp ../python*-html5lib*1.1*.{gz,xz,spec,dsc} /osc/home\:alvistack/html5lib-html5lib-python-1.1/
rm -rf ../python*-html5lib*1.1*.*
See html5lib#583
See html5lib#587
See html5lib#592
Signed-off-by: Wong Hoi Sing Edison <hswong3i@pantarei-design.com>
|
@chenrui333 will you also be doing a pull for pkg_resources use in html5lib/tests/conftest.py? |
| from pkg_resources import parse_version | ||
| import pkg_resources | ||
| except ModuleNotFoundError: | ||
| from setuptools._vendor.packaging.version import parse as parse_version |
There was a problem hiding this comment.
@chenrui333 @grawlinson this does not work on Arch linux. The vendor namespace is an internal implementation detail that should not be relied upon. setuptools 82 that removed pkg_resources requires the packaging package so if pkg_resources is not provided by setuptools packing will be available not withstanding a broken installation.
There was a problem hiding this comment.
Like @loqs has said; It is 100% better to just do from packaging import parse as parse_version rather than depending on an internal implementation which will change at some point in the future.
There was a problem hiding this comment.
I think the issue can be avoided as the check is only for setuptools less than 18.5 and pkg_resources was removed in setuptools 82 so the import failure means there is no need to do the version check and it is enough to set pkg_resources to None:
--- a/setup.py
+++ b/setup.py
@@ -6,9 +6,11 @@ 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:
+ import pkg_resources
+except ImportError:
+ pkg_resources = None
try:
import _markerlib.markers
relates to Homebrew/homebrew-core#266589