The html5lib-python OSS-Fuzz build fails while pip is preparing the package metadata.
The failure occurs during:
Getting requirements to build wheel
The relevant error is:
ModuleNotFoundError: No module named 'pkg_resources'
ERROR: Failed to build 'file:///src/html5lib-python' when getting requirements to build wheel
At the affected source revision, setup.py imports pkg_resources during build-time setup processing:
from pkg_resources import parse_version
import pkg_resources
Because pkg_resources is unavailable in the build environment, setup.py cannot complete the wheel metadata preparation step, and the fuzz targets are not compiled.
The fix makes pkg_resources optional:
try:
import pkg_resources
except ImportError:
pkg_resources = None
The existing setuptools compatibility logic is executed only when pkg_resources is available, and version parsing is performed through pkg_resources.parse_version() within that guarded branch.
This removes the unconditional import that caused the metadata-generation failure while preserving the existing compatibility behavior when the module is present.
The patch was successfully verified with the OSS-Fuzz fuzzing build and check_build.

The html5lib-python OSS-Fuzz build fails while pip is preparing the package metadata.
The failure occurs during:
The relevant error is:
At the affected source revision,
setup.pyimports pkg_resources during build-time setup processing:Because pkg_resources is unavailable in the build environment, setup.py cannot complete the wheel metadata preparation step, and the fuzz targets are not compiled.
The fix makes pkg_resources optional:
The existing setuptools compatibility logic is executed only when pkg_resources is available, and version parsing is performed through
pkg_resources.parse_version()within that guarded branch.This removes the unconditional import that caused the metadata-generation failure while preserving the existing compatibility behavior when the module is present.
The patch was successfully verified with the OSS-Fuzz fuzzing build and
check_build.