mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:24 +00:00
[ty] Remove vestigial pyvenv.cfg
creation in mdtest (#18006)
Some checks are pending
CI / cargo clippy (push) Blocked by required conditions
CI / cargo build (msrv) (push) Blocked by required conditions
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (linux, release) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (release) (push) Waiting to run
CI / cargo fuzz build (push) Blocked by required conditions
CI / fuzz parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / ecosystem (push) Blocked by required conditions
CI / Fuzz for new ty panics (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / check playground (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
[ty Playground] Release / publish (push) Waiting to run
Some checks are pending
CI / cargo clippy (push) Blocked by required conditions
CI / cargo build (msrv) (push) Blocked by required conditions
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (linux, release) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (release) (push) Waiting to run
CI / cargo fuzz build (push) Blocked by required conditions
CI / fuzz parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / ecosystem (push) Blocked by required conditions
CI / Fuzz for new ty panics (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / check playground (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
[ty Playground] Release / publish (push) Waiting to run
Following #17991, removes some of https://github.com/astral-sh/ruff/pull/17222 which is no longer strictly necessary. I don't actually think it's that ugly to have around? no strong feelings on retaining it or not.
This commit is contained in:
parent
0bb8cbdf07
commit
7e8ba2b68e
2 changed files with 8 additions and 26 deletions
|
@ -314,9 +314,9 @@ typeshed = "/typeshed"
|
|||
|
||||
For more details, take a look at the [custom-typeshed Markdown test].
|
||||
|
||||
### Mocking a virtual environment
|
||||
### Mocking a Python environment
|
||||
|
||||
Mdtest supports mocking a virtual environment for a specific test at an arbitrary location, again
|
||||
Mdtest supports mocking a Python environment for a specific test at an arbitrary location, again
|
||||
using the `[environment]` configuration option:
|
||||
|
||||
````markdown
|
||||
|
@ -326,16 +326,10 @@ python = ".venv"
|
|||
```
|
||||
````
|
||||
|
||||
ty will reject virtual environments that do not have valid `pyvenv.cfg` files at the
|
||||
virtual-environment directory root (here, `.venv/pyvenv.cfg`). However, if a `pyvenv.cfg` file does
|
||||
not have its contents specified by the test, mdtest will automatically generate one for you, to
|
||||
make mocking a virtual environment more ergonomic.
|
||||
|
||||
Mdtest also makes it easy to write Python packages to the mock virtual environment's
|
||||
`site-packages` directory using the `<path-to-site-packages>` magic path segment. This would
|
||||
otherwise be hard, due to the fact that the `site-packages` subdirectory in a virtual environment
|
||||
is located at a different relative path depending on the platform the virtual environment was
|
||||
created on. In the following test, mdtest will write the Python file to
|
||||
Mdtest also makes it easy to write Python packages to the mock environment's `site-packages`
|
||||
directory using the `<path-to-site-packages>` magic path segment. This would otherwise be hard, due
|
||||
to the fact that the `site-packages` subdirectory in an environment is located at a different
|
||||
relative path depending on the platform. In the following test, mdtest will write the Python file to
|
||||
`.venv/Lib/site-packages/foo.py` in its in-memory filesystem used for the test if the test is being
|
||||
executed on Windows, and `.venv/lib/python3.13/site-packages/foo.py` otherwise:
|
||||
|
||||
|
|
|
@ -170,7 +170,6 @@ fn run_test(
|
|||
|
||||
let mut typeshed_files = vec![];
|
||||
let mut has_custom_versions_file = false;
|
||||
let mut has_custom_pyvenv_cfg_file = false;
|
||||
|
||||
let test_files: Vec<_> = test
|
||||
.files()
|
||||
|
@ -196,9 +195,8 @@ fn run_test(
|
|||
}
|
||||
} else if let Some(python_path) = python_path {
|
||||
if let Ok(relative_path) = full_path.strip_prefix(python_path) {
|
||||
if relative_path.as_str() == "pyvenv.cfg" {
|
||||
has_custom_pyvenv_cfg_file = true;
|
||||
} else {
|
||||
// Construct the path to the site-packages directory
|
||||
if relative_path.as_str() != "pyvenv.cfg" {
|
||||
let mut new_path = SystemPathBuf::new();
|
||||
for component in full_path.components() {
|
||||
let component = component.as_str();
|
||||
|
@ -256,16 +254,6 @@ fn run_test(
|
|||
}
|
||||
}
|
||||
|
||||
if let Some(python_path) = python_path {
|
||||
if !has_custom_pyvenv_cfg_file {
|
||||
let pyvenv_cfg_file = python_path.join("pyvenv.cfg");
|
||||
let home_directory = SystemPathBuf::from(format!("/Python{python_version}"));
|
||||
db.create_directory_all(&home_directory).unwrap();
|
||||
db.write_file(&pyvenv_cfg_file, format!("home = {home_directory}"))
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
let configuration = test.configuration();
|
||||
|
||||
let settings = ProgramSettings {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue