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

Method execute

pex/pex.py:572–614  ·  view source on GitHub ↗

Execute the PEX. This function makes assumptions that it is the last function called by the interpreter.

(self, python_args=())

Source from the content-addressed store, hash-verified

570 return self._pex
571
572 def execute(self, python_args=()):
573 # type: (Sequence[str]) -> Any
574 """Execute the PEX.
575
576 This function makes assumptions that it is the last function called by the interpreter.
577 """
578 pex_file = self._vars.PEX
579 if self._vars.PEX_TOOLS:
580 if not self._pex_info.includes_tools:
581 die(
582 "The PEX_TOOLS environment variable was set, but this PEX was not built "
583 "with tools (Re-build the PEX file with `pex --include-tools ...`)"
584 )
585
586 from pex.tools import main as tools
587
588 sys.exit(tools.main(pex=PEX(pex_file or sys.argv[0])))
589
590 self.activate()
591
592 if pex_file:
593 try:
594 from setproctitle import setproctitle # type: ignore[import]
595
596 setproctitle(
597 "{python} {pex_file} {args}".format(
598 python=sys.executable,
599 pex_file=pex_file,
600 args=" ".join(sys.argv[1:]),
601 )
602 )
603 except ImportError:
604 TRACER.log(
605 "Not setting process title since setproctitle is not available in "
606 "{pex_file}".format(pex_file=pex_file),
607 V=3,
608 )
609
610 result = self._wrap_coverage(self._wrap_profiling, self._execute, python_args)
611 if "PYTHONINSPECT" not in os.environ:
612 sys.exit(0 if isinstance(result, Globals) else result)
613 else:
614 return result
615
616 def _execute(self, python_args):
617 # type: (Sequence[str]) -> Any

Callers 15

bootstrap_pexFunction · 0.45
compileMethod · 0.45
runMethod · 0.45
_createMethod · 0.45
_db_connectionMethod · 0.45
_iter_cachedMethod · 0.45
bdist_pex_venvFunction · 0.45
test_executor_executeFunction · 0.45
test_local_pip_packageFunction · 0.45

Calls 7

activateMethod · 0.95
_wrap_coverageMethod · 0.95
dieFunction · 0.90
PEXClass · 0.85
exitMethod · 0.80
logMethod · 0.80
joinMethod · 0.45

Tested by 15

bdist_pex_venvFunction · 0.36
test_executor_executeFunction · 0.36
test_local_pip_packageFunction · 0.36
test_detect_pyvenvFunction · 0.36
create_venvFunction · 0.36
test_sys_pathFunction · 0.36
test_forceFunction · 0.36
test_multiplatformFunction · 0.36