https://pantsbuild.org/ logo
#general
Title
# general
s

straight-action-80318

09/23/2022, 5:17 PM
This feels like a very stupid question but I can’t seem to find the answer: I have a
pex
file that I want to execute by simply running
./my_package.pex
, but I cannot figure out how to pass arguments to the script that’s inside the package. Just adding flags doesn’t seem to get parsed, and passing them via
--
doesn’t work either.
w

witty-crayon-22786

09/23/2022, 5:21 PM
when you run a PEX file, the name of the python code that will actually be executed is an `entry_point`: https://www.pantsbuild.org/docs/reference-pex_binary#codeentry_pointcode
s

straight-action-80318

09/23/2022, 5:24 PM
Is “You must use the file name shorthand for file arguments to work with this target.” what I’m looking for? Not sure what a file argument means in this context
I believe I’m using 1 in my Pants build file
Copy code
pex_binary(
    name="pex_data_extraction",
    entry_point="data_extraction.py",
)
w

witty-crayon-22786

09/23/2022, 5:27 PM
ok: and what happens when you run the PEX?
s

straight-action-80318

09/23/2022, 5:28 PM
the pex runs fine, the issue is that I can’t pass arguments to the underlying python file
w

witty-crayon-22786

09/23/2022, 5:28 PM
runs the code you are expecting to run?
s

straight-action-80318

09/23/2022, 5:29 PM
yeah
it just says
Discarding unparseable args
and then lists all the arguments I pass
I wonder if there’s some weird interaction happening with the way I’m parsing args? Is expected behavior to read the arguments normally?
h

happy-kitchen-89482

09/23/2022, 5:30 PM
The pex command line should be passed through to your code’s sys.argv
w

witty-crayon-22786

09/23/2022, 5:30 PM
yea, you should be able to read them normally.
e

enough-analyst-54434

09/23/2022, 6:07 PM
@straight-action-80318 can you provide 3 things for debugging?: 1. The full output of:
PEX_VERBOSE=9 ./pex_data_extraction.pex --bob
2. The full output of:
unzip -qc ./pex_data_extraction.pex PEX-INFO | jq .
3. The full output of: `zipinfo ./pex_data_extraction.pex``
s

straight-action-80318

09/23/2022, 6:36 PM
I think I figured it out, sorry for the fuss! It was an interaction of apache beam with argument parsing, I don’t think it was a Pex issue
🙌 1
4 Views