mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-04 07:36:11 +00:00
Allow discovery of venv in VIRTUAL_ENV env variable (#16853)
## Summary Fixes #16744 Allows the cli to find a virtual environment from the VIRTUAL_ENV environment variable if no `--python` is set ## Test Plan Manual testing, of: - Virtual environments explicitly activated using `source .venv/bin/activate` - Virtual environments implicilty activated via `uv run` - Broken virtual environments with no `pyvenv.cfg` file
This commit is contained in:
parent
12725943cd
commit
cdafd8e32b
5 changed files with 111 additions and 34 deletions
|
@ -223,14 +223,15 @@ impl SearchPaths {
|
|||
static_paths.push(stdlib_path);
|
||||
|
||||
let site_packages_paths = match python_path {
|
||||
PythonPath::SysPrefix(sys_prefix) => {
|
||||
PythonPath::SysPrefix(sys_prefix, origin) => {
|
||||
// TODO: We may want to warn here if the venv's python version is older
|
||||
// than the one resolved in the program settings because it indicates
|
||||
// that the `target-version` is incorrectly configured or that the
|
||||
// venv is out of date.
|
||||
VirtualEnvironment::new(sys_prefix, system)
|
||||
VirtualEnvironment::new(sys_prefix, *origin, system)
|
||||
.and_then(|venv| venv.site_packages_directories(system))?
|
||||
}
|
||||
|
||||
PythonPath::KnownSitePackages(paths) => paths
|
||||
.iter()
|
||||
.map(|path| canonicalize(path, system))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue