# TODO: (#2896) Find a more canonical way to identify the GROMACS commandline wrapper binary.
# We should be able to get the GMXRC contents and related hints from a gmxapi
# package resource or from module attributes of a ``gromacs`` stub package.
- command = shutil.which('gmx')
- if command is None:
- gmxbindir = os.getenv('GMXBIN')
- if gmxbindir is None:
- gromacsdir = os.getenv('GROMACS_DIR')
- if gromacsdir is not None and gromacsdir != '':
- gmxbindir = os.path.join(gromacsdir, 'bin')
- if gmxbindir is None:
- gmxapidir = os.getenv('gmxapi_DIR')
- if gmxapidir is not None and gmxapidir != '':
- gmxbindir = os.path.join(gmxapidir, 'bin')
- if gmxbindir is not None:
- gmxbindir = os.path.abspath(gmxbindir)
- command = shutil.which('gmx', path=gmxbindir)
- else:
- message = "Tests need 'gmx' command line tool, but could not find it on the path."
- raise RuntimeError(message)
+ allowed_command_names = ['gmx', 'gmx_mpi']
+ command = None
+ for command_name in allowed_command_names:
+ if command is not None:
+ break
+ command = shutil.which(command_name)
+ if command is None:
+ gmxbindir = os.getenv('GMXBIN')
+ if gmxbindir is None:
+ gromacsdir = os.getenv('GROMACS_DIR')
+ if gromacsdir is not None and gromacsdir != '':
+ gmxbindir = os.path.join(gromacsdir, 'bin')
+ if gmxbindir is None:
+ gmxapidir = os.getenv('gmxapi_DIR')
+ if gmxapidir is not None and gmxapidir != '':
+ gmxbindir = os.path.join(gmxapidir, 'bin')
+ if gmxbindir is not None:
+ gmxbindir = os.path.abspath(gmxbindir)
+ command = shutil.which(command_name, path=gmxbindir)
if command is None:
message = "Tests need 'gmx' command line tool, but could not find it on the path."
raise RuntimeError(message)