{"record":{"id":"dc71960e37a3d75c","repo":"astral-sh/uv","slug":"using-uv-attr-name-is-not-allowed-build-backe","errorCode":null,"errorMessage":"Using `uv.{attr_name}` is not allowed; build backend functionality is in the `uv_build` package. Did you mean to use `uv_build` as your build system?","messagePattern":"Using `uv\\.(.+?)` is not allowed; build backend functionality is in the `uv_build` package\\. Did you mean to use `uv_build` as your build system\\?","errorType":"exception","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"python/uv/__init__.py","lineNumber":23,"sourceCode":"__all__ = [\"find_uv_bin\"]\n\n\ndef __getattr__(attr_name: str) -> object:\n    if attr_name in {\n        \"build_sdist\",\n        \"build_wheel\",\n        \"build_editable\",\n        \"get_requires_for_build_sdist\",\n        \"get_requires_for_build_wheel\",\n        \"prepare_metadata_for_build_wheel\",\n        \"get_requires_for_build_editable\",\n        \"prepare_metadata_for_build_editable\",\n    }:\n        err = (\n            f\"Using `uv.{attr_name}` is not allowed; build backend functionality is in the `uv_build` package. \"\n            f\"Did you mean to use `uv_build` as your build system?\"\n        )\n        raise AttributeError(err)\n    raise AttributeError(f\"module `{__name__}` has no attribute `{attr_name}`\")\n","sourceCodeStart":5,"sourceCodeEnd":25,"githubUrl":"https://github.com/astral-sh/uv/blob/f1a42680ff5272232d65748acf338b19778dde24/python/uv/__init__.py#L5-L25","documentation":"The `uv` PyPI package intentionally exposes only `find_uv_bin`. Build-backend hooks previously reachable as `uv.build_wheel` etc. moved to the separate `uv_build` package, so the module-level `__getattr__` raises a tailored AttributeError for any of the eight PEP 517 hook names, pointing you at `uv_build`. Any other unknown attribute raises a plain AttributeError instead.","triggerScenarios":"`pyproject.toml` with `build-backend = \"uv.build_wheel\"` (or `uv.build_sdist`, `uv.build_editable`, `uv.get_requires_for_build_*`, `uv.prepare_metadata_for_build_*`), which makes the PEP 517 frontend do `getattr(uv, hook_name)`; also direct code like `import uv; uv.build_wheel(wheel_dir)`.","commonSituations":"Projects created when uv shipped the backend inside the `uv` package (early 0.4/0.5 era) or templates/tutorials from that period; upgrading uv without updating `[build-system]`; a backend string typo that starts with `uv.` instead of `uv_build`.","solutions":["Set `build-backend = \"uv_build\"` in pyproject.toml.","Set `requires = [\"uv_build>=0.5,<0.6\"]` (or the matching minor range) in `[build-system]` so the correct package is installed in build isolation.","If code called the hooks directly, depend on `uv-build` and `import uv_build` instead of `uv`."],"exampleFix":"# before (pyproject.toml)\n[build-system]\nrequires = [\"uv>=0.4\"]\nbuild-backend = \"uv.build_wheel\"\n\n# after\n[build-system]\nrequires = [\"uv_build>=0.5,<0.6\"]\nbuild-backend = \"uv_build\"","handlingStrategy":"validation","validationCode":"import tomllib\n\nwith open(\"pyproject.toml\", \"rb\") as fh:\n    backend = tomllib.load(fh)[\"build-system\"][\"build-backend\"]\nassert backend == \"uv_build\" or backend.startswith(\"uv_build:\"), (\n    f\"unsupported backend {backend!r}: build hooks live in the uv_build package, not uv\"\n)","typeGuard":"LEGACY_UV_HOOKS = {\n    \"build_sdist\", \"build_wheel\", \"build_editable\",\n    \"get_requires_for_build_sdist\", \"get_requires_for_build_wheel\",\n    \"prepare_metadata_for_build_wheel\", \"get_requires_for_build_editable\",\n    \"prepare_metadata_for_build_editable\",\n}\n\ndef is_valid_uv_backend(backend: str) -> bool:\n    \"\"\"True for the supported `uv_build` backend (with optional :target suffix).\"\"\"\n    name = backend.split(\":\", 1)[0]\n    return name == \"uv_build\" and name not in LEGACY_UV_HOOKS","tryCatchPattern":"try:\n    hook = getattr(backend_module, hook_name)\nexcept AttributeError as exc:\n    if \"uv_build\" in str(exc):\n        raise SystemExit(\"Fix pyproject.toml: build-backend = \\\"uv_build\\\"\") from exc\n    raise","preventionTips":["When upgrading uv in a project using its build backend, also update [build-system] requires and build-backend together.","CI: after dependency upgrades, run a trivial `python -m build --sdist --no-isolation` smoke build to catch backend-string rot early.","Never reference `uv.` hooks in templates; the `uv` PyPI package intentionally exports only find_uv_bin."],"tags":["build-backend","pep-517","packaging","migration","attributeerror"],"backgroundTag":null,"analyzedSha":"f1a42680ff5272232d65748acf338b19778dde24","analyzedAt":"2026-08-16T04:51:47.599Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}