mirror of
https://github.com/astral-sh/uv
synced 2026-01-24 06:50:18 -05:00
Previously, we were assuming that `which <python>` return the path to the python executable. This is not true when using pyenv shims, which are bash scripts. Instead, we have to use `sys.executable`. Luckily, we're already querying the python interpreter and can do it in that pass. We are also not allowed to cache the execution of the python interpreter through the shim because pyenv might change the target. As a heuristic, we check whether `sys.executable`, the real binary, is the same our canonicalized `which` result. --------- Co-authored-by: Zanie Blue <contact@zanie.dev>
Gourgeist
Gourgeist is a rust library to create python virtual environments. It also has a CLI.
It currently supports only unix (linux/mac), windows support is missing.
Rust
use camino::Utf8PathBuf;
use gourgeist::{create_venv, get_interpreter_info, parse_python_cli};
let location = cli.path.unwrap_or(Utf8PathBuf::from(".venv"));
let python = parse_python_cli(cli.python)?;
let data = get_interpreter_info(&python)?;
create_venv(&location, &python, &data, cli.bare)?;
CLI
Use python as base for a virtualenv .venv:
gourgeist
Or use custom defaults:
gourgeist -p 3.11 my_env
