python - Get name of executed .pex file? - Stack Overflow

Consider this script tmptest.py:import osimport sysprint(__file__)print(os.path.dirname(os.path.r

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 badges
Add a comment  | 

1 Answer 1

Reset to default 1

PEX applications expose a PEX environment variable that is the absolute path of the PEX file.

print(os.environ["PEX"])

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744211328a4563346.html

相关推荐

  • python - Get name of executed .pex file? - Stack Overflow

    Consider this script tmptest.py:import osimport sysprint(__file__)print(os.path.dirname(os.path.r

    8天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信