Allow passing json file to pex to embed as part of PexInfo
Discussion:
In pants v1, when a pex was created (for a binary target) it would add some build properties from run tracker: https://github.com/pantsbuild/pants/blob/master/src/python/pants/backend/python/tasks/python_binary_create.py#L171
I am mostly interested in the scm info (revision) which came thru here: https://github.com/pantsbuild/pants/blob/29cf9fc8b25a540f32e4a9e0aeeaaa6ea4dcc48f/src/python/pants/base/run_info.py#L103
Is there anyway to bring this back to v2 ? where would we do it ?
It is helpful to know which git hash was used when building a specific pex file because it allows tools like sentry to trace back regressions to specific commits. (for example) https://docs.sentry.io/workflow/releases/?platform=python
I think this is extremely useful to be able to attach arbitrary metadata to the a pex file. We already have PexInfo (and in v1 we used to attach some data to it) This allow the application to know which version it is running and is useful when working with error tracking tools like sentry.
If this makes sense to people, I can take a stab and try to implement this in pex (and then we need to figure out how to properly integrate into pants's create_pex rule)
@Eric-Arellano @jsirois @benjyw @stuhood
PEX already allows for embedding of arbitrary files. So I think that this would be a 100% pants-side change.
If you wanted to embed a static file, you could already do that by adding a dependency on a resources target. In this case, because you would like the file to be generated dynamically, this is instead an interesting testcase for the v2 Target API. cc @Eric-Arellano
I'm going to attempt to transfer this ticket to pants.
Instead of embedding a file we could just set custom PexInfo.build_properties from the Pants side: https://github.com/pantsbuild/pex/blob/ea57f59773ca64d8415194d23720b5e5fb4378ec/pex/pex_info.py#L153-L158
And if we did it with a union, it would allow for pluggable additions...
that is my original intent... to use the pex info build properties and pass the content for it from pants to pex using a json file
that is my original intent... to use the pex info build properties and pass the content for it from pants to pex using a json file
Ah, ok. The JSON bit threw me. Since build properties already takes a dict, no need to add JSON support unless you want to do that on the Pants side and have pants load an object from JSON to stuff in the build_properties.
Ok. Apologies, I was also confused. Pex doesn't have a CLI argument to allow including additional information there.
This issue has been open for over one year without activity and is not labeled as a bug. It has been labeled as stale to invite any further updates. If you can confirm whether the issue is still applicable to the latest version of Pants, appears in other contexts, or its priority has changed, please let us know. Please feel free to close this issue if it is no longer relevant.
Pex infra here: https://github.com/pex-tool/pex/pull/3036 I'll update when this is released in Pex 2.74.0. Released here: https://github.com/pex-tool/pex/releases/tag/v2.74.0