Add --bare option to uv init (#11192)

People are looking for a less opinionated version of `uv init`. The goal
here is to create a `pyproject.toml` and nothing else. With the `--lib`
or `--package` flags, we'll still configure a build backend but we won't
create the source tree. This disables things like the default
`description`, author behavior, and VCS.

See

- https://github.com/astral-sh/uv/issues/8178
- https://github.com/astral-sh/uv/issues/7181
- https://github.com/astral-sh/uv/issues/6750
This commit is contained in:
Zanie Blue
2025-02-05 10:12:27 -06:00
committed by GitHub
parent 989b103171
commit acbbb2b82a
7 changed files with 311 additions and 13 deletions
+36
View File
@@ -295,3 +295,39 @@ Hello from example-ext!
Changes to the extension code in `lib.rs` or `main.cpp` will require running `--reinstall` to
rebuild them.
## Creating a minimal project
If you only want to create a `pyproject.toml`, use the `--bare` option:
```console
$ uv init example --bare
```
uv will skip creating a Python version pin file, a README, and any source directories or files.
Additionally, uv will not initialize a version control system (i.e., `git`).
```console
$ tree example-bare
example-bare
└── pyproject.toml
```
uv will also not add extra metadata to the `pyproject.toml`, such as the `description` or `authors`.
```toml
[project]
name = "example"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = []
```
The `--bare` option can be used with other options like `--lib` or `--build-backend` — in these
cases uv will still configure a build system but will not create the expected file structure.
When `--bare` is used, additional features can still be used opt-in:
```console
$ uv init example --description "Hello world" --author-from git --vcs git
```