cold-vr-15232
12/13/2022, 4:26 PMenough-analyst-54434
12/13/2022, 5:26 PM$ echo $PWD
/home/jsirois/dev/pantsbuild/jsirois-scie-pants
$ PEX_INTERPRETER=1 dist/scie-pants-linux-x86_64 run tools -- -c 'import os; print(f"I am here: {os.getcwd()}")'
I am here: /home/jsirois/dev/pantsbuild/jsirois-scie-pants
$ dist/scie-pants-linux-x86_64 -V
2.15.0rc0enough-analyst-54434
12/13/2022, 5:32 PM./pants run is the repo root.happy-kitchen-89482
12/13/2022, 5:54 PMrun_goal_use_sandbox=False on the pex_binary target, and then ./pants run will run directly from the sources in the repo, instead of from sandboxed sources. But whether you do that or not, in either case the CWD is the repo root, not the sandbox root.happy-kitchen-89482
12/13/2022, 5:55 PM__file__ or something?happy-kitchen-89482
12/13/2022, 5:55 PMrun_goal_use_sandbox=False would fix thisbroad-processor-92400
12/13/2022, 7:16 PMresource instead of a file and having the Python files depend on it. The data then has to be read via importlib.resources. https://www.pantsbuild.org/docs/assetsenough-analyst-54434
12/13/2022, 7:43 PM__file__ now always works and you can load the data relative to __file__ if the data is embedded as a resource. Just another option. You still need a Pants resource target as Huon suggests either way you read the file.cold-vr-15232
12/13/2022, 8:40 PM