Bundle of docs changes (#5426)

This commit is contained in:
Zanie Blue 2024-07-24 18:10:33 -04:00 committed by GitHub
parent ac81036aa9
commit 3581e27cdf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 127 additions and 102 deletions

View file

@ -2,6 +2,10 @@
If Python is already installed on your system, uv will [detect and use](#using-an-existing-python-installation) it without configuration. However, uv can also install and manage Python versions for you.
!!! tip
uv will [automatically fetch Python versions](#automatic-python-downloads) as needed — you don't need to install Python to get started.
To install the latest Python version:
```console
@ -59,10 +63,10 @@ Note that Python does not need to be explicitly installed to use uv. By default,
$ uv run --python 3.12 python -c 'print("hello world")'
```
Even if a specific Python version is not requested, uv will download the latest version on demand. For example, the following will create a new virtual environment and download a managed Python version if one hasn't been installed yet:
Even if a specific Python version is not requested, uv will download the latest version on demand. For example, the following will create a new virtual environment and download a managed Python version if Python is not found:
```console
$ uv venv --python-preference only-managed
$ uv venv
```
<!-- TODO(zanieb): Restore when Python shim management is added

26
docs/guides/overview.md Normal file
View file

@ -0,0 +1,26 @@
# Overview
Check out one of the core guides to get started:
- [Installing Python versions](./install-python.md)
- [Running scripts and declaring dependencies](./scripts.md)
- [Running and installing applications as tools](./tools.md)
- [Creating and working on projects](./projects.md)
Learn how to integrate uv with other software:
- [Using in Docker images](./integration/docker.md)
- [Using with pre-commit](./integration/pre-commit.md)
- [Using in GitHub Actions](./integration/github.md)
- [Using with commercial package indexes](./integration/commercial-indexes.md)
Or, explore the concept documentation for comprehensive breakdown of each feature:
- [Projects](../projects.md)
- [Dependencies](../dependencies.md)
- [Workspaces](../workspaces.md)
- [Tools](../tools.md)
- [Python versions](../python-versions.md)
- [Resolution](../resolution.md)
- [Caching](../cache.md)
- [Authentication](../configuration/authentication.md)

View file

@ -1,6 +1,6 @@
# Working on projects
uv is capable of managing Python projects following the `pyproject.toml` standard.
uv is capable of managing Python projects using a `pyproject.toml` with a `[project]` metadata table.
## Creating a new project
@ -69,6 +69,10 @@ such as it's description or license. You can edit this file manually, or use
commands like `uv add` and `uv remove` to manage your project through the
CLI.
!!! tip
See the official [`pyproject.toml` guide](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/) for more details on getting started with the `pyproject.toml` format.
### `.venv`
The `.venv` folder contains your project's virtual environment, a Python
@ -102,9 +106,14 @@ virtual environment before executing a command:
```console
$ uv sync
$ source .venv/bin/active
$ python my_script.py
```
!!! note
The virtual environment must be active to run scripts and commands in the project without `uv run`. Virtual environment activation differs per shell and platform.
## Managing dependencies
You can add dependencies to your `pyproject.toml` with the `uv add` command.

View file

@ -102,7 +102,7 @@ Note that if `uv run` is used in a _project_, these dependencies will be include
Python recently added a standard format for [inline script metadata](https://packaging.python.org/en/latest/specifications/inline-script-metadata/#inline-script-metadata). This allows the dependencies for a script to be declared in the script itself.
To use inline script metadata, include a `script` section at the top of the script:
To use inline script metadata, include a `script` section at the top of the script and declare the dependencies using TOML:
```python title="example.py"
# /// script

View file

@ -1,6 +1,6 @@
# Using tools
Many Python packages provide command-line interfaces which are useful as standalone tools. uv has specialized support for easily invoking and installing tools.
Many Python packages provide applications that can be used as tools. uv has specialized support for easily invoking and installing tools.
## Using `uvx`
@ -90,7 +90,7 @@ $ uvx --with mkdocs-material mkdocs --help
## Installing tools
If a tool is used often, it can be useful to install it to a persistent environment instead of invoking `uvx` repeatedly.
If a tool is used often, it can be useful to install it to a persistent environment and add it to the `PATH` instead of invoking `uvx` repeatedly.
To install `ruff`: