acoustic-library-86413
08/24/2023, 10:47 AMrefined-addition-53644
08/24/2023, 1:43 PMenv option that you can pass to pex_binary as mentioned in the docs
Although you will have to list all of the env vars from the system that you want.acoustic-library-86413
08/24/2023, 1:43 PMacoustic-library-86413
08/24/2023, 1:44 PMrefined-addition-53644
08/24/2023, 1:45 PMenough-analyst-54434
08/24/2023, 1:48 PMpants package ... to have Pants build your PEX and then run the PEX file. Now, when Pants runs your PEX file (not you), this can change. In certain scenarios Pants hides env vars.acoustic-library-86413
08/24/2023, 2:11 PMvariables:.enough-analyst-54434
08/24/2023, 2:39 PMjsirois@siroisdesign:~$ echo 'import colors, os; print(colors.yellow(os.environ["FOO"]))' > exe.py
jsirois@siroisdesign:~$ pex ansicolors --exe exe.py -o example.pex
jsirois@siroisdesign:~$ pex -V
2.1.137
(pex.venv) jsirois@siroisdesign:~$ ./example.pex
Traceback (most recent call last):
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/jsirois/.pex/unzipped_pexes/6a3a805ada20ebeb98566f705c22fd54a2fe7f9c/__main__.py", line 106, in <module>
bootstrap_pex(__entry_point__, execute=__execute__, venv_dir=__venv_dir__)
File "/home/jsirois/.pex/unzipped_pexes/6a3a805ada20ebeb98566f705c22fd54a2fe7f9c/.bootstrap/pex/pex_bootstrapper.py", line 618, in bootstrap_pex
pex.PEX(entry_point).execute()
File "/home/jsirois/.pex/unzipped_pexes/6a3a805ada20ebeb98566f705c22fd54a2fe7f9c/.bootstrap/pex/pex.py", line 560, in execute
sys.exit(self._wrap_coverage(self._wrap_profiling, self._execute))
File "/home/jsirois/.pex/unzipped_pexes/6a3a805ada20ebeb98566f705c22fd54a2fe7f9c/.bootstrap/pex/pex.py", line 467, in _wrap_coverage
return runner(*args)
File "/home/jsirois/.pex/unzipped_pexes/6a3a805ada20ebeb98566f705c22fd54a2fe7f9c/.bootstrap/pex/pex.py", line 498, in _wrap_profiling
return runner(*args)
File "/home/jsirois/.pex/unzipped_pexes/6a3a805ada20ebeb98566f705c22fd54a2fe7f9c/.bootstrap/pex/pex.py", line 603, in _execute
return self.execute_entry(
File "/home/jsirois/.pex/unzipped_pexes/6a3a805ada20ebeb98566f705c22fd54a2fe7f9c/.bootstrap/pex/pex.py", line 800, in execute_entry
return self.execute_module(entry_point.module)
File "/home/jsirois/.pex/unzipped_pexes/6a3a805ada20ebeb98566f705c22fd54a2fe7f9c/.bootstrap/pex/pex.py", line 808, in execute_module
runpy.run_module(module_name, run_name="__main__", alter_sys=True)
File "/usr/lib/python3.9/runpy.py", line 210, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/usr/lib/python3.9/runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/jsirois/.pex/unzipped_pexes/6a3a805ada20ebeb98566f705c22fd54a2fe7f9c/__pex_executable__.py", line 1, in <module>
import colors, os; print(colors.yellow(os.environ["FOO"]))
File "/usr/lib/python3.9/os.py", line 679, in __getitem__
raise KeyError(key) from None
KeyError: 'FOO'
(pex.venv) jsirois@siroisdesign:~$ FOO=bar ./example.pex
bar
(pex.venv) jsirois@siroisdesign:~$enough-analyst-54434
08/24/2023, 2:40 PMacoustic-library-86413
08/24/2023, 2:41 PM