-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Add a "storage" reference document #15954
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e895de4
Add a "storage" reference document
zanieb a4ded8d
expand on the storage documentation and add links back to it
zsol ab18613
reformat
zsol 59fac59
Rewrite the Directory Strategies section
zsol 000243f
review feedback
zsol 132a0ba
Zanie does some restructuring and hopes it isn't offensive
zanieb 746821c
Bullets -> numbers
zsol 5a75ebe
Fix typos in Windows directories and add links to constants
zsol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| # Storage | ||
|
|
||
| uv persists data in several locations on your system. | ||
|
|
||
| ## Directory Strategies | ||
|
|
||
| For determining where to store different types of data, uv follows the | ||
| [XDG](https://specifications.freedesktop.org/basedir-spec/latest/) conventions on Linux and macOS | ||
| and the platform defaults on Windows, with XDG paths where Windows does not have defaults. | ||
| Generally, it's best to configure these rather than each uv-specific storage location. | ||
zsol marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Here's a summary of the locations uv uses on each platform: | ||
|
|
||
| | Purpose | Unix Default | Windows Default | | ||
| | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| | Temporary files and caches | `$XDG_CACHE_HOME/uv` or `~/.cache/uv` if `XDG_CACHE_HOME` is not set | `%LOCALAPPDATA%\uv\cache` | | ||
| | Persistent data | `$XDG_DATA_HOME/uv`, or `~/.local/share/uv` if `XDG_DATA_HOME` is not set, or `.uv` in the current directory if the home directory is unavailable | `%APPDATA%\uv`, unless the legacy `%APPDATA%\uv\data` exists; if the home directory is unavailable, then `.uv` in the current directory is used | | ||
| | User configuration files | `$XDG_CONFIG_HOME/uv` or `~/.config/uv` if `XDG_CONFIG_HOME` is not set | `%APPDATA%\uv` | | ||
| | System configuration files | `$XDG_CONFIG_DIRS/uv` or `/etc/uv` if `XDG_CONFIG_DIRS` is not set | `%PROGRAMDATA%\uv` | | ||
| | Executables | `$XDG_BIN_HOME`, or `$XDG_DATA_HOME/../bin` if the former is not set, or `~/.local/bin` if `XDG_DATA_HOME` is also not set | same as on Unix | | ||
| | Environment | `.venv` in the project or workspace directory | same as on Unix | | ||
|
|
||
| ## Caching | ||
|
|
||
| uv uses a local cache to avoid re-downloading and re-building dependencies. | ||
|
|
||
| By default, the cache is stored according to [the table above](#directory-strategies), and can be | ||
| overridden via command line arguments, environment variables, or settings as detailed in | ||
| [the cache documentation](../concepts/cache.md#cache-directory). | ||
|
|
||
| Use `uv cache dir` to show the current cache directory path. | ||
|
|
||
| It is important for performance for the cache directory to be on the same filesystem as the | ||
| [virtual environments](#project-environments) uv operates on. | ||
|
|
||
| ## Python versions | ||
|
|
||
| uv can download and manage Python versions. | ||
|
|
||
| By default, Python versions are stored as persistent data according to | ||
| [the table above](#directory-strategies), in a `python/` subdirectory, e.g., | ||
| `~/.local/share/uv/python`. | ||
|
|
||
| Use `uv python dir` to show the Python installation directory. | ||
|
|
||
| Use the `UV_PYTHON_INSTALL_DIR` environment variable to configure the installation directory. | ||
zsol marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| !!! note | ||
|
|
||
| Changing where Python is installed will not be automatically reflected in existing virtual environments; they will keep referring to the old location, and will need to be updated manually (e.g. by re-creating them). | ||
|
|
||
| For more details on how uv manages Python versions, see the | ||
| [dedicated documentation page](../concepts/python-versions.md). | ||
|
|
||
| ### Python executables | ||
|
|
||
| uv also supports adding Python executables to your `PATH`. | ||
|
|
||
| By default, Python executables are stored according to [the table above](#directory-strategies). | ||
|
|
||
| Use `uv python dir --bin` to show the Python executable directory. | ||
|
|
||
| Use the `UV_PYTHON_BIN_DIR` environment variable to configure the executable directory. | ||
|
|
||
| ## Tools | ||
|
|
||
| uv can install Python applications as tools using `uv tool install`. | ||
|
|
||
| By default, tools are installed as persistent data according to | ||
| [the table above](#directory-strategies), under a `tools/` subdirectory, e.g., | ||
| `~/.local/share/uv/tools` | ||
|
|
||
| Use `uv tool dir` to show the tool installation directory. | ||
|
|
||
| Use the `UV_TOOL_DIR` environment variable to configure the installation directory. | ||
|
|
||
| For more details, see the [tools documentation](../concepts/tools.md). | ||
|
|
||
| ### Tool executables | ||
|
|
||
| When installing tools, uv will add tools to your `PATH`. | ||
|
|
||
| By default, tool executables are stored according to [the table above](#directory-strategies). | ||
|
|
||
| Use `uv tool dir --bin` to show the tool executable directory. | ||
|
|
||
| Use the `UV_TOOL_BIN_DIR` environment variable to configure the executable directory. | ||
|
|
||
| ## uv | ||
|
|
||
| uv itself is also installed by [the installer](./installer.md) into the executables folder from | ||
| [the table above](#directory-strategies), and this can be overridden via the `UV_INSTALL_DIR` | ||
| environment variable. | ||
|
|
||
| ## Configuration | ||
|
|
||
| uv's behavior (including most of the storage locations on this page) can be configured through | ||
| configuration files stored in standard locations. | ||
|
|
||
| Configuration files are located in the corresponding system- or user-specific locations from | ||
| [the table above](#directory-strategies). | ||
|
|
||
| For more details, see the [configuration files documentation](../concepts/configuration-files.md). | ||
|
|
||
| ## Project environments | ||
|
|
||
| uv creates virtual environments for projects to isolate their dependencies. | ||
|
|
||
| By default, project virtual environments are created in `.venv` within the project directory, and a | ||
| workspace's environment is created with the same name in the workspace root. | ||
|
|
||
| Use the `UV_PROJECT_ENVIRONMENT` environment variable to override this location, which is should be | ||
| either an absolute path, or relative to the workspace root. | ||
|
|
||
| For more details, see the | ||
| [projects environment documentation](../concepts/projects/config.md#project-environment-path). | ||
zanieb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.