[ty] Move venv and conda env discovery to SearchPath::from_settings (#18938)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
Micha Reiser 2025-06-26 16:39:27 +02:00 committed by GitHub
parent d04e63a6d9
commit 76387295a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 147 additions and 108 deletions

View file

@ -21,7 +21,7 @@ use std::fmt::Write;
use ty_python_semantic::pull_types::pull_types;
use ty_python_semantic::types::check_types;
use ty_python_semantic::{
Program, ProgramSettings, PythonPath, PythonPlatform, PythonVersionSource,
Program, ProgramSettings, PythonEnvironmentPath, PythonPlatform, PythonVersionSource,
PythonVersionWithSource, SearchPathSettings, SysPrefixPathOrigin,
};
@ -271,15 +271,15 @@ fn run_test(
src_roots: vec![src_path],
extra_paths: configuration.extra_paths().unwrap_or_default().to_vec(),
custom_typeshed: custom_typeshed_path.map(SystemPath::to_path_buf),
python_path: configuration
python_environment: configuration
.python()
.map(|sys_prefix| {
PythonPath::IntoSysPrefix(
PythonEnvironmentPath::explicit(
sys_prefix.to_path_buf(),
SysPrefixPathOrigin::PythonCliFlag,
)
})
.unwrap_or(PythonPath::KnownSitePackages(vec![])),
.unwrap_or(PythonEnvironmentPath::Testing(vec![])),
}
.to_search_paths(db.system(), db.vendored())
.expect("Failed to resolve search path settings"),