Skip to content

Commit

Permalink
Deprecate the --isolated flag (#5466)
Browse files Browse the repository at this point in the history
## Summary

This PR deprecates the `--isolated` flag. The treatment varies across
the APIs:

- For non-preview APIs, we warn but treat it as equivalent to
`--no-config`.
- For preview APIs, we warn and ignore it, with two exceptions...
- For `tool run` and `run` specifically, we don't even warn, because we
can't differentiate the command-specific `--isolated` from the global
`--isolated`.
  • Loading branch information
charliermarsh authored Jul 30, 2024
1 parent f971631 commit 5d727cb
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 71 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
46 changes: 40 additions & 6 deletions crates/uv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use uv_configuration::Concurrency;
use uv_fs::CWD;
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 @@ -67,6 +68,39 @@ async fn run(cli: Cli) -> Result<ExitStatus> {
std::env::set_current_dir(directory)?;
}

// The `--isolated` argument is deprecated on preview APIs, and warns on non-preview APIs.
let deprecated_isolated = if cli.global_args.isolated {
match &*cli.command {
// Supports `--isolated` as its own argument, so we can't warn either way.
Commands::Tool(ToolNamespace {
command: ToolCommand::Run(_),
}) => false,

// Supports `--isolated` as its own argument, so we can't warn either way.
Commands::Project(command) if matches!(**command, ProjectCommand::Run(_)) => false,

// `--isolated` moved to `--no-workspace`.
Commands::Project(command) if matches!(**command, ProjectCommand::Init(_)) => {
warn_user!("The `--isolated` flag is deprecated and has no effect. Instead, use `--no-config` to prevent uv from discovering configuration files or `--no-workspace` to prevent uv from adding the initialized project to the containing workspace.");
false
}

// Preview APIs. Ignore `--isolated` and warn.
Commands::Project(_) | Commands::Tool(_) | Commands::Python(_) => {
warn_user!("The `--isolated` flag is deprecated and has no effect. Instead, use `--no-config` to prevent uv from discovering configuration files.");
false
}

// Non-preview APIs. Continue to support `--isolated`, but warn.
_ => {
warn_user!("The `--isolated` flag is deprecated. Instead, use `--no-config` to prevent uv from discovering configuration files.");
true
}
}
} else {
false
};

// Load configuration from the filesystem, prioritizing (in order):
// 1. The configuration file specified on the command-line.
// 2. The configuration file in the current workspace (i.e., the `pyproject.toml` or `uv.toml`
Expand All @@ -77,7 +111,7 @@ async fn run(cli: Cli) -> Result<ExitStatus> {
// search for `pyproject.toml` files, since we're not in a workspace.
let filesystem = if let Some(config_file) = cli.config_file.as_ref() {
Some(FilesystemOptions::from_file(config_file)?)
} else if cli.global_args.isolated || cli.no_config {
} else if deprecated_isolated || cli.no_config {
None
} else if let Ok(project) = Workspace::discover(&CWD, &DiscoveryOptions::default()).await {
let project = FilesystemOptions::from_directory(project.install_path())?;
Expand Down Expand Up @@ -654,7 +688,7 @@ async fn run(cli: Cli) -> Result<ExitStatus> {
args.python,
args.settings,
invocation_source,
args.isolated || globals.isolated,
args.isolated,
globals.preview,
globals.python_preference,
globals.python_fetch,
Expand Down Expand Up @@ -780,7 +814,7 @@ async fn run(cli: Cli) -> Result<ExitStatus> {
globals.native_tls,
globals.connectivity,
globals.preview,
cli.no_config || globals.isolated,
cli.no_config,
printer,
)
.await
Expand Down Expand Up @@ -826,7 +860,7 @@ async fn run(cli: Cli) -> Result<ExitStatus> {
args.resolved,
globals.python_preference,
globals.preview,
args.no_workspace || globals.isolated,
args.no_workspace,
&cache,
printer,
)
Expand Down Expand Up @@ -876,7 +910,7 @@ async fn run_project(
args.r#virtual,
args.no_readme,
args.python,
args.no_workspace || globals.isolated,
args.no_workspace,
globals.preview,
globals.python_preference,
globals.python_fetch,
Expand Down Expand Up @@ -916,7 +950,7 @@ async fn run_project(
args.frozen,
args.isolated,
args.package,
args.no_project || globals.isolated,
args.no_project,
args.extras,
args.dev,
args.python,
Expand Down
2 changes: 0 additions & 2 deletions crates/uv/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ pub(crate) struct GlobalSettings {
pub(crate) color: ColorChoice,
pub(crate) native_tls: bool,
pub(crate) connectivity: Connectivity,
pub(crate) isolated: bool,
pub(crate) show_settings: bool,
pub(crate) preview: PreviewMode,
pub(crate) python_preference: PythonPreference,
Expand Down Expand Up @@ -108,7 +107,6 @@ impl GlobalSettings {
} else {
Connectivity::Online
},
isolated: args.isolated,
show_settings: args.show_settings,
preview,
python_preference: args
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
5 changes: 5 additions & 0 deletions crates/uv/tests/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,9 @@ fn init_isolated() -> Result<()> {
----- stdout -----
----- stderr -----
warning: The `--isolated` flag is deprecated and has no effect. Instead, use `--no-config` to prevent uv from discovering configuration files or `--no-workspace` to prevent uv from adding the initialized project to the containing workspace.
warning: `uv init` is experimental and may change without warning
Adding `foo` as member of workspace `[TEMP_DIR]/`
Initialized project `foo`
"###);

Expand All @@ -627,6 +629,9 @@ fn init_isolated() -> Result<()> {
name = "project"
version = "0.1.0"
requires-python = ">=3.12"
[tool.uv.workspace]
members = ["foo"]
"###
);
});
Expand Down
Loading

0 comments on commit 5d727cb

Please sign in to comment.