Odd behavior of setup

Using the 1.0rc tarball, I find

./setup --extra-cxx-flags -march=haswell

results in:

usage: setup [-h] [–cc STRING] [–cxx STRING] [–fc STRING]

[–extra-cxx-flags STRING] [–extra-fc-flags STRING]
[–custom-cc-flags STRING] [–custom-cxx-flags STRING]
[–custom-fc-flags STRING]
setup: error: argument --extra-cxx-flags: expected one argument

similar results are obtained from

./setup --extra-cxx-flags “-march=haswell”

some fiddling reveals that what works is

./setup --extra-cxx-flags "-march=haswell " <-- trailing space needed

similar behavior is found for --extra-math-flags, for example

./setup --extra-math-flags “-lm”

fails in the same way, but

./setup --extra-math-flags “-lgfortran -lm”

works as expected, no extra space needed.

Yes, python’s argparse module is what’s being used under the hood, and it’s picking up the single dash as a short-form argument (-lm --> -l=m). Unfortunately, I can’t turn off short-form arguments because setup uses them to pass -DCMAKE_VARIABLE directly to cmake. But associating the argument and value like --extra-math-flags="-lm" works and looks fairly natural. I’ve changed the help string, so see if having something like the below would have smoothed your interaction with setup.

  --extra-math-flags STRING
                        extra linker flags (usually -Llibdir -llibname type
                        arguments). use equals, quotes, and spaces for correct
                        parsing (e.g., --extra-math-flags="-lm -lgfortran")
                        [default: None]

This does help, thank you Lori.