MCPcopy
hub / github.com/pex-tool/pex / python

Method python

pex/pyenv.py:210–233  ·  view source on GitHub ↗

Return the path of the python binary for the given pyenv version. Returns `None` if the given pyenv version is not installed.

(
        self,
        pyenv_version,  # type: str
        binary_name=None,  # type: Optional[str]
    )

Source from the content-addressed store, hash-verified

208 return ()
209
210 def python(
211 self,
212 pyenv_version, # type: str
213 binary_name=None, # type: Optional[str]
214 ):
215 # type: (...) -> Optional[str]
216 """Return the path of the python binary for the given pyenv version.
217
218 Returns `None` if the given pyenv version is not installed.
219 """
220 # N.B.: Pyenv creates a 'python' symlink for both the CPython and PyPy versions it installs;
221 # so counting on 'python' is OK here. We do resolve the symlink though to return a canonical
222 # direct path to the python binary.
223 binary_name = script_name(binary_name or "python")
224
225 if WINDOWS:
226 python = os.path.realpath(
227 os.path.join(self.root, "versions", pyenv_version, binary_name)
228 )
229 else:
230 python = os.path.realpath(
231 os.path.join(self.root, "versions", pyenv_version, SCRIPT_DIR, binary_name)
232 )
233 return python if is_exe(python) else None

Callers 1

select_versionMethod · 0.45

Calls 3

script_nameFunction · 0.90
is_exeFunction · 0.90
joinMethod · 0.45

Tested by

no test coverage detected