Skip to content

Exclude the project from no-build by default #17416

Closed

Description

@NMertsch

Summary

I'd like to have the following:

  1. External dependencies are not built, unless explicitly allowed with no-binary-package (basically: I want to install wheels, not sdists)
  2. uv sync can create/update the venv
  3. uv build can package my package (e.g. for uv publish)

However, that's not possible with packages (uv init --package):

  1. no-build = true correctly prevents sdist installs, but then
  2. uv sync only works after also configuring no-binary-package = ["my-package"]
  3. uv build only works with the uv_build backend. I have to remove no-build = true to make it work with other backends.

I think points 2 and 3 should work out of the box.

How to reproduce

# create new package
uv init --package --build-backend setuptools my-package
cd my-package

# set `no-build = true`
echo '[tool.uv]' >> pyproject.toml
echo 'no-build = true' >> pyproject.toml

# interact with the package
uv sync  # error: Distribution `my-package==0.1.0 @ editable+.` can't be installed because it is marked as `--no-build` but has no binary distribution

# explicitly allow uv to build my own package
echo 'no-binary-package = ["my-package"]' >> pyproject.toml

# interact with the package
uv sync  # works

# build the package
uv build  # Failed to build, Building source distributions is disabled

Activity

  1. added
    enhancementNew feature or improvement to existing functionality
    on Jan 12, 2026
  2. zanieb commented on Jan 12, 2026

    @zanieb
    Member

    Can you explain (3)? Why does setuptools fail?

  3. NMertsch commented on Jan 12, 2026

    @NMertsch
    Author

    Can you explain (3)? Why does setuptools fail?

    I don't think setuptools fails. To me, "Building source distributions is disabled" implies that uv didn't invoke setuptools at all due to no-build = true.

    But when running uv init --package my-package (without --build-backend setuptools), uv build works just fine.

  4. zanieb commented on Jan 12, 2026

    @zanieb
    Member

    I'm confused that you said

    uv build doesn't work at all for setuptools projects

  5. zanieb commented on Jan 12, 2026

    @zanieb
    Member

    You're saying it works for the uv_build backend but not any other ones?

  6. NMertsch commented on Jan 12, 2026

    @NMertsch
    Author

    Sorry for the confusion. What I meant was:

    • uv build with backend setuptools works, unless no-build = true.
    • uv build with backend uv_build works, independently of no-build = true.

    I didn't test other backends. Give me a few minutes to try them all.

  7. NMertsch commented on Jan 12, 2026

    @NMertsch
    Author

    I now tried steps from the original post on all supported build backends.

    • uv sync behavior doesn't depend on the build backend. It always fails with no-build = true and always works without it.
    • uv build with -no-build = true only works for --build-backend uv and fails for all other backends (hatch, flit, pdm, poetry, scikit, setuptools; I skipped maturin because I don't have Rust installed). The error message is always the same: "Building source distributions is disabled".

    (Updated the original post: setuptools -> all backends besides uv_build)

  8. CHC383 commented on Jan 16, 2026

    @CHC383

    I have a similar case

    # pyproject.toml
    [build-system]
    requires = [ "uv_build>=0.9.26" ]
    build-backend = "uv_build"
    
    [tool.uv]
    no-build = true
    no-binary-package = [ "my-project" ]

    uv build --sdist failed because Building source distributions is disabled.

    Basically I want to disable building external dependencies but not my own project, and the workaround no-binary-package doesn't work in this case. I think this behavior was raised in #12607 but that issue was buried 😞

    @NMertsch I wonder how

    uv build with -no-build = true only works for --build-backend uv

    as it doesn't work with the config above.

  9. bluetech commented on Jan 20, 2026

    @bluetech

    I have a workspace with many packages using uv_build and I tried to set no-build = true in the root pyproject.toml for security reasons. I get the "can't be installed because [...] has no binary distribution" error. Does it make sense to have editable installs in particular excluded from the no-build check?

  10. segfly commented on Feb 8, 2026

    @segfly

    I ran into this issue as well:

    1. My project is a published library
    2. I want to use vcs tags for package versioning, so I am using hatchling build backend with hatch-vcs (because the uv build backend doesn't support hooks)
    3. I want to control my CI security posture by preventing arbitrary code from running due to building third party wheels

    2 and 3 are currently mutually exclusive because of these two uv issues. So I either have to choose security or choose dynamic versions from vcs.

  11. janos-varga commented on Sep 7, 2026

    @janos-varga

    I ran into this issue as well:

    1. My project is a published library
    2. I want to use vcs tags for package versioning, so I am using hatchling build backend with hatch-vcs (because the uv build backend doesn't support hooks)
    3. I want to control my CI security posture by preventing arbitrary code from running due to building third party wheels

    2 and 3 are currently mutually exclusive because of these two uv issues. So I either have to choose security or choose dynamic versions from vcs.

    I work at a large financial services firm where several teams (who already migrated to uv) are suffering from this, and even more teams are refusing to migrate exactly because of this. We need 2 and 3 to work at the same time.
    Data scientists (as well as other non-engineer Python users) cannot be expected to have full go/rust/c++ build toolchains installed locally when they only work with Python. For this reason, and the security one stated by @segfly , source distros are not an option for us. But teams that develop building blocks for others (i.e. libs) must be able to obide by requirements 2 and 3 above.
    Please fix this.

  12. CarrotManMatt commented on Oct 15, 2026

    @CarrotManMatt
    Contributor

    The workaround I found for building the local project into a wheel is to use the --build flag in CI: uv build --no-sources --build. For some reason that lets the current project be built when no-build = true & no-binary-package = ["my_project"].

    That being said, I think the correct solution in the long term is for the no-build = true configuration option to exclude the current project.

  13. zanieb commented on Oct 15, 2026

    @zanieb
    Member

    I believe this has been resolved:

    • 0.12.6: #21294 allows explicit uv build and non-editable workspace builds under no-build
    • 0.12.20: #21988 extends that exemption to first-party metadata builds for dynamic versions and dependencies
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

    enhancementNew feature or improvement to existing functionality

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions