Package by default: Add in preview by konstin · Pull Request #17841 · astral-sh/uv · GitHub
Skip to content

Package by default: Add in preview#17841

Merged
konstin merged 3 commits into
mainfrom
konsti/package-by-default
Jun 10, 2026
Merged

Package by default: Add in preview#17841
konstin merged 3 commits into
mainfrom
konsti/package-by-default

Conversation

@konstin

@konstin konstin commented Feb 3, 2026

Copy link
Copy Markdown
Member

Switch the (preview) default for uv init to a src-package. The package by default has an entrypoint by the name of the package that can be run with uv init foo.

There's effectively three layouts with this change:

  • package with entrypoint (packaged application, the default)
  • package without entrypoint (pure lib)
  • flat main.py application (pure app)

These are selected from among the existing --app/--lib and --package/--no-package flags, as to not cause too much churn. --build-backend still implies --package, with --app --build-backend doesn't change. --bare doesn't add a build system by default.

Testing is a bit awkward, cause there's now all the stable tests and a separate test for the preview behavior, while we'll have to update the stable tests upon stabilization. You can see the effect of stabilization in #19197.

kind package template
(default) (default) entrypoint + package exposing hello()
(default) --package entrypoint + package exposing hello()
(default) --no-package main.py with main()
--app (default) main.py with main()
--app --package entrypoint + package exposing hello()
--app --no-package main.py with main()
--lib (default) package exposing hello()
--lib --package package exposing hello()
--lib --no-package Error: libraries are always packaged

Navigation

There are three branches:

Open Decided design questions

  • Should the default layout fill out the authors table?
    No, the authors field isn't helpful here.
  • Should --bare also create a (by itself broken) build system by default, without setting --package or --build-backend?
    No, we want something that works, and not creating a build backend is very bare. It's slightly inconsistent that effectively --bare is no-package by default, but that's better than the alternatives and explainable as --bare being no-most-things.

@konstin konstin force-pushed the konsti/package-by-default branch 5 times, most recently from d24977d to 41931f4 Compare February 20, 2026 14:15
@codspeed-hq

codspeed-hq Bot commented Mar 15, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 13 untouched benchmarks


Comparing konsti/package-by-default (39c1221) with main (3b8e3ca)

Open in CodSpeed

@konstin konstin force-pushed the konsti/package-by-default branch from 41931f4 to 63b394e Compare March 26, 2026 12:02
@konstin konstin added preview Experimental behavior enhancement New feature or improvement to existing functionality labels Mar 26, 2026
@konstin konstin force-pushed the konsti/package-by-default branch 2 times, most recently from 96ad72e to 986e822 Compare March 26, 2026 16:10
@konstin konstin force-pushed the konsti/package-by-default branch 4 times, most recently from e389a8a to a3cbb2d Compare April 16, 2026 13:54
@konstin konstin force-pushed the konsti/package-by-default branch from a3cbb2d to 8e7f3b9 Compare April 27, 2026 20:33
@konstin konstin changed the title Package by default Package by default: Add preview feature Apr 27, 2026
@konstin konstin changed the title Package by default: Add preview feature Package by default: Add in preview Apr 27, 2026
Comment thread crates/uv/src/commands/project/init.rs Outdated

// Do no fill in `authors` for non-packaged applications unless explicitly requested.
let author_from = author_from.unwrap_or_else(|| match self {
Self::ApplicationWithLibrary | Self::Library | Self::BareWithBuildBackend => {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Flagging: Should bare with a build backend populate authors?

@konstin konstin force-pushed the konsti/package-by-default branch from 77ed055 to e44f8c1 Compare April 27, 2026 23:20
@konstin konstin marked this pull request as ready for review April 28, 2026 00:36
@konstin konstin requested a review from zanieb April 28, 2026 00:38
@konstin konstin force-pushed the konsti/package-by-default branch from e44f8c1 to 9ee4139 Compare May 16, 2026 20:38

@zsol zsol left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

overall LGTM but there are a few things we should address in here

Comment thread crates/uv-cli/src/lib.rs Outdated
Comment on lines +754 to +757
ApplicationOld,
// TODO(konsti): Remove when stabilizing.
/// Initialize a Python library.
LibraryOld,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: don't use Old/New, they quickly become confusing :) I'd go with ApplicationWithPackageInitOff and LibraryWithPackageInitOff

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This should only be temporary, https://github.com/astral-sh/uv/pull/19197/changes removes the nomenclature entirely, the idea is more like <style>ToBeRemoved and <style>ToBecomeTheDefault

Comment thread crates/uv/src/commands/project/init.rs Outdated
Comment thread crates/uv/src/commands/project/init.rs Outdated
Comment on lines +986 to +993
// Do no fill in `authors` for non-packaged applications unless explicitly requested.
let author_from = author_from.unwrap_or_else(|| match self {
Self::ApplicationWithLibrary | Self::Library | Self::BareWithBuildSystem => {
AuthorFrom::default()
}
Self::Application | Self::Bare => AuthorFrom::None,
Self::ApplicationOld | Self::LibraryOld => unreachable!(),
});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I realize this is what you highlight as a question in the PR summary, so let's discuss: What's the downside of filling this out by default?

@konstin konstin Jun 1, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's more metadata to maintain, especially since it's filled with whatever name and mail the person who did uv init had configured. We can't infer actual team information, and if it's not distributed as a package, there doesn't seem to much use in the package authors field. It's also taking a lesson from Cargo, which wanted to deprecate the authors field entirely but eventually settled on making it optional and not filling it by default: https://rust-lang.github.io/rfcs/3052-optional-authors-field.html. Python didn't make this same decision, but the considerations of the RFC apply to Python equally.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sounds good to me!

Comment thread crates/uv/src/commands/project/init.rs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we don't call this in BareWithBuildSystem, which will probably result in a broken configuration with e.g. maturin or scikit. Is that intentional? If so, maybe capture that somewhere?

Edit: I now realize this is another thing you call out, so my opinion is that we shouldn't generate broken configuration if we can help it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Does this mean we should error for uv init --lib --bare or uv init --package --bare? (Given that we shouldn't ignore --lib/--package)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do you think it's possible to generate something that's not broken? If not, then erroring out would be fine

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There's two aspects here:

Stable already allows uv init --bare --package, which creates a [build-system] table without the associated files. Not supporting this anymore would be a regression.

It seems fine to not create a build system with --bare by default, as --bare doesn't create most things we usually create.

Comment thread crates/uv/src/settings.rs
Comment thread crates/uv/src/settings.rs
Comment thread crates/uv/src/settings.rs
@konstin konstin force-pushed the konsti/package-by-default branch from 57d3b49 to f7dd196 Compare June 9, 2026 08:21
@konstin konstin force-pushed the konsti/package-by-default branch from f7dd196 to 39c1221 Compare June 9, 2026 14:20
@konstin konstin merged commit ab62196 into main Jun 10, 2026
56 checks passed
@konstin konstin deleted the konsti/package-by-default branch June 10, 2026 08:26
blake-hamm added a commit to blake-hamm/bhamm-lab that referenced this pull request Jun 12, 2026
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [ghcr.io/astral-sh/uv](https://github.com/astral-sh/uv) | stage | patch | `0.11.20` → `0.11.21` |

---

> ⚠️ **Warning**
>
> Some dependencies could not be looked up. Check the [Dependency Dashboard](issues/155) for more information.

---

### Release Notes

<details>
<summary>astral-sh/uv (ghcr.io/astral-sh/uv)</summary>

### [`v0.11.21`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#01121)

[Compare Source](astral-sh/uv@0.11.20...0.11.21)

Released on 2026-06-11.

##### Python

- Add CPython 3.13.14 and 3.14.6 ([#&#8203;19787](astral-sh/uv#19787))

##### Preview features

- Add `environment.root` to `uv workspace metadata --sync` ([#&#8203;19760](astral-sh/uv#19760))
- Allow `uv upgrade` to update a single dependency constraint ([#&#8203;19738](astral-sh/uv#19738))
- Compute and pass `uv workspace metadata` payload in `ty check` ([#&#8203;19763](astral-sh/uv#19763))
- Make packaged applications the default for `uv init` ([#&#8203;17841](astral-sh/uv#17841))

##### Performance

- Add parallel discovery of Python versions for `uv python list` ([#&#8203;18684](astral-sh/uv#18684))
- Avoid normalizing source distribution names twice ([#&#8203;19784](astral-sh/uv#19784))

##### Bug fixes

- Improve cache robustness and pruning behavior
  - Allow CI cache pruning without an sdist bucket ([#&#8203;19802](astral-sh/uv#19802))
  - Avoid overflow when reading malformed cache entries ([#&#8203;19799](astral-sh/uv#19799))
  - Preserve cached Python downloads during cache pruning ([#&#8203;19795](astral-sh/uv#19795))
  - Reject running inside the cache ([#&#8203;19659](astral-sh/uv#19659))
- Fix Python discovery and version request edge cases
  - Avoid panics for Unicode Python version requests ([#&#8203;19797](astral-sh/uv#19797))
  - Fix handling of non-critical errors in `uv python list` with path requests ([#&#8203;19774](astral-sh/uv#19774))
  - Fix stop-discovery-at regression ([#&#8203;19769](astral-sh/uv#19769))
- Harden parsing and validation for package metadata, requirements, markers, URLs, and conflict sets
  - Allow trailing commas in version specifiers ([#&#8203;19806](astral-sh/uv#19806))
  - Avoid panics for invalid UTF-8 URL credentials ([#&#8203;19800](astral-sh/uv#19800))
  - Avoid panics for malformed source distribution filenames ([#&#8203;19776](astral-sh/uv#19776))
  - Avoid panics for trailing extra separators ([#&#8203;19779](astral-sh/uv#19779))
  - Avoid stack overflow for recursive requirements path aliases ([#&#8203;19777](astral-sh/uv#19777))
  - Ignore reversed string compatible-release markers ([#&#8203;19782](astral-sh/uv#19782))
  - Reject duplicate entries in conflict sets ([#&#8203;19801](astral-sh/uv#19801))
  - Reject malformed hash options in requirements files ([#&#8203;19783](astral-sh/uv#19783))
  - Reject source distribution filenames without a separator ([#&#8203;19803](astral-sh/uv#19803))
  - Use UTF-8 lengths for requirement errors ([#&#8203;19781](astral-sh/uv#19781))
  - Use UTF-8 lengths for trailing marker errors ([#&#8203;19796](astral-sh/uv#19796))
  - Use byte offsets when peeking over requirements ([#&#8203;19780](astral-sh/uv#19780))
  - Validate GraalPy ABI suffixes ([#&#8203;19805](astral-sh/uv#19805))
- Improve wheel entry-point error handling and virtual environment activation quoting
  - Propagate errors when reading wheel entry points ([#&#8203;19794](astral-sh/uv#19794))
  - Quote virtual environment activation paths with shell metacharacters ([#&#8203;19798](astral-sh/uv#19798))

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yMjAuMCIsInVwZGF0ZWRJblZlciI6IjQzLjIyMC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiXX0=-->

Co-authored-by: Renovate Bot <renovate@bhamm-lab.com>
Reviewed-on: https://codeberg.org/blake-hamm/bhamm-lab/pulls/194
hbjydev pushed a commit to hbjydev/phoebe that referenced this pull request Jun 14, 2026
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [uv](https://github.com/astral-sh/uv) | patch | `0.11.19` → `0.11.21` |

---

### Release Notes

<details>
<summary>astral-sh/uv (uv)</summary>

### [`v0.11.21`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#01121)

[Compare Source](astral-sh/uv@0.11.20...0.11.21)

Released on 2026-06-11.

##### Python

- Add CPython 3.13.14 and 3.14.6 ([#&#8203;19787](astral-sh/uv#19787))

##### Preview features

- Add `environment.root` to `uv workspace metadata --sync` ([#&#8203;19760](astral-sh/uv#19760))
- Allow `uv upgrade` to update a single dependency constraint ([#&#8203;19738](astral-sh/uv#19738))
- Compute and pass `uv workspace metadata` payload in `ty check` ([#&#8203;19763](astral-sh/uv#19763))
- Make packaged applications the default for `uv init` ([#&#8203;17841](astral-sh/uv#17841))

##### Performance

- Add parallel discovery of Python versions for `uv python list` ([#&#8203;18684](astral-sh/uv#18684))
- Avoid normalizing source distribution names twice ([#&#8203;19784](astral-sh/uv#19784))

##### Bug fixes

- Improve cache robustness and pruning behavior
  - Allow CI cache pruning without an sdist bucket ([#&#8203;19802](astral-sh/uv#19802))
  - Avoid overflow when reading malformed cache entries ([#&#8203;19799](astral-sh/uv#19799))
  - Preserve cached Python downloads during cache pruning ([#&#8203;19795](astral-sh/uv#19795))
  - Reject running inside the cache ([#&#8203;19659](astral-sh/uv#19659))
- Fix Python discovery and version request edge cases
  - Avoid panics for Unicode Python version requests ([#&#8203;19797](astral-sh/uv#19797))
  - Fix handling of non-critical errors in `uv python list` with path requests ([#&#8203;19774](astral-sh/uv#19774))
  - Fix stop-discovery-at regression ([#&#8203;19769](astral-sh/uv#19769))
- Harden parsing and validation for package metadata, requirements, markers, URLs, and conflict sets
  - Allow trailing commas in version specifiers ([#&#8203;19806](astral-sh/uv#19806))
  - Avoid panics for invalid UTF-8 URL credentials ([#&#8203;19800](astral-sh/uv#19800))
  - Avoid panics for malformed source distribution filenames ([#&#8203;19776](astral-sh/uv#19776))
  - Avoid panics for trailing extra separators ([#&#8203;19779](astral-sh/uv#19779))
  - Avoid stack overflow for recursive requirements path aliases ([#&#8203;19777](astral-sh/uv#19777))
  - Ignore reversed string compatible-release markers ([#&#8203;19782](astral-sh/uv#19782))
  - Reject duplicate entries in conflict sets ([#&#8203;19801](astral-sh/uv#19801))
  - Reject malformed hash options in requirements files ([#&#8203;19783](astral-sh/uv#19783))
  - Reject source distribution filenames without a separator ([#&#8203;19803](astral-sh/uv#19803))
  - Use UTF-8 lengths for requirement errors ([#&#8203;19781](astral-sh/uv#19781))
  - Use UTF-8 lengths for trailing marker errors ([#&#8203;19796](astral-sh/uv#19796))
  - Use byte offsets when peeking over requirements ([#&#8203;19780](astral-sh/uv#19780))
  - Validate GraalPy ABI suffixes ([#&#8203;19805](astral-sh/uv#19805))
- Improve wheel entry-point error handling and virtual environment activation quoting
  - Propagate errors when reading wheel entry points ([#&#8203;19794](astral-sh/uv#19794))
  - Quote virtual environment activation paths with shell metacharacters ([#&#8203;19798](astral-sh/uv#19798))

### [`v0.11.20`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#01120)

[Compare Source](astral-sh/uv@0.11.19...0.11.20)

Released on 2026-06-10.

##### Enhancements

- Add `--emit-index-url` and `--emit-find-links` to `uv export` ([#&#8203;18370](astral-sh/uv#18370))
- Add `--find-links` support for `uv pip list` ([#&#8203;16103](astral-sh/uv#16103))
- Group executable install errors during `uv python install` ([#&#8203;19691](astral-sh/uv#19691))
- Use ICF in macOS release builds to reduce binary sizes ([#&#8203;19615](astral-sh/uv#19615))

##### Preview features

- Add initial hidden `uv upgrade` command ([#&#8203;19678](astral-sh/uv#19678))
- Reject Git revisions in `uv upgrade` ([#&#8203;19742](astral-sh/uv#19742))

##### Configuration

- Recognize `UV_NO_INSTALL_PROJECT`, `UV_NO_INSTALL_WORKSPACE`, `UV_NO_INSTALL_LOCAL` ([#&#8203;19323](astral-sh/uv#19323))

##### Performance

- Speed up discovery of large workspaces ([#&#8203;18311](astral-sh/uv#18311))

##### Bug fixes

- Allow unknown preview flags with a warning again ([#&#8203;19669](astral-sh/uv#19669))
- Apply dependency exclusions to direct requirements ([#&#8203;19699](astral-sh/uv#19699))
- Avoid following external symlinks during cache clean ([#&#8203;19682](astral-sh/uv#19682))
- Avoid following symlinks during cache prune ([#&#8203;19543](astral-sh/uv#19543))
- Fix Git cache keys for worktrees and packed refs ([#&#8203;19706](astral-sh/uv#19706))
- Make resolver error handling iterative to avoid stack overflows ([#&#8203;19695](astral-sh/uv#19695))
- Pass `VIRTUAL_ENV` through `cygpath` inside `fish` on Windows ([#&#8203;19703](astral-sh/uv#19703))
- Rebuild explicit local directory tool installs ([#&#8203;19591](astral-sh/uv#19591))
- Validate egg top-level entries as identifiers ([#&#8203;19679](astral-sh/uv#19679))

##### Documentation

- Document `--find-links` caching behavior ([#&#8203;19585](astral-sh/uv#19585))
- Add a small section for malware checks ([#&#8203;19680](astral-sh/uv#19680))

</details>

---

### Configuration

📅 **Schedule**: (in timezone Europe/London)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yMTkuMCIsInVwZGF0ZWRJblZlciI6IjQzLjIxOS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9naXRodWItcmVsZWFzZSIsInR5cGUvcGF0Y2giXX0=-->

Reviewed-on: https://forgejo.hayden.moe/hayden/phoebe/pulls/92
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or improvement to existing functionality preview Experimental behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants