Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions python/uv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,21 @@
]
else:
__all__ = ["find_uv_bin"]


def __getattr__(attr_name: str) -> object:
if attr_name in {
"build_sdist",
"build_wheel",
"build_editable",
"get_requires_for_build_sdist",
"get_requires_for_build_wheel",
"prepare_metadata_for_build_wheel",
"get_requires_for_build_editable",
"prepare_metadata_for_build_editable",
}:
err = f"Using `uv.{attr_name}` is not allowed. The uv build backend requires preview mode to be enabled, e.g., via the `UV_PREVIEW=1` environment variable."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're hitting this branch, you need UV_PREVIEW=1, that's e.g. with python -m build. For uv build, you usually want --preview which goes through the direct path, except for uv build --force-pep517, in which case you need UV_PREVIEW=1, which is why I had just put "Use UV_PREVIEW=1 and --preview" on top of the docs.

We could also set preview through PEP 517 config settings, but that seems even worse.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm, is this asking for a change to what I wrote here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was only adding context on why this preview feature is complicated beyond the usual "Add --preview to use".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 sounds good, that makes sense to me.

raise AttributeError(err)

err = f"module 'uv' has no attribute '{attr_name}'"
raise AttributeError(err)
Loading