Does `pex` have a query feature? Asking because th...
# pex
j
Does
pex
have a query feature? Asking because this seems like a common problem during development and reporting (compliance, etc): https://pantsbuild.slack.com/archives/C011AR526RJ/p1605545745001100
For instance
pex query pants.pex
would return a report on what's in
pants.pex
without having to do the unzip song and dance.
Maybe that would be out of scope of
pex
. In which case maybe
pexinterrogator
(need a shorter name) should become a thing. Any interest?
h
Does pex have a query feature?
No, outside of
PEX-INFO
and then piping into JQ or Python’s json module I suspect that there might be more skepticism to adding, as Pex much more closely follows the Unix philosophy of the tool doing one thing and doing it well, unlike Pants trying to bake most things in. But could be useful. What would you expect the output of query to be? Is it shorthand for
unzip
+ JQ?
Maybe that would be out of scope of pex. In which case maybe pexinterrogator (need a shorter name) should become a thing. Any interest?
Might make sense, but I suspect it’d still be better to rely on tools that already work great like unzip and JQ. One thing we could improve is the docs for Pex to give query recipes!
j
So the pipeline to avoid filesystem touching would be... (he goes off to figure it out, but hopes someone already has it in their cache)
j
unzip -p skelpants.pex PEX-INFO | jq -S .
stupid unix
keeping me from building a bloated tool yet again
😄 1
Having that in the man page/help page would give you eye rolling momentum when people ask that question for the 100th time.
💯 1
e
Agreed with everything said about unix philosophy here, so I'd be happy with documenting PEX-INFO exists and is in json format, but that's about it. I don't want to distribute command line lessons to every unix tool that happens to tangentially involve json files.
👍🏽 2
h
Personally, I’d love something short like this:
PEX-INFO
is a JSON file with metadata about the distribution. You can use it to query the build, e.g.
unzip -p foo.pex PEX-INFO | jq ...
.
It’s enough of a hint to check those tools out if people aren’t already familiar with unzip and jq, without rewriting their docs.
e
without rewriting their docs.
By distribute command line docs, I meant exactly not repeating your 2nd sentence in every tool (like) pex that happens to tangentially involve json.
j
I think it is enough to have it in places like this slack and maybe troubleshooting posts. The best tools to use evolves over time, so informing people that a
.pex
is a zipped file is a reasonable stopping place for its docs. Case in point, I've never bothered to remember the exact sequence for taring up a directory before sending it over an ssh pipe to another machine because all I have to remember is
man tar
then find the example. Had that example not been there, I might actually remember the exact format and then use that in more places then just when I need to transfer a dir hierarchy from one box to another.
e
Yeah, that's how I go about these things too. Its probably from a physics background where you optimize for deriving ~everything from a minimal set of 1st principles.
h
That’s astute. I think part of where I’m coming from is my time teaching, where you have to repeat yourself, often in different ways
j
Maybe what's needed is creating a pants entries for https://github.com/tldr-pages/tldr 🙂
👀 1
e
A tool for querying ... but you still need to know
jq
if you want to do more: https://github.com/pantsbuild/pex/pull/1127
🎉 1