Skip to content

Quote the SU2 executable path in SU2_PY on Linux/macOS (SU2_RUN with spaces) - #2935

Open
nikita-ageev wants to merge 1 commit into
su2code:developfrom
nikita-ageev:fix/su2py-quote-exec-path
Open

nikita-ageev wants to merge 1 commit into
su2code:developfrom
nikita-ageev:fix/su2py-quote-exec-path

Conversation

@nikita-ageev

@nikita-ageev nikita-ageev commented Sep 28, 2026 •

Copy link
Copy Markdown

Proposed Changes

SU2_PY/SU2/run/interface.py builds the command as os.path.join(SU2_RUN, "SU2_CFD") + " config_CFD.cfg" and runs it with shell=True. The executable path is quoted only on Windows (quote = '"' if sys.platform == "win32" else ""), so on Linux/macOS any SU2_PY script (shape_optimization.py, parallel_computation.py, ...) fails if SU2_RUN contains a space.

This PR moves the quoting into build_command: the first word of the command is joined with SU2_RUN and quoted (shlex.quote on POSIX, double quotes on Windows as before), the callers pass plain "SU2_CFD config_CFD.cfg" strings. The quoted path is then inserted into the MPI template as before (mpirun -n %i %s, srun, SU2_MPI_COMMAND). The module-level quote variable is removed; it was not used outside interface.py.

Reproduction on macOS, SU2_RUN=".../su2 bin", shape_opt_euler_py from serial_regression.py:

before:
Command = /.../su2 bin/SU2_CFD config_CFD.cfg
SU2 process returned error '127'
/bin/sh: /.../su2: No such file or directory

after:
Command = '/.../su2 bin/SU2_CFD' config_CFD.cfg
optimization runs to the end

With the change and SU2_RUN containing a space, history_project.csv and the optimizer output of shape_opt_euler_py are identical to develop with a SU2_RUN without spaces. The MPI path was checked with NUMBER_PART=2: mpirun -n 2 '/.../su2 bin/SU2_CFD' config_CFD.cfg runs with 2 ranks. The Windows branch produces the same string as before.

Related Work

None found. Separate from #2934 (also SU2_PY).

PR Checklist

  • I am submitting my contribution to the develop branch.
  • My contribution generates no new compiler warnings (try with --warnlevel=3 when using meson).
  • My contribution is commented and consistent with SU2 style (https://su2code.github.io/docs_v7/Style-Guide/).
  • I used the pre-commit hook to prevent dirty commits and used pre-commit run --all to format old commits.
  • I have added a test case that demonstrates my contribution, if necessary. — Not necessary: the change only affects how the executable path is quoted; shape_opt_euler_py passes unchanged, and the reproduction above (SU2_RUN with a space) fails before and passes after.
  • I have updated appropriate documentation (Tutorials, Docs Page, config_template.cpp), if necessary. — Not necessary: no user-facing option changed.

SU2_RUN containing a space broke SU2_PY on Linux/macOS because the
executable path was only quoted on Windows. Quote it in build_command
(shlex.quote on POSIX, double quotes on Windows) and pass plain
"SU2_XXX config.cfg" strings from the callers.

This branch has not been deployed

No deployments
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