Skip to content

Commit

Permalink
Add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Mar 4, 2024
1 parent 2f48ff6 commit 2671cd5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/uv-virtualenv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ thiserror = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true, optional = true }
which = { workspace = true }
walkdir.workspace = true

[features]
cli = ["clap", "tracing-subscriber"]
24 changes: 21 additions & 3 deletions crates/uv-virtualenv/src/bare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ pub fn create_bare_venv(
// a virtual environment is a symlink to the base interpreter.
uv_fs::canonicalize_executable(interpreter.sys_executable())?
} else if cfg!(windows) {
println!("interpreter.is_virtualenv(): {:?}", interpreter.is_virtualenv());
println!("interpreter.base_executable(): {:?}", interpreter.base_executable());
println!("interpreter.base_prefix(): {:?}", interpreter.base_prefix());
println!("interpreter.sys_executable(): {:?}", interpreter.sys_executable());
println!("uv_fs::canonicalize_executable(interpreter.sys_executable()): {:?}", uv_fs::canonicalize_executable(interpreter.sys_executable()));

// On Windows, follow `virtualenv`. If we're in a virtual environment, use
// `sys._base_executable` if it exists; if not, use `sys.base_prefix`. For example, with
// Python installed from the Windows Store, `sys.base_prefix` is slightly "incorrect".
Expand All @@ -73,8 +79,9 @@ pub fn create_bare_venv(
interpreter.base_prefix().join("python.exe")
}
} else {
uv_fs::canonicalize_executable(interpreter.sys_executable())?
interpreter.sys_executable().to_path_buf()
}

} else {
unimplemented!("Only Windows and Unix are supported")
};
Expand Down Expand Up @@ -162,15 +169,26 @@ pub fn create_bare_venv(
)?;
}

println!("interpreter.stdlib(): {:?}", interpreter.stdlib());
println!("uv_fs::canonicalize_executable(interpreter.sys_executable()): {:?}", uv_fs::canonicalize_executable(interpreter.stdlib()));

// Show the entire directory structure.
for x in walkdir::WalkDir::new(base_python.parent().unwrap()) {
println!("{:?}", x);
}

#[cfg(windows)]
{
// https://github.com/python/cpython/blob/d457345bbc6414db0443819290b04a9a4333313d/Lib/venv/__init__.py#L261-L267
// https://github.com/pypa/virtualenv/blob/d9fdf48d69f0d0ca56140cf0381edbb5d6fe09f5/src/virtualenv/create/via_global_ref/builtin/cpython/cpython3.py#L78-L83
// There's two kinds of applications on windows: Those that allocate a console (python.exe) and those that
// don't because they use window(s) (pythonw.exe).
println!("interpreter.stdlib(): {:?}", interpreter.stdlib());
println!("interpreter.stdlib().join('venv'): {:?}", interpreter.stdlib().join("venv"));

for python_exe in ["python.exe", "pythonw.exe"] {
let shim = interpreter
.stdlib()

let shim = base_python.parent().unwrap()
.join("venv")
.join("scripts")
.join("nt")
Expand Down

0 comments on commit 2671cd5

Please sign in to comment.