buck2 icon indicating copy to clipboard operation
buck2 copied to clipboard

Add the python interpreter as a hidden dep of a pex file

Open zjturner opened this issue 10 months ago • 3 comments

We have a unique python setup. We distribute it hermetically via an internal tool (similar to dotslash), then we set up our python toolchain to return a PythonToolchainInfo whose interpreter and host_interpreter fields point to a shell script called python_shim.sh that is created via ctx.actions.write(), in order to properly set up the venv and do some other things to make it hermetic.

Later, if you call python_binary, it generates a pex file which contains a line like this at the beginning:

#!/usr/bin/env buck-out/v2/gen/toolchains/48291db568f0aab5-9e2be58768776d78/__python__/python_shim.sh 

Presently this is broken because the cmd_args to execute the pex file does not have an action dependency on the interpreter, and so it complains that it cannot find python_shim.h. This PR makes it work

zjturner avatar Apr 23 '24 20:04 zjturner

@JakobDegen Do you know anyone who can review this?

zjturner avatar May 01 '24 19:05 zjturner

I'll import it and try and find someone. Sorry for letting this slip a bit, I've been traveling and so it's a bit harder to keep up with everything going on

JakobDegen avatar May 01 '24 20:05 JakobDegen

@JakobDegen has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot avatar May 01 '24 20:05 facebook-github-bot