{"record":{"id":"e53ec9e9c7836b89","repo":"pypa/pip","slug":"missing-pyproject-build-system-requires","errorCode":"missing-pyproject-build-system-requires","errorMessage":"Can not process {package}","messagePattern":"Can not process (.+?)","errorType":"validation","errorClass":"MissingPyProjectBuildRequires","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/pyproject.py","lineNumber":85,"sourceCode":"        build_system = None\n\n    if build_system is None:\n        # In the absence of any explicit backend specification, we\n        # assume the setuptools backend that most closely emulates the\n        # traditional direct setup.py execution, and require wheel and\n        # a version of setuptools that supports that backend.\n\n        build_system = {\n            \"requires\": [\"setuptools>=40.8.0\"],\n            \"build-backend\": \"setuptools.build_meta:__legacy__\",\n        }\n\n    # Ensure that the build-system section in pyproject.toml conforms\n    # to PEP 518.\n\n    # Specifying the build-system table but not the requires key is invalid\n    if \"requires\" not in build_system:\n        raise MissingPyProjectBuildRequires(package=req_name)\n\n    # Error out if requires is not a list of strings\n    requires = build_system[\"requires\"]\n    if not _is_list_of_str(requires):\n        raise InvalidPyProjectBuildRequires(\n            package=req_name,\n            reason=\"It is not a list of strings.\",\n        )\n\n    # Each requirement must be valid as per PEP 508\n    for requirement in requires:\n        try:\n            get_requirement(requirement)\n        except InvalidRequirement as error:\n            raise InvalidPyProjectBuildRequires(\n                package=req_name,\n                reason=f\"It contains an invalid requirement: {requirement!r}\",\n            ) from error","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_internal/pyproject.py#L67-L103","documentation":"Raised by load_pyproject_toml (pyproject.py:84) as MissingPyProjectBuildRequires (code: missing-pyproject-build-system-requires) when a pyproject.toml has a [build-system] table but that table lacks the required 'requires' key. PEP 518 mandates that [build-system] must contain 'requires', so pip refuses to build.","triggerScenarios":"A pyproject.toml containing '[build-system]' with only 'build-backend' (or 'backend-path') and no 'requires' array. The check 'if \"requires\" not in build_system' fires.","commonSituations":"Hand-authored pyproject.toml where the author listed a backend but forgot the requires; migration artifacts where build-system was partially populated; tooling that writes backend-path without requires.","solutions":["Add the 'requires' array to [build-system] listing build dependencies (e.g. setuptools + wheel).","Remove the [build-system] table entirely so pip applies the setuptools legacy defaults.","Validate the pyproject.toml with a linter/schema checker before publishing."],"exampleFix":"# before (pyproject.toml)\n[build-system]\nbuild-backend = \"setuptools.build_meta\"\n# after\n[build-system]\nrequires = [\"setuptools>=61.0\", \"wheel\"]\nbuild-backend = \"setuptools.build_meta\"","handlingStrategy":"validation","validationCode":"from pip._internal.utils.compat import tomllib\n\ndef build_system_has_requires(pyproject_path: str) -> tuple[bool, str | None]:\n    with open(pyproject_path, 'rb') as f:\n        data = tomllib.load(f)\n    bs = data.get('build-system')\n    if bs is not None and 'requires' not in bs:\n        return False, '[build-system] present but missing \"requires\"'\n    return True, None","typeGuard":"from typing import Any\n\ndef has_build_requires(build_system: dict[str, Any] | None) -> bool:\n    return build_system is None or isinstance(build_system.get('requires'), list)","tryCatchPattern":"from subprocess import run, CalledProcessError\ntry:\n    run([\"pip\", \"install\", target], check=True)\nexcept CalledProcessError:\n    # Add the requires array to [build-system] then rebuild.\n    run([\"python\", \"-m\", \"build\", target], check=True)","preventionTips":["Always include 'requires' in [build-system] when declaring a backend.","Lint pyproject.toml against the PEP 518/621 schema in CI.","Prefer modern project templates (e.g. setuptools [project]) that include build-system."],"tags":["pyproject","pep518","build-system","requires","config","pip"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}