MCPcopy
hub / github.com/jazzband/pip-tools / _validate_python_executable

Function _validate_python_executable

piptools/scripts/sync.py:159–180  ·  view source on GitHub ↗

Validates incoming python_executable argument passed to CLI.

(python_executable: str)

Source from the content-addressed store, hash-verified

157
158
159def _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
183def _compose_install_flags(

Callers 1

cliFunction · 0.85

Calls 2

errorMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…