(version: str)
| 146 | |
| 147 | |
| 148 | def norm_version(version: str) -> str | None: |
| 149 | if version == C.DEFAULT: # use virtualenv's default |
| 150 | return None |
| 151 | elif _sys_executable_matches(version): # virtualenv defaults to our exe |
| 152 | return None |
| 153 | |
| 154 | if sys.platform == 'win32': # pragma: no cover (windows) |
| 155 | version_exec = _find_by_py_launcher(version) |
| 156 | if version_exec: |
| 157 | return version_exec |
| 158 | |
| 159 | # Try looking up by name |
| 160 | version_exec = find_executable(version) |
| 161 | if version_exec and version_exec != version: |
| 162 | return version_exec |
| 163 | |
| 164 | # Otherwise assume it is a path |
| 165 | return os.path.expanduser(version) |
| 166 | |
| 167 | |
| 168 | @contextlib.contextmanager |
no test coverage detected