()
| 83 | |
| 84 | |
| 85 | def _find_by_sys_executable() -> str | None: |
| 86 | def _norm(path: str) -> str | None: |
| 87 | _, exe = os.path.split(path.lower()) |
| 88 | exe, _, _ = exe.partition('.exe') |
| 89 | if exe not in {'python', 'pythonw'} and find_executable(exe): |
| 90 | return exe |
| 91 | return None |
| 92 | |
| 93 | # On linux, I see these common sys.executables: |
| 94 | # |
| 95 | # system `python`: /usr/bin/python -> python2.7 |
| 96 | # system `python2`: /usr/bin/python2 -> python2.7 |
| 97 | # virtualenv v: v/bin/python (will not return from this loop) |
| 98 | # virtualenv v -ppython2: v/bin/python -> python2 |
| 99 | # virtualenv v -ppython2.7: v/bin/python -> python2.7 |
| 100 | # virtualenv v -ppypy: v/bin/python -> v/bin/pypy |
| 101 | for path in (sys.executable, os.path.realpath(sys.executable)): |
| 102 | exe = _norm(path) |
| 103 | if exe: |
| 104 | return exe |
| 105 | return None |
| 106 | |
| 107 | |
| 108 | @functools.lru_cache(maxsize=1) |
no test coverage detected