mirror of https://github.com/astral-sh/ruff
## Summary Fixes https://github.com/astral-sh/ty/issues/640. If a user passes `--python=<some-virtual-environment>/bin/python`, we must avoid canonicalizing the path until we've traversed upwards to find the `sys.prefix` directory (`<some-virtual-environment>`). On Unix systems, `<sys.prefix>/bin/python` is often a symlink to a system interpreter; if we resolve the symlink too easily then we'll add the system interpreter's `site-packages` directory as a search path rather than the virtual environment's directory. ## Test Plan I added an integration test to `crates/ty/tests/cli/python_environment.rs` which fails on `main`. I also manually tested locally that running `cargo run -p ty check foo.py --python=.venv/bin/python -vv` now prints this log to the terminal ``` 2025-06-20 18:35:24.57702 DEBUG Resolved site-packages directories for this virtual environment are: SitePackagesPaths({"/Users/alexw/dev/ruff/.venv/lib/python3.13/site-packages"}) ``` Whereas it previously resolved `site-packages` to my system intallation's `site-packages` directory |
||
|---|---|---|
| .. | ||
| ruff | ||
| ruff_annotate_snippets | ||
| ruff_benchmark | ||
| ruff_cache | ||
| ruff_db | ||
| ruff_dev | ||
| ruff_diagnostics | ||
| ruff_formatter | ||
| ruff_graph | ||
| ruff_index | ||
| ruff_linter | ||
| ruff_macros | ||
| ruff_notebook | ||
| ruff_options_metadata | ||
| ruff_python_ast | ||
| ruff_python_ast_integration_tests | ||
| ruff_python_codegen | ||
| ruff_python_formatter | ||
| ruff_python_index | ||
| ruff_python_literal | ||
| ruff_python_parser | ||
| ruff_python_resolver | ||
| ruff_python_semantic | ||
| ruff_python_stdlib | ||
| ruff_python_trivia | ||
| ruff_python_trivia_integration_tests | ||
| ruff_server | ||
| ruff_source_file | ||
| ruff_text_size | ||
| ruff_wasm | ||
| ruff_workspace | ||
| ty | ||
| ty_ide | ||
| ty_project | ||
| ty_python_semantic | ||
| ty_server | ||
| ty_test | ||
| ty_vendored | ||
| ty_wasm | ||