mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25:00 +00:00
Create empty environment for uv run --isolated
(#4849)
## Summary If you pass `--isolated` but no `--with`, at present, we don't create any environment (so `--python` isn't respected and `python` will fail entirely if it wasn't already in your path). Now, we create a base environment in `--isolated` even if `with` wasn't provided. Closes https://github.com/astral-sh/uv/issues/4846. Closes https://github.com/astral-sh/uv/issues/4776.
This commit is contained in:
parent
1f454f3a67
commit
798ec373c0
1 changed files with 32 additions and 23 deletions
|
@ -231,12 +231,14 @@ pub(crate) async fn run(
|
|||
);
|
||||
}
|
||||
|
||||
// If necessary, create an environment for the ephemeral requirements.
|
||||
// If necessary, create an environment for the ephemeral requirements or command.
|
||||
let temp_dir;
|
||||
let ephemeral_env = if requirements.is_empty() {
|
||||
let ephemeral_env = if requirements.is_empty() && base_interpreter.is_some() {
|
||||
// If we don't have any `--with` requirements, and we already have a base environment, then
|
||||
// there's no need to create an additional environment.
|
||||
None
|
||||
} else {
|
||||
debug!("Syncing ephemeral environment.");
|
||||
debug!("Creating ephemeral environment");
|
||||
|
||||
// Discover an interpreter.
|
||||
let interpreter = if let Some(base_interpreter) = &base_interpreter {
|
||||
|
@ -274,29 +276,36 @@ pub(crate) async fn run(
|
|||
false,
|
||||
)?;
|
||||
|
||||
let client_builder = BaseClientBuilder::new()
|
||||
.connectivity(connectivity)
|
||||
.native_tls(native_tls);
|
||||
if requirements.is_empty() {
|
||||
Some(venv)
|
||||
} else {
|
||||
debug!("Syncing ephemeral requirements");
|
||||
|
||||
let spec =
|
||||
RequirementsSpecification::from_simple_sources(&requirements, &client_builder).await?;
|
||||
let client_builder = BaseClientBuilder::new()
|
||||
.connectivity(connectivity)
|
||||
.native_tls(native_tls);
|
||||
|
||||
// Install the ephemeral requirements.
|
||||
Some(
|
||||
project::update_environment(
|
||||
venv,
|
||||
spec,
|
||||
&settings,
|
||||
&state,
|
||||
preview,
|
||||
connectivity,
|
||||
concurrency,
|
||||
native_tls,
|
||||
cache,
|
||||
printer,
|
||||
let spec =
|
||||
RequirementsSpecification::from_simple_sources(&requirements, &client_builder)
|
||||
.await?;
|
||||
|
||||
// Install the ephemeral requirements.
|
||||
Some(
|
||||
project::update_environment(
|
||||
venv,
|
||||
spec,
|
||||
&settings,
|
||||
&state,
|
||||
preview,
|
||||
connectivity,
|
||||
concurrency,
|
||||
native_tls,
|
||||
cache,
|
||||
printer,
|
||||
)
|
||||
.await?,
|
||||
)
|
||||
.await?,
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
debug!("Running `{command}`");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue