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

Method mount

pex/environment.py:220–244  ·  view source on GitHub ↗
(
        cls,
        pex,  # type: str
        pex_info=None,  # type: Optional[PexInfo]
        target=None,  # type: Optional[Target]
    )

Source from the content-addressed store, hash-verified

218
219 @classmethod
220 def mount(
221 cls,
222 pex, # type: str
223 pex_info=None, # type: Optional[PexInfo]
224 target=None, # type: Optional[Target]
225 ):
226 # type: (...) -> PEXEnvironment
227 pex_file = os.path.realpath(pex)
228 if not pex_info:
229 pex_info = PexInfo.from_pex(pex_file)
230 pex_info.update(PexInfo.from_env())
231 pex_hash = pex_info.pex_hash
232 if pex_hash is None:
233 raise AssertionError(
234 "There was no pex_hash stored in {} for {}.".format(PexInfo.PATH, pex)
235 )
236 target = target or targets.current()
237 key = (pex_file, pex_hash, target)
238 mounted = cls._CACHE.get(key)
239 if mounted is None:
240 pex_root = pex_info.pex_root
241 installed_pex = ensure_installed(pex=pex, pex_root=pex_root, pex_hash=pex_hash)
242 mounted = cls(pex=installed_pex, pex_info=pex_info, target=target, source_pex=pex)
243 cls._CACHE[key] = mounted
244 return mounted
245
246 def __init__(
247 self,

Callers 6

_loaded_envsMethod · 0.80
test_resolveMethod · 0.80
bootstrap_pex_envFunction · 0.80
add_from_pexMethod · 0.80
_extract_sdistMethod · 0.80
resolve_from_pexFunction · 0.80

Calls 6

ensure_installedFunction · 0.90
from_pexMethod · 0.80
updateMethod · 0.45
from_envMethod · 0.45
currentMethod · 0.45
getMethod · 0.45

Tested by 1

test_resolveMethod · 0.64