Skip to content

Commit

Permalink
Deprecate the --isolated flag
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Jul 29, 2024
1 parent 99638ad commit abf2d17
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 46 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/sync-python-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
- uses: hynek/setup-cached-uv@v2
- name: Sync Python Releases
run: |
uv run --isolated -- fetch-download-metadata.py
uv run --isolated -- template-download-metadata.py
uv run -- fetch-download-metadata.py
uv run -- template-download-metadata.py
working-directory: ./crates/uv-python
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ project-level settings appearing earlier in the merged array.
Settings provided via environment variables take precedence over persistent configuration, and
settings provided via the command line take precedence over both.

uv accepts a `--isolated` command-line argument which, when provided, disables the discovery of any
uv accepts a `--no-config` command-line argument which, when provided, disables the discovery of any
persistent configuration.

uv also accepts a `--config-file` command-line argument, which accepts a path to a `uv.toml` to use
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ pub struct GlobalArgs {

/// Avoid discovering a `pyproject.toml` or `uv.toml` file in the current directory or any
/// parent directories.
#[arg(global = true, long)]
#[arg(global = true, long, hide = true)]
pub isolated: bool,

/// Show the resolved settings for the current command.
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-python/fetch-download-metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Usage:
uv run --isolated -- crates/uv-python/fetch-download-metadata.py
uv run -- crates/uv-python/fetch-download-metadata.py
Acknowledgements:
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-python/template-download-metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Usage:
uv run --isolated -- crates/uv-python/template-download-metadata.py
uv run -- crates/uv-python/template-download-metadata.py
"""

import argparse
Expand Down
9 changes: 9 additions & 0 deletions crates/uv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use uv_cli::{SelfCommand, SelfNamespace};
use uv_configuration::Concurrency;
use uv_requirements::RequirementsSource;
use uv_settings::{Combine, FilesystemOptions};
use uv_warnings::warn_user;
use uv_workspace::{DiscoveryOptions, Workspace};

use crate::commands::{ExitStatus, ToolRunCommand};
Expand Down Expand Up @@ -136,6 +137,14 @@ async fn run(cli: Cli) -> Result<ExitStatus> {
)
}))?;

if globals.isolated {
if globals.preview.is_enabled() {
warn_user!("The `--isolated` flag is deprecated. Instead, use `--no-config` to prevent uv from discovering configuration files, or `--no-workspace` to prevent uv from discovering a workspace in `uv run` and other commands.");
} else {
warn_user!("The `--isolated` flag is deprecated. Instead, use `--no-config` to prevent uv from discovering configuration files.");
}
}

debug!("uv {}", version::version());

// Write out any resolved settings.
Expand Down
29 changes: 0 additions & 29 deletions crates/uv/tests/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ fn help() {
--python-fetch <PYTHON_FETCH>
Whether to automatically download Python when required [possible values: automatic,
manual]
--isolated
Avoid discovering a `pyproject.toml` or `uv.toml` file in the current directory or any
parent directories
--no-progress
Hides all progress outputs when set
-n, --no-cache
Expand Down Expand Up @@ -109,9 +106,6 @@ fn help_flag() {
--python-fetch <PYTHON_FETCH>
Whether to automatically download Python when required [possible values: automatic,
manual]
--isolated
Avoid discovering a `pyproject.toml` or `uv.toml` file in the current directory or any
parent directories
--no-progress
Hides all progress outputs when set
-n, --no-cache
Expand Down Expand Up @@ -174,9 +168,6 @@ fn help_short_flag() {
--python-fetch <PYTHON_FETCH>
Whether to automatically download Python when required [possible values: automatic,
manual]
--isolated
Avoid discovering a `pyproject.toml` or `uv.toml` file in the current directory or any
parent directories
--no-progress
Hides all progress outputs when set
-n, --no-cache
Expand Down Expand Up @@ -280,10 +271,6 @@ fn help_subcommand() {
- manual: Do not automatically fetch managed Python installations; require explicit
installation
--isolated
Avoid discovering a `pyproject.toml` or `uv.toml` file in the current directory or any
parent directories
--no-progress
Hides all progress outputs when set
Expand Down Expand Up @@ -408,10 +395,6 @@ fn help_subsubcommand() {
- manual: Do not automatically fetch managed Python installations; require explicit
installation
--isolated
Avoid discovering a `pyproject.toml` or `uv.toml` file in the current directory or any
parent directories
--no-progress
Hides all progress outputs when set
Expand Down Expand Up @@ -490,9 +473,6 @@ fn help_flag_subcommand() {
--python-fetch <PYTHON_FETCH>
Whether to automatically download Python when required [possible values: automatic,
manual]
--isolated
Avoid discovering a `pyproject.toml` or `uv.toml` file in the current directory or any
parent directories
--no-progress
Hides all progress outputs when set
-n, --no-cache
Expand Down Expand Up @@ -552,9 +532,6 @@ fn help_flag_subsubcommand() {
--python-fetch <PYTHON_FETCH>
Whether to automatically download Python when required [possible values: automatic,
manual]
--isolated
Avoid discovering a `pyproject.toml` or `uv.toml` file in the current directory or any
parent directories
--no-progress
Hides all progress outputs when set
-n, --no-cache
Expand Down Expand Up @@ -671,9 +648,6 @@ fn help_with_global_option() {
--python-fetch <PYTHON_FETCH>
Whether to automatically download Python when required [possible values: automatic,
manual]
--isolated
Avoid discovering a `pyproject.toml` or `uv.toml` file in the current directory or any
parent directories
--no-progress
Hides all progress outputs when set
-n, --no-cache
Expand Down Expand Up @@ -770,9 +744,6 @@ fn test_with_no_pager() {
--python-fetch <PYTHON_FETCH>
Whether to automatically download Python when required [possible values: automatic,
manual]
--isolated
Avoid discovering a `pyproject.toml` or `uv.toml` file in the current directory or any
parent directories
--no-progress
Hides all progress outputs when set
-n, --no-cache
Expand Down
1 change: 1 addition & 0 deletions crates/uv/tests/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ fn init_isolated() -> Result<()> {
----- stdout -----
----- stderr -----
warning: The `--isolated` flag is deprecated. Instead, use `--no-config` to prevent uv from discovering configuration files.
warning: `uv init` is experimental and may change without warning
Initialized project `foo`
"###);
Expand Down
4 changes: 2 additions & 2 deletions docs/concepts/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ Installation of tools will not overwrite executables in the `bin` directory that
The invocation `uv tool run <name>` is nearly equivalent to:

```console
$ uv run --isolated --with <name> -- <name>
$ uv run --no-project --with <name> -- <name>
```

However, there are a couple notable differences when using uv's tool interface:

- The `--with` option is not needed — the required package is inferred from the command name.
- The temporary environment is cached in a dedicated location.
- The `--isolated` flag is not needed — tools are always run isolated from the project.
- The `--no-project` flag is not needed — tools are always run isolated from the project.
- If a tool is already installed, `uv tool run` will use the installed version but `uv run` will not.
2 changes: 1 addition & 1 deletion docs/concepts/workspaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Workspaces help organize large codebases by splitting them into multiple package
independent dependencies.

When using the `uv pip` interface, workspace dependencies behave like automatic editable path
dependencies. Using the uv project interface, all of the workspace packages are locked together.
dependencies. Using the uv project interface, all workspace packages are locked together.
`uv run` installs only the current package (unless overridden with `--package`) and its workspace and
non-workspace dependencies.

Expand Down
2 changes: 1 addition & 1 deletion docs/configuration/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ project-level settings appearing earlier in the merged array.
Settings provided via environment variables take precedence over persistent configuration, and
settings provided via the command line take precedence over both.

uv accepts a `--isolated` command-line argument which, when provided, disables the discovery of any
uv accepts a `--no-config` command-line argument which, when provided, disables the discovery of any
persistent configuration.

uv also accepts a `--config-file` command-line argument, which accepts a path to a `uv.toml` to use
Expand Down
10 changes: 5 additions & 5 deletions docs/guides/scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ $ uv run example.py hello world!
hello world!
```

Note that if you use `uv run` in a _project_, i.e. a directory with a `pyproject.toml`, it will install the current project before running the script. If your script does not depend on the project, use the `--isolated` flag to skip this:
Note that if you use `uv run` in a _project_, i.e. a directory with a `pyproject.toml`, it will install the current project before running the script. If your script does not depend on the project, use the `--no-project` flag to skip this:

```console
# Note, it is important that the flag comes _before_ the script
$ uv run --isolated example.py
$ uv run --no-project example.py
```

See the [projects guide](./projects.md) for more details on working in projects.
Expand All @@ -74,7 +74,7 @@ for i in track(range(20), description="For example:"):
If executed without specifying a dependency, this script will fail:

```console
$ uv run --isolated example.py
$ uv run --no-project example.py
Traceback (most recent call last):
File "/Users/astral/example.py", line 2, in <module>
from rich.progress import track
Expand All @@ -96,7 +96,7 @@ $ uv run --with 'rich>12,<13' example.py

Multiple dependencies can be requested by repeating with `--with` option.

Note that if `uv run` is used in a _project_, these dependencies will be included _in addition_ to the project's dependencies. To opt-out of this behavior, use the `--isolated` flag.
Note that if `uv run` is used in a _project_, these dependencies will be included _in addition_ to the project's dependencies. To opt-out of this behavior, use the `--no-project` flag.

## Declaring script dependencies

Expand Down Expand Up @@ -153,7 +153,7 @@ print(Point)

uv will fetch the required Python version if it is not installed — see the documentation on [Python versions](../concepts/python-versions.md) for more details. Note that the `dependencies` field must be provided even if empty.

Note that when using inline script metadata, even if `uv run` is used in a _project_, the project's dependencies will be ignored. The `--isolated` flag is not required.
Note that when using inline script metadata, even if `uv run` is used in a _project_, the project's dependencies will be ignored. The `--no-project` flag is not required.

## Using different Python versions

Expand Down
4 changes: 2 additions & 2 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ echo "Updating metadata with rooster..."
cd "$project_root"

# Update the preview changelog
uv tool run --from 'rooster-blue>=0.0.7' --python 3.12 --isolated -- \
uv tool run --from 'rooster-blue>=0.0.7' --python 3.12 -- \
rooster release "$@" \
--only-sections preview \
--changelog-file PREVIEW-CHANGELOG.md \
--no-update-pyproject --no-update-version-files

# Update the real changelog
uv tool run --from 'rooster-blue>=0.0.7' --python 3.12 --isolated -- \
uv tool run --from 'rooster-blue>=0.0.7' --python 3.12 -- \
rooster release "$@" --without-sections preview

echo "Updating lockfile..."
Expand Down

0 comments on commit abf2d17

Please sign in to comment.