high-yak-85899
07/04/2022, 9:33 PMunzipped_pexes
determined?enough-analyst-54434
07/04/2022, 10:07 PMhigh-yak-85899
07/04/2022, 10:10 PMunzipped_pexes
directory. So was trying to come up with a robust way to map executable to absolute path on system of the unzipped source.enough-analyst-54434
07/04/2022, 10:16 PM__file__
in one of your PEXed 1st party sources to establish a baseline?high-yak-85899
07/04/2022, 10:24 PMhigh-yak-85899
07/04/2022, 10:25 PMhigh-yak-85899
07/04/2022, 10:25 PM__file__
, it would break some nice separation that exists right now between "executor" and "thing to be executed"enough-analyst-54434
07/04/2022, 10:46 PM$ mkdir /tmp/etc
$ ln -s /etc/hosts /tmp/etc/
$ pex -D /tmp/etc/ -o hosts.pex
Now find out about a resource inside that PEX:
$ PEX_INTERPRETER=1 ./hosts.pex -c 'from pathlib import Path; import __main__; root = Path(__main__.__file__).parent; hosts = root / "hosts"; print(f"{hosts}:\n{hosts.read_text()}")'
/home/jsirois/.pex/unzipped_pexes/ed7e98d7651e6062e07738d325356e7473719d91/hosts:
# Static table lookup for hostnames.
# See hosts(5) for details.
127.0.0.1 gill
::1 gill
127.0.1.1 gill.localdomain gill
Work for you?enough-analyst-54434
07/04/2022, 10:49 PM__main__.py
- as do Pex PEX files - and PEX_INTERPRETER has ~always existed and will never go away (see pex --help-variables
).enough-analyst-54434
07/04/2022, 10:50 PMhigh-yak-85899
07/04/2022, 11:07 PMenough-analyst-54434
07/04/2022, 11:22 PM--venv
PEXes too, the details will be different. The __main__.__file__
will be in the venv root dir and the 1st party code will be in the site-packages subdir of that venv.enough-analyst-54434
07/04/2022, 11:30 PM