pants icon indicating copy to clipboard operation
pants copied to clipboard

Expose the hash of a given target

Open ns-cweber opened this issue 6 years ago • 3 comments

This has come up several times for our team, but it would be nice to have access to the hash of a given target. Most recently, we're building PEX files with pants and then dropping them into Docker Images--we'd like to tag the Docker Image with the hash of the PEX's inputs so our deploy pipeline will see that the image tags are the same and not trigger a redeploy.

We could hash the PEX file, but then we're at the mercy of pants to produce exactly (bit for bit) the same PEX file with each build. Admittedly, a shared cache probably makes this mostly an academic concern.

I'm not familiar with pants internals, but ideally this would be agnostic to the type of target--the same use case could easily apply to Node or Go images as for Python.

ns-cweber avatar Oct 10 '19 19:10 ns-cweber

This is actually something that would be immediately useful for IDE support in Metals too (from scalameta/metals#935), and it would almost definitely be generically useful in the way you describe.

cosmicexplorer avatar Oct 10 '19 21:10 cosmicexplorer

N.b. for those coming here, tagging images built with the docker_image target, there is a pants.hash value for the images inputs: https://www.pantsbuild.org/2.19/docs/docker/tagging-docker-images#string-interpolation-using-placeholder-values

kaos avatar Mar 07 '24 10:03 kaos

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.

github-actions[bot] avatar Dec 03 '25 04:12 github-actions[bot]