Update docs on `.python-version` file (#7051)

## Summary

Closes https://github.com/astral-sh/uv/issues/7027

* When displaying the file structure of a uv-managed project show the
`.python-version` file which is now created by default.
* Mention the purpose of the `.python-version` file in `Guides/Working
on projects/Project structure`
* In `Concepts/Python versions/Project python versions`, changed
sentence about `.python-version` file to reflect the fact it is included
by default so is likely to be present.
This commit is contained in:
my1e5 2024-09-05 00:22:34 +01:00 committed by GitHub
parent 20c666c10d
commit 86c8906d10
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 2 deletions

View File

@ -106,6 +106,7 @@ Applications are the default target for `uv init`, but can also be specified wit
$ uv init --app example-app $ uv init --app example-app
$ tree example-app $ tree example-app
example-app example-app
├── .python-version
├── README.md ├── README.md
├── hello.py ├── hello.py
└── pyproject.toml └── pyproject.toml
@ -155,6 +156,7 @@ Libraries can be created by using the `--lib` flag:
$ uv init --lib example-lib $ uv init --lib example-lib
$ tree example-lib $ tree example-lib
example-lib example-lib
├── .python-version
├── README.md ├── README.md
├── pyproject.toml ├── pyproject.toml
└── src └── src
@ -217,6 +219,7 @@ The project structure looks the same as a library:
$ uv init --app --package example-packaged-app $ uv init --app --package example-packaged-app
$ tree example-packaged-app $ tree example-packaged-app
example-packaged-app example-packaged-app
├── .python-version
├── README.md ├── README.md
├── pyproject.toml ├── pyproject.toml
└── src └── src

View File

@ -96,8 +96,8 @@ are used for requesting local interpreters such as a file path.
By default `uv python install` will verify that a managed Python version is installed or install the By default `uv python install` will verify that a managed Python version is installed or install the
latest version. latest version.
However, a project may define a `.python-version` file specifying the default Python version to be However, a project may include a `.python-version` file specifying a default Python version. If
used. If present, uv will install the Python version listed in the file. present, uv will install the Python version listed in the file.
Alternatively, a project that requires multiple Python versions may also define a `.python-versions` Alternatively, a project that requires multiple Python versions may also define a `.python-versions`
file. If present, uv will install all of the Python versions listed in the file. This file takes file. If present, uv will install all of the Python versions listed in the file. This file takes

View File

@ -23,6 +23,7 @@ uv will create the following files:
```text ```text
. .
├── .python-version
├── README.md ├── README.md
├── hello.py ├── hello.py
└── pyproject.toml └── pyproject.toml
@ -50,6 +51,7 @@ A complete listing would look like:
│   ├── bin │   ├── bin
│   ├── lib │   ├── lib
│   └── pyvenv.cfg │   └── pyvenv.cfg
├── .python-version
├── README.md ├── README.md
├── hello.py ├── hello.py
├── pyproject.toml ├── pyproject.toml
@ -81,6 +83,11 @@ description or license. You can edit this file manually, or use commands like `u
You'll also use this file to specify uv [configuration options](../configuration/files.md) in a You'll also use this file to specify uv [configuration options](../configuration/files.md) in a
[`[tool.uv]`](../reference/settings.md) section. [`[tool.uv]`](../reference/settings.md) section.
### `.python-version`
The `.python-version` file contains the project's default Python version. This file tells uv which
Python version to use when creating the project's virtual environment.
### `.venv` ### `.venv`
The `.venv` folder contains your project's virtual environment, a Python environment that is The `.venv` folder contains your project's virtual environment, a Python environment that is