redex.py: fix binary autodetection - #982
Conversation
|
@xuhdev has imported this pull request. If you are a Meta employee, you can view this in D101099802. |
343ddfb to
bd1dc91
Compare
Signed-off-by: Leon Adomaitis <leon@adomaitis.de>
bd1dc91 to
f1d9211
Compare
| extract_signing_args(args) | ||
|
|
||
| if not args.unpack_only: | ||
| args.redex_binary = find_redex_binary(args.redex_binary) |
There was a problem hiding this comment.
What's the purpose of this line?
There was a problem hiding this comment.
To find the redex-all file in the same directory if not given via flag. It would fail before reaching run-binary
There was a problem hiding this comment.
This specifically requires --redex-binary argument to be passed, see the line right below:
raise argparse.ArgumentTypeError("Requires --redex-binary argument")
There was a problem hiding this comment.
Yup, and if the new function doesnt find the binary, it will set it to null. This means, it will got to the exception raising. But if it found one, it sets the arg value and bascaily dies the sea was setting the flag to a value.
why? because in your docs, you say somewhere that you need to either set the flag or have it in the same directory.
This is already the case, but because the check for that previously happens after validating the flags.
So currently (ie in the current main branch) you check for the binary in the same directory already here
Lines 237 to 244 in b342673
But this (run_redex) is never called if args.redex_binary is None , because raise argparse.ArgumentTypeError("Requires --redex-binary argument") is thrown before. (Because validate_args is run before run_redex, which raises that exception if state.args.redex_binary is None )
Lines 1815 to 1816 in b342673
So what I did, I basically removed the check logic from run_redex, put that into find_redex_binary, and set args.redex_binary to the return value of said function, inside validate_args. I also did this in run_redex to not mix refactor with fix in this pr
There was a problem hiding this comment.
Where did you see "you say somewhere that you need to either set the flag or have it in the same directory."? Is this from the Windows context in the installation page?
Bundling the redex-all binary with the python scripts is not supported on Windows. Manually copy the binary into the same directory as redex.py and use redex.py that way, or ensure that redex.py is called with the --redex-binary parameter:
Because this is a behavior change, I just wanna make sure if you see it somewhere in doc, the doc is kept in sync.
There was a problem hiding this comment.
yes, from the windows steps.
Summary
find_redex_binary()so validation and execution share the same autodetection pathredex-allfromPATHor a bundled binary next toredex.pyWhy
Validation previously rejected runs without
--redex-binaryeven though runtime already supported autodetecting the binary.Validation
python3 test/test_redex_args.pypython3 -m py_compile redex.py test/test_redex_args.py