Attempt to detect if ``path`` is the root of a Virtual Environment by checking for the existence of the pyvenv.cfg file. [https://peps.python.org/pep-0405/] For regression protection we also check for conda environments that do not include pyenv.cfg yet -- https://github.com/conda/
(path: Path)
| 414 | |
| 415 | |
| 416 | def _in_venv(path: Path) -> bool: |
| 417 | """Attempt to detect if ``path`` is the root of a Virtual Environment by |
| 418 | checking for the existence of the pyvenv.cfg file. |
| 419 | |
| 420 | [https://peps.python.org/pep-0405/] |
| 421 | |
| 422 | For regression protection we also check for conda environments that do not include pyenv.cfg yet -- |
| 423 | https://github.com/conda/conda/issues/13337 is the conda issue tracking adding pyenv.cfg. |
| 424 | |
| 425 | Checking for the `conda-meta/history` file per https://github.com/pytest-dev/pytest/issues/12652#issuecomment-2246336902. |
| 426 | |
| 427 | """ |
| 428 | try: |
| 429 | return ( |
| 430 | path.joinpath("pyvenv.cfg").is_file() |
| 431 | or path.joinpath("conda-meta", "history").is_file() |
| 432 | ) |
| 433 | except OSError: |
| 434 | return False |
| 435 | |
| 436 | |
| 437 | def pytest_ignore_collect(collection_path: Path, config: Config) -> bool | None: |
no outgoing calls