Skip to content

Package by default: Stabilize preview feature#19197

Open
konstin wants to merge 2 commits into
mainfrom
konsti/package-by-default-stabilize
Open

Package by default: Stabilize preview feature#19197
konstin wants to merge 2 commits into
mainfrom
konsti/package-by-default-stabilize

Conversation

@konstin

@konstin konstin commented Apr 27, 2026

Copy link
Copy Markdown
Member

Prepare the changes when stabilizing package by default, as a preview how this looks after stabilization.

I've updated the snapshots of other uv init-using test to using packaged projects (separate commit), they don't seem to be testing unpacked cases specifically and using the defaults seems the most realistic choice for them.

To be merged with the next breaking release.

@konstin konstin added the breaking A breaking change label Apr 27, 2026
@konstin
konstin force-pushed the konsti/package-by-default-stabilize branch from 7bc0276 to 373247a Compare April 27, 2026 20:32
@konstin
konstin force-pushed the konsti/package-by-default branch from a3cbb2d to 8e7f3b9 Compare April 27, 2026 20:33
@konstin
konstin force-pushed the konsti/package-by-default-stabilize branch 2 times, most recently from d03f429 to 9206638 Compare April 27, 2026 20:46
@konstin konstin changed the title Stabilize package by default Package by default: Stabilize preview feature Apr 27, 2026
@konstin
konstin force-pushed the konsti/package-by-default-stabilize branch 2 times, most recently from ebdc505 to 5fb3a93 Compare April 27, 2026 22:19
@konstin
konstin force-pushed the konsti/package-by-default branch from 77ed055 to e44f8c1 Compare April 27, 2026 23:20
@konstin
konstin force-pushed the konsti/package-by-default-stabilize branch from 5fb3a93 to 4bef47b Compare April 27, 2026 23:24
@konstin
konstin force-pushed the konsti/package-by-default branch from e44f8c1 to 9ee4139 Compare May 16, 2026 20:38
@konstin
konstin force-pushed the konsti/package-by-default branch from 386eac8 to b6c5328 Compare June 1, 2026 11:01
@konstin
konstin force-pushed the konsti/package-by-default branch 2 times, most recently from f7dd196 to 39c1221 Compare June 9, 2026 14:20
konstin added a commit that referenced this pull request Jun 10, 2026
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:

* main <- konsti/package-by-default
  #17841
* konsti/package-by-default <- konsti/package-by-default-doc-changes
  #19026
* konsti/package-by-default <- konsti/package-by-default-stabilize
  #19197


**~~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.
Base automatically changed from konsti/package-by-default to main June 10, 2026 08:26
@konstin
konstin force-pushed the konsti/package-by-default-stabilize branch 2 times, most recently from a334f9e to c6c098d Compare June 10, 2026 08:38
@konstin
konstin force-pushed the konsti/package-by-default-stabilize branch from c6c098d to e6abc57 Compare June 11, 2026 09:46
@konstin
konstin marked this pull request as ready for review June 23, 2026 11:40
@konstin konstin added this to the v0.12.0 milestone Jun 23, 2026
@konstin konstin mentioned this pull request Jun 26, 2026
konstin added a commit that referenced this pull request Jun 26, 2026
Package by default: Stabilize preview feature
konstin added a commit that referenced this pull request Jun 26, 2026
Package by default: Stabilize preview feature
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking A breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant