mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-01 09:32:18 +00:00
Remove --isolated
usages from the uv python
API (#5468)
This commit is contained in:
parent
5830a532ef
commit
f7494f24cf
5 changed files with 17 additions and 15 deletions
|
@ -2485,6 +2485,11 @@ pub struct PythonPinArgs {
|
||||||
|
|
||||||
#[arg(long, overrides_with("no_resolved"), hide = true)]
|
#[arg(long, overrides_with("no_resolved"), hide = true)]
|
||||||
pub no_resolved: bool,
|
pub no_resolved: bool,
|
||||||
|
|
||||||
|
/// Avoid validating the Python pin against the workspace in the current directory or any parent
|
||||||
|
/// directory.
|
||||||
|
#[arg(long)]
|
||||||
|
pub no_workspace: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args)]
|
#[derive(Args)]
|
||||||
|
|
|
@ -8,7 +8,6 @@ use std::collections::BTreeSet;
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
use uv_cache::Cache;
|
|
||||||
use uv_client::Connectivity;
|
use uv_client::Connectivity;
|
||||||
use uv_configuration::PreviewMode;
|
use uv_configuration::PreviewMode;
|
||||||
use uv_fs::CWD;
|
use uv_fs::CWD;
|
||||||
|
@ -31,8 +30,7 @@ pub(crate) async fn install(
|
||||||
native_tls: bool,
|
native_tls: bool,
|
||||||
connectivity: Connectivity,
|
connectivity: Connectivity,
|
||||||
preview: PreviewMode,
|
preview: PreviewMode,
|
||||||
isolated: bool,
|
no_config: bool,
|
||||||
_cache: &Cache,
|
|
||||||
printer: Printer,
|
printer: Printer,
|
||||||
) -> Result<ExitStatus> {
|
) -> Result<ExitStatus> {
|
||||||
if preview.is_disabled() {
|
if preview.is_disabled() {
|
||||||
|
@ -47,12 +45,12 @@ pub(crate) async fn install(
|
||||||
|
|
||||||
let targets = targets.into_iter().collect::<BTreeSet<_>>();
|
let targets = targets.into_iter().collect::<BTreeSet<_>>();
|
||||||
let requests: Vec<_> = if targets.is_empty() {
|
let requests: Vec<_> = if targets.is_empty() {
|
||||||
// Read from the version file, unless `isolated` was requested
|
// Read from the version file, unless `--no-config` was requested
|
||||||
let version_file_requests = if isolated {
|
let version_file_requests = if no_config {
|
||||||
if PathBuf::from(PYTHON_VERSION_FILENAME).exists() {
|
if PathBuf::from(PYTHON_VERSION_FILENAME).exists() {
|
||||||
debug!("Ignoring `.python-version` file due to isolated mode");
|
debug!("Ignoring `.python-version` file due to `--no-config`");
|
||||||
} else if PathBuf::from(PYTHON_VERSIONS_FILENAME).exists() {
|
} else if PathBuf::from(PYTHON_VERSIONS_FILENAME).exists() {
|
||||||
debug!("Ignoring `.python-versions` file due to isolated mode");
|
debug!("Ignoring `.python-versions` file due to `--no-config`");
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -25,7 +25,7 @@ pub(crate) async fn pin(
|
||||||
resolved: bool,
|
resolved: bool,
|
||||||
python_preference: PythonPreference,
|
python_preference: PythonPreference,
|
||||||
preview: PreviewMode,
|
preview: PreviewMode,
|
||||||
isolated: bool,
|
no_workspace: bool,
|
||||||
cache: &Cache,
|
cache: &Cache,
|
||||||
printer: Printer,
|
printer: Printer,
|
||||||
) -> Result<ExitStatus> {
|
) -> Result<ExitStatus> {
|
||||||
|
@ -33,7 +33,7 @@ pub(crate) async fn pin(
|
||||||
warn_user_once!("`uv python pin` is experimental and may change without warning");
|
warn_user_once!("`uv python pin` is experimental and may change without warning");
|
||||||
}
|
}
|
||||||
|
|
||||||
let virtual_project = if isolated {
|
let virtual_project = if no_workspace {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
match VirtualProject::discover(&CWD, &DiscoveryOptions::default()).await {
|
match VirtualProject::discover(&CWD, &DiscoveryOptions::default()).await {
|
||||||
|
|
|
@ -773,17 +773,13 @@ async fn run(cli: Cli) -> Result<ExitStatus> {
|
||||||
let args = settings::PythonInstallSettings::resolve(args, filesystem);
|
let args = settings::PythonInstallSettings::resolve(args, filesystem);
|
||||||
show_settings!(args);
|
show_settings!(args);
|
||||||
|
|
||||||
// Initialize the cache.
|
|
||||||
let cache = cache.init()?;
|
|
||||||
|
|
||||||
commands::python_install(
|
commands::python_install(
|
||||||
args.targets,
|
args.targets,
|
||||||
args.reinstall,
|
args.reinstall,
|
||||||
globals.native_tls,
|
globals.native_tls,
|
||||||
globals.connectivity,
|
globals.connectivity,
|
||||||
globals.preview,
|
globals.preview,
|
||||||
globals.isolated,
|
cli.no_config || globals.isolated,
|
||||||
&cache,
|
|
||||||
printer,
|
printer,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
@ -829,7 +825,7 @@ async fn run(cli: Cli) -> Result<ExitStatus> {
|
||||||
args.resolved,
|
args.resolved,
|
||||||
globals.python_preference,
|
globals.python_preference,
|
||||||
globals.preview,
|
globals.preview,
|
||||||
globals.isolated,
|
args.no_workspace || globals.isolated,
|
||||||
&cache,
|
&cache,
|
||||||
printer,
|
printer,
|
||||||
)
|
)
|
||||||
|
|
|
@ -503,6 +503,7 @@ impl PythonFindSettings {
|
||||||
pub(crate) struct PythonPinSettings {
|
pub(crate) struct PythonPinSettings {
|
||||||
pub(crate) request: Option<String>,
|
pub(crate) request: Option<String>,
|
||||||
pub(crate) resolved: bool,
|
pub(crate) resolved: bool,
|
||||||
|
pub(crate) no_workspace: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PythonPinSettings {
|
impl PythonPinSettings {
|
||||||
|
@ -513,11 +514,13 @@ impl PythonPinSettings {
|
||||||
request,
|
request,
|
||||||
no_resolved,
|
no_resolved,
|
||||||
resolved,
|
resolved,
|
||||||
|
no_workspace,
|
||||||
} = args;
|
} = args;
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
request,
|
request,
|
||||||
resolved: flag(resolved, no_resolved).unwrap_or(false),
|
resolved: flag(resolved, no_resolved).unwrap_or(false),
|
||||||
|
no_workspace,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue