Restart the process passing the given options to the python interpreter
(
python_options, # type: List[str]
args, # List[str]
)
| 738 | |
| 739 | @staticmethod |
| 740 | def re_execute_with_options( |
| 741 | python_options, # type: List[str] |
| 742 | args, # List[str] |
| 743 | ): |
| 744 | # type: (...) -> Union[NoReturn, Any] |
| 745 | """ |
| 746 | Restart the process passing the given options to the python interpreter |
| 747 | """ |
| 748 | # Find the installed (unzipped) PEX entry point. |
| 749 | main = sys.modules.get("__main__") |
| 750 | if not main or not main.__file__: |
| 751 | # N.B.: This should never happen. |
| 752 | return "Unable to resolve PEX __main__ module file: {}".format(main) |
| 753 | |
| 754 | python = sys.executable |
| 755 | cmdline = [python] + python_options + [os.path.dirname(main.__file__)] + args |
| 756 | TRACER.log( |
| 757 | "Re-executing with Python interpreter options: cmdline={cmdline!r}".format( |
| 758 | cmdline=" ".join(cmdline) |
| 759 | ) |
| 760 | ) |
| 761 | if any( |
| 762 | arg.startswith("-") and not arg.startswith("--") and "i" in arg |
| 763 | for arg in python_options |
| 764 | ): |
| 765 | os.environ["PYTHONINSPECT"] = "1" |
| 766 | safe_execv(cmdline) |
| 767 | |
| 768 | def execute_script(self, script_name): |
| 769 | # type: (str) -> Any |
no test coverage detected