Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include sys.path of ephemeral env in PYTHONPATH #7699

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
17 changes: 16 additions & 1 deletion crates/uv/src/commands/project/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,22 @@ pub(crate) async fn run(
let new_path = std::env::join_paths(
ephemeral_env
.as_ref()
.map(PythonEnvironment::scripts)
.map(|ephemeral_env| {
// Ensure the sys.path of the ephemeral env is included in
// the process's env, in case we're executing an external
// command which resolves to the project environment (i.e. `jupyter`)
process.env(
"PYTHONPATH",
ephemeral_env
.interpreter()
.sys_path()
.iter()
.map(|path| path.display().to_string())
.collect::<Vec<_>>()
.join(if cfg!(windows) { ";" } else { ":" }),
);
PythonEnvironment::scripts(ephemeral_env)
})
.into_iter()
.chain(std::iter::once(base_interpreter.scripts()))
.map(PathBuf::from)
Expand Down
Loading