Validates incoming python_executable argument passed to CLI.
(python_executable: str)
| 157 | |
| 158 | |
| 159 | def _validate_python_executable(python_executable: str) -> None: |
| 160 | """ |
| 161 | Validates incoming python_executable argument passed to CLI. |
| 162 | """ |
| 163 | resolved_python_executable = shutil.which(python_executable) |
| 164 | if resolved_python_executable is None: |
| 165 | msg = "Could not resolve '{}' as valid executable path or alias." |
| 166 | log.error(msg.format(python_executable)) |
| 167 | sys.exit(2) |
| 168 | |
| 169 | # Ensure that target python executable has the right version of pip installed |
| 170 | pip_version = _pip_api.get_pip_version_for_python_executable(python_executable) |
| 171 | required_pip_specification = get_required_pip_specification() |
| 172 | if not required_pip_specification.contains(pip_version, prereleases=True): |
| 173 | msg = ( |
| 174 | "Target python executable '{}' has pip version {} installed. " |
| 175 | "Version {} is expected." |
| 176 | ) |
| 177 | log.error( |
| 178 | msg.format(python_executable, pip_version, required_pip_specification) |
| 179 | ) |
| 180 | sys.exit(2) |
| 181 | |
| 182 | |
| 183 | def _compose_install_flags( |
no test coverage detected
searching dependent graphs…