mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 02:48:17 +00:00
Add --app
and --lib
options to uv init
(#6689)
Changes the `uv init` experience with a focus on working for more use-cases out of the box. - Adds `--app` and `--lib` options to control the created project style - Changes the default from a library with `src/` and a build backend (`--lib`) to an application that is not packaged (`--app`) - Hides the `--virtual` option and replaces it with `--package` and `--no-package` - `--no-package` is not allowed with `--lib` right now, but it could be in the future once we understand a use-case - Creates a runnable project - Applications have a `hello.py` file which you can run with `uv run hello.py` - Packaged applications, e.g., `uv init --app --package` create a package and script entrypoint, which you can run with `uv run hello` - Libraries provide a demo API function, e.g., `uv run python -c "import name; print(name.hello())"` — this is unchanged Closes #6471
This commit is contained in:
parent
8d466db080
commit
bc5b069a61
7 changed files with 726 additions and 120 deletions
|
@ -372,7 +372,15 @@ uv init [OPTIONS] [PATH]
|
|||
|
||||
<h3 class="cli-reference">Options</h3>
|
||||
|
||||
<dl class="cli-reference"><dt><code>--cache-dir</code> <i>cache-dir</i></dt><dd><p>Path to the cache directory.</p>
|
||||
<dl class="cli-reference"><dt><code>--app</code></dt><dd><p>Create a project for an application.</p>
|
||||
|
||||
<p>This is the default behavior if <code>--lib</code> is not requested.</p>
|
||||
|
||||
<p>This project kind is for web servers, scripts, and command-line interfaces.</p>
|
||||
|
||||
<p>By default, an application is not intended to be built and distributed as a Python package. The <code>--package</code> option can be used to create an application that is distributable, e.g., if you want to distribute a command-line interface via PyPI.</p>
|
||||
|
||||
</dd><dt><code>--cache-dir</code> <i>cache-dir</i></dt><dd><p>Path to the cache directory.</p>
|
||||
|
||||
<p>Defaults to <code>$HOME/Library/Caches/uv</code> on macOS, <code>$XDG_CACHE_HOME/uv</code> or <code>$HOME/.cache/uv</code> on Linux, and <code>%LOCALAPPDATA%\uv\cache</code> on Windows.</p>
|
||||
|
||||
|
@ -394,6 +402,10 @@ uv init [OPTIONS] [PATH]
|
|||
|
||||
</dd><dt><code>--help</code>, <code>-h</code></dt><dd><p>Display the concise help for this command</p>
|
||||
|
||||
</dd><dt><code>--lib</code></dt><dd><p>Create a project for a library.</p>
|
||||
|
||||
<p>A library is a project that is intended to be built and distributed as a Python package.</p>
|
||||
|
||||
</dd><dt><code>--name</code> <i>name</i></dt><dd><p>The name of the project.</p>
|
||||
|
||||
<p>Defaults to the name of the directory.</p>
|
||||
|
@ -410,6 +422,12 @@ uv init [OPTIONS] [PATH]
|
|||
|
||||
<p>Normally, configuration files are discovered in the current directory, parent directories, or user configuration directories.</p>
|
||||
|
||||
</dd><dt><code>--no-package</code></dt><dd><p>Do not set up the project to be built as a Python package.</p>
|
||||
|
||||
<p>Does not include a <code>[build-system]</code> for the project.</p>
|
||||
|
||||
<p>This is the default behavior when using <code>--app</code>.</p>
|
||||
|
||||
</dd><dt><code>--no-progress</code></dt><dd><p>Hide all progress outputs.</p>
|
||||
|
||||
<p>For example, spinners or progress bars.</p>
|
||||
|
@ -428,6 +446,14 @@ uv init [OPTIONS] [PATH]
|
|||
|
||||
<p>When disabled, uv will only use locally cached data and locally available files.</p>
|
||||
|
||||
</dd><dt><code>--package</code></dt><dd><p>Set up the project to be built as a Python package.</p>
|
||||
|
||||
<p>Defines a <code>[build-system]</code> for the project.</p>
|
||||
|
||||
<p>This is the default behavior when using <code>--lib</code>.</p>
|
||||
|
||||
<p>When using <code>--app</code>, this will include a <code>[project.scripts]</code> entrypoint and use a <code>src/</code> project structure.</p>
|
||||
|
||||
</dd><dt><code>--python</code>, <code>-p</code> <i>python</i></dt><dd><p>The Python interpreter to use to determine the minimum supported Python version.</p>
|
||||
|
||||
<p>See <a href="#uv-python">uv python</a> to view supported request formats.</p>
|
||||
|
@ -455,12 +481,6 @@ uv init [OPTIONS] [PATH]
|
|||
|
||||
</dd><dt><code>--version</code>, <code>-V</code></dt><dd><p>Display the uv version</p>
|
||||
|
||||
</dd><dt><code>--virtual</code></dt><dd><p>Create a virtual project, rather than a package.</p>
|
||||
|
||||
<p>A virtual project is a project that is not intended to be built as a Python package, such as a project that only contains scripts or other application code.</p>
|
||||
|
||||
<p>Virtual projects themselves are not installed into the Python environment.</p>
|
||||
|
||||
</dd></dl>
|
||||
|
||||
## uv add
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue