Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 2 commits into from

Conversation

zjturner
Copy link
Contributor

@zjturner zjturner commented Apr 23, 2024

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

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 23, 2024
@zjturner
Copy link
Contributor Author

zjturner commented May 1, 2024

@JakobDegen Do you know anyone who can review this?

@JakobDegen
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

facebook-github-bot pushed a commit to facebook/buck2-prelude that referenced this pull request May 3, 2024
Summary:
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

X-link: facebook/buck2#626

Reviewed By: IanChilds

Differential Revision: D56844063

Pulled By: JakobDegen

fbshipit-source-id: 69b68f7a0884d645203bf8b199be5c0b97cacef7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants