admin管理员组文章数量:1399329
Consider this script /tmp/test.py
:
import os
import sys
print(__file__)
print(os.path.dirname(os.path.realpath(__file__)))
print(sys.argv)
bundled like this with pex
:
python -m pex --exe test.py -o test.pex
Executing ./test.pex
gives:
/home/user/.cache/pex/unzipped_pexes/1/05ee97ddfe7a3cfe9392492e49c46d07135e26d9/__pex_executable__.py
/home/user/.cache/pex/user_code/0/242a6d4429f13194d3dedebc8dbd8d72bf0c79bd
['/home/user/.cache/pex/unzipped_pexes/1/05ee97ddfe7a3cfe9392492e49c46d07135e26d9/__pex_executable__.py']
How can I get the name and path of the executed .pex file?
Consider this script /tmp/test.py
:
import os
import sys
print(__file__)
print(os.path.dirname(os.path.realpath(__file__)))
print(sys.argv)
bundled like this with pex
:
python -m pex --exe test.py -o test.pex
Executing ./test.pex
gives:
/home/user/.cache/pex/unzipped_pexes/1/05ee97ddfe7a3cfe9392492e49c46d07135e26d9/__pex_executable__.py
/home/user/.cache/pex/user_code/0/242a6d4429f13194d3dedebc8dbd8d72bf0c79bd
['/home/user/.cache/pex/unzipped_pexes/1/05ee97ddfe7a3cfe9392492e49c46d07135e26d9/__pex_executable__.py']
How can I get the name and path of the executed .pex file?
Share Improve this question asked Mar 25 at 8:08 spinkusspinkus 8,5704 gold badges44 silver badges72 bronze badges1 Answer
Reset to default 1PEX applications expose a PEX environment variable that is the absolute path of the PEX file.
print(os.environ["PEX"])
本文标签: pythonGet name of executed pex fileStack Overflow
版权声明:本文标题:python - Get name of executed .pex file? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744211327a2595431.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论