Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/uv-python/src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ impl Interpreter {
sys_prefix: virtualenv.root,
target: None,
prefix: None,
site_packages: vec![],
..self
}
}
Expand Down
81 changes: 81 additions & 0 deletions crates/uv/tests/it/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5958,3 +5958,84 @@ fn run_python_preference_no_project() {
----- stderr -----
");
}

/// Regression test for: <https://github.com/astral-sh/uv/issues/15518>
#[test]
fn isolate_child_environment() -> Result<()> {
let context = TestContext::new("3.12");

let pyproject_toml = context.temp_dir.child("pyproject.toml");
pyproject_toml.write_str(indoc! { r#"
[project]
name = "foo"
version = "1.0.0"
requires-python = ">=3.12"
dependencies = [
"iniconfig"
]

[tool.uv.workspace]
members = ["child"]
"#
})?;

context
.temp_dir
.child("child")
.child("pyproject.toml")
.write_str(indoc! { r#"
[project]
name = "child"
version = "1.0.0"
requires-python = ">=3.12"
dependencies = []
"#
})?;

// Sync the parent package.
uv_snapshot!(context.filters(), context.sync(), @r"
success: true
exit_code: 0
----- stdout -----

----- stderr -----
Resolved 3 packages in [TIME]
Prepared 1 package in [TIME]
Installed 1 package in [TIME]
+ iniconfig==2.0.0
");

// Ensure that the isolated environment can't access `iniconfig` (from the parent package).
uv_snapshot!(context.filters(), context.run().arg("--package").arg("child").arg("--isolated").arg("python").arg("-c").arg("import iniconfig"), @r#"
success: false
exit_code: 1
----- stdout -----

----- stderr -----
Resolved 3 packages in [TIME]
Audited in [TIME]
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'iniconfig'
"#);

// Ensure that the isolated environment can't access `iniconfig` (from the parent package).
uv_snapshot!(context.filters(), context.run().arg("--package").arg("child").arg("--isolated").arg("--with").arg("typing-extensions").arg("python").arg("-c").arg("import iniconfig"), @r#"
success: false
exit_code: 1
----- stdout -----

----- stderr -----
Resolved 3 packages in [TIME]
Audited in [TIME]
Resolved 1 package in [TIME]
Prepared 1 package in [TIME]
Installed 1 package in [TIME]
+ typing-extensions==4.10.0
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'iniconfig'
"#);

Ok(())
}
Loading