{"id":"d38a65d45be35425","repo":"pypa/pip","slug":"invalid-pyproject-build-system-requires","errorCode":"invalid-pyproject-build-system-requires","errorMessage":"Can not process {package}","messagePattern":"Can not process (.+?)","errorType":"exception","errorClass":"InvalidPyProjectBuildRequires","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/pyproject.py","lineNumber":90,"sourceCode":"        # 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\n\n    backend = build_system.get(\"build-backend\")\n    backend_path = build_system.get(\"backend-path\", [])\n    check: list[str] = []\n    if backend is None:","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_internal/pyproject.py#L72-L108","documentation":"Raised as InvalidPyProjectBuildRequires when [build-system].requires exists in pyproject.toml but is not a list of strings (validated by _is_list_of_str at pyproject.py:18). PEP 518 requires `requires` to be an array of PEP 508 requirement strings. A non-list value (a single string, a number, a dict) or a list containing non-string elements is rejected.","triggerScenarios":"Setting `requires = \"setuptools\"` (a bare string instead of a list). Setting `requires = [42]` or `requires = [{name=\"setuptools\"}]`. The check at pyproject.py:89 fails because either isinstance(obj, list) is False or any element is not a str.","commonSituations":"Authors unfamiliar with TOML/PEP 518 writing a scalar instead of an array. Misconfigured tooling that emits a malformed requires. Editing pyproject.toml by hand and dropping the square brackets.","solutions":["Change `requires` to be a TOML array of strings: wrap the value in `[ ... ]` and quote each entry.","Ensure every element is a quoted PEP 508 specifier string, e.g. `requires = [\"setuptools>=61.0\", \"wheel\"]`.","Re-run pip install; the build-system table now passes _is_list_of_str."],"exampleFix":"# before\n[build-system]\nrequires = \"setuptools\"\n# after\n[build-system]\nrequires = [\"setuptools>=61.0\"]","handlingStrategy":"validation","validationCode":"import tomllib\n\ndef validate_requires_is_str_list(path: str = \"pyproject.toml\") -> None:\n    with open(path, \"rb\") as f:\n        data = tomllib.load(f)\n    requires = data.get(\"build-system\", {}).get(\"requires\")\n    if not (isinstance(requires, list) and all(isinstance(r, str) for r in requires)):\n        raise TypeError(\"[build-system].requires must be a list of strings\")\n\nvalidate_requires_is_str_list()","typeGuard":"def is_list_of_str(obj) -> bool:\n    return isinstance(obj, list) and all(isinstance(i, str) for i in obj)","tryCatchPattern":"null","preventionTips":["Always wrap requires values in square brackets and quote each entry.","Lint pyproject.toml with a tool that understands PEP 518 (e.g. validate-pyproject)."],"tags":["pyproject","build-system","pep518","validation"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}