Attempt to detect if ``path`` is the root of a Virtual Environment by checking for the existence of the appropriate activate script.
(path: Path)
| 353 | |
| 354 | |
| 355 | def _in_venv(path: Path) -> bool: |
| 356 | """Attempt to detect if ``path`` is the root of a Virtual Environment by |
| 357 | checking for the existence of the appropriate activate script.""" |
| 358 | bindir = path.joinpath("Scripts" if sys.platform.startswith("win") else "bin") |
| 359 | try: |
| 360 | if not bindir.is_dir(): |
| 361 | return False |
| 362 | except OSError: |
| 363 | return False |
| 364 | activates = ( |
| 365 | "activate", |
| 366 | "activate.csh", |
| 367 | "activate.fish", |
| 368 | "Activate", |
| 369 | "Activate.bat", |
| 370 | "Activate.ps1", |
| 371 | ) |
| 372 | return any(fname.name in activates for fname in bindir.iterdir()) |
| 373 | |
| 374 | |
| 375 | def pytest_ignore_collect(collection_path: Path, config: Config) -> Optional[bool]: |
no outgoing calls