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

Use path file instead of sitecustomize.py #7161

Merged
merged 1 commit into from
Sep 9, 2024
Merged
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
6 changes: 4 additions & 2 deletions crates/uv/src/commands/project/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,9 +612,11 @@ pub(crate) async fn run(
})
};

// If we're running in an ephemeral environment, add a `sitecustomize.py` to enable loading of
// If we're running in an ephemeral environment, add a path file to enable loading of
// the base environment's site packages. Setting `PYTHONPATH` is insufficient, as it doesn't
// resolve `.pth` files in the base environment.
// And `sitecustomize.py` would be an alternative but it can be shadowed by an existing such
// module in the python installation.
if let Some(ephemeral_env) = ephemeral_env.as_ref() {
let ephemeral_site_packages = ephemeral_env
.site_packages()
Expand All @@ -626,7 +628,7 @@ pub(crate) async fn run(
.ok_or_else(|| anyhow!("Base environment has no site packages directory"))?;

fs_err::write(
ephemeral_site_packages.join("sitecustomize.py"),
ephemeral_site_packages.join("_uv_ephemeral_overlay.pth"),
format!(
"import site; site.addsitedir(\"{}\")",
base_site_packages.escape_for_python()
Expand Down
Loading