Skip to content

fix: improve vivado binary handling in argument parser#141

Open
taraxacum45e9a wants to merge 1 commit into
Xilinx:devfrom
taraxacum45e9a:pr/fix/python
Open

fix: improve vivado binary handling in argument parser#141
taraxacum45e9a wants to merge 1 commit into
Xilinx:devfrom
taraxacum45e9a:pr/fix/python

Conversation

@taraxacum45e9a

Copy link
Copy Markdown

Fixes a TypeError crash when Vivado isn't on PATH and --vivado isn't explicitly passed. The argparse default is now resolved via shutil.which("vivado") at parse time, and CommandConfiguration.__init__ raises a clear ValueError if no binary could be determined, instead of passing None into Path(...).

Problem

Previously, --vivado defaulted to None, and the fallback lookup (shutil.which("vivado")) happened in __init__. When Vivado wasn't found on PATH, shutil.which returned None, which was then passed directly into Path(...), causing an unhandled TypeError:

TypeError: argument should be a str or an os.PathLike object where __fspath__ returns a str, not 'NoneType'

Fix

  • --vivado now defaults to shutil.which("vivado") directly in populate_argument_parser, so the PATH lookup happens once, at argument-parsing time.
  • In __init__, if args.vivado is falsy (not provided and not found on PATH), we raise a descriptive ValueError instead of constructing a Path from None.
  • The rest of the resolution logic (expanduser().resolve() and the is_file() check) is preserved.
ValueError: Vivado binary not specified and could not be found on PATH.

…ror if not found

Signed-off-by: Shen Jiamin <shen_jiamin@comp.nus.edu.sg>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant