Run the PythonEnvironment in an interpreter in a subprocess. :keyword args: Additional arguments to be passed to the application being invoked by the environment. :keyword with_chroot: Run with cwd set to the environment's working directory. :keyword blocking: If t
(self, args=(), with_chroot=False, blocking=True, setsid=False, env=None, **kwargs)
| 863 | return cmd |
| 864 | |
| 865 | def run(self, args=(), with_chroot=False, blocking=True, setsid=False, env=None, **kwargs): |
| 866 | """Run the PythonEnvironment in an interpreter in a subprocess. |
| 867 | |
| 868 | :keyword args: Additional arguments to be passed to the application being invoked by the |
| 869 | environment. |
| 870 | :keyword with_chroot: Run with cwd set to the environment's working directory. |
| 871 | :keyword blocking: If true, return the return code of the subprocess. |
| 872 | If false, return the Popen object of the invoked subprocess. |
| 873 | :keyword setsid: If true, run the PEX in a separate operating system session. |
| 874 | :keyword env: An optional environment dict to use as the PEX subprocess environment. If none is |
| 875 | passed, the ambient environment is inherited. |
| 876 | Remaining keyword arguments are passed directly to subprocess.Popen. |
| 877 | """ |
| 878 | if env is not None: |
| 879 | # If explicit env vars are passed, we don't want to clean any of these. |
| 880 | env = env.copy() |
| 881 | else: |
| 882 | env = os.environ.copy() |
| 883 | self._clean_environment(env=env, strip_pex_env=self._pex_info.strip_pex_env) |
| 884 | |
| 885 | kwargs = dict(subprocess_daemon_kwargs() if setsid else {}, **kwargs) |
| 886 | |
| 887 | TRACER.log("PEX.run invoking {}".format(" ".join(self.cmdline(args)))) |
| 888 | _, process = self._interpreter.open_process( |
| 889 | [self._pex] + list(args), |
| 890 | cwd=self._pex if with_chroot else os.getcwd(), |
| 891 | stdin=kwargs.pop("stdin", None), |
| 892 | stdout=kwargs.pop("stdout", None), |
| 893 | stderr=kwargs.pop("stderr", None), |
| 894 | env=env, |
| 895 | **kwargs |
| 896 | ) |
| 897 | return process.wait() if blocking else process |
| 898 | |
| 899 | |
| 900 | def validate_entry_point( |