True if ``path`` is inside the active venv (sys.prefix). The venv hipInfo.exe (AMD wheel, put on PATH by the bnb fix) is NOT a HIP SDK (_amd_smi_allowed).
(path: str)
| 283 | |
| 284 | |
| 285 | def _path_inside_venv(path: str) -> bool: |
| 286 | """True if ``path`` is inside the active venv (sys.prefix). |
| 287 | |
| 288 | The venv hipInfo.exe (AMD wheel, put on PATH by the bnb fix) is NOT a HIP SDK |
| 289 | (_amd_smi_allowed).""" |
| 290 | try: |
| 291 | # realpath (not abspath): resolve symlinks/8.3 names so an aliased venv matches. |
| 292 | _root = os.path.normcase(os.path.realpath(sys.prefix)) |
| 293 | # Guard a root-dir prefix (C:\ or /): commonpath would match every path on |
| 294 | # it. A venv is never at root, so treat that as outside. |
| 295 | if os.path.dirname(_root) == _root: |
| 296 | return False |
| 297 | return os.path.normcase(os.path.commonpath([os.path.realpath(path), _root])) == _root |
| 298 | except (ValueError, OSError): |
| 299 | # Different drive / unresolvable -> treat as outside the venv. |
| 300 | return False |
| 301 | |
| 302 | |
| 303 | def _external_hipinfo_on_path() -> bool: |
no outgoing calls
no test coverage detected
searching dependent graphs…