Skip to content

OSS-Fuzz build fails when setup.py imports unavailable pkg_resources #604

Description

@xingyaner

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.

Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions