had to build/install latest cmake and gromacs as per instructions,
needed to install openmpi-bin libopenmpi-dev
used
gmxapi_ROOT=/usr/local/gromacs/ pip install --no-cache-dir gmxapi
and everything seems fine.
gmx
returns
:-) GROMACS - gmx, 2026.1 (-:
import gmxapi
print('gmxapi version : ', gmxapi.version)
prints gmxapi version : 0.4.2
but trying to run pytest:
cd python_packaging/gmxapi
pip install -r requirements.txt
pytest test
gives : ImportError: Error importing plugin “gmxapi.testsupport”: No module named ‘gmxapi’
while in python :
from gmxapi import testsupport
print('gmxapi.testsupport : ', gmxapi.testsupport)
gives: gmxapi.testsupport : <module ‘gmxapi.testsupport’ from ‘/xxx/xxx/xxx/xx/myenv/GMXAPI_spyder/lib/python3.12/site-packages/gmxapi/testsupport.py’>
can run it from inside python with
python
>>>> import pytest
>>>> pytest.main([“test”])
and unfortunately got:
platform linux – Python 3.12.3, pytest-9.0.2, pluggy-1.6.0
rootdir: /xx/xxx/xxx/GROMACS/gromacs-2026.1/python_packaging/gmxapi/test
configfile: pytest.ini
collected 41 items
test/test_commandline.py …F… [ 29%]
test/test_exceptions.py . [ 31%]
test/test_feature_check.py .ss [ 39%]
test/test_fileio.py … [ 46%]
test/test_fileio_low_level.py … [ 53%]
test/test_mdrun.py …s.s.. [ 73%]
test/test_operation.py … [ 82%]
test/test_runtime.py … [ 92%]
test/test_subgraph.py … [100%]
================================================================================= FAILURES =================================================================================
__ test_command_with_input_files ___
cleandir = PosixPath(‘/tmp/pytest-of-opw/pytest-1/test_command_with_input_files0’)
def test_command_with_input_files(cleandir):
"""Test handling of *input_file* arguments.
Generate a file and provide it as a relative path to a simple command line tool.
Confirm that the relative path (valid for the script working directory but not
for the Task working directory) is correctly normalized to an absolute path.
Check for #4827 regression.
"""
with tempfile.NamedTemporaryFile(mode="w", delete=False) as fh:
fh.write("hi\nthere\n")
fh.flush()
assert fh.closed
actual_path = Path(fh.name).resolve()
try:
with open(actual_path, "r") as fh:
num_lines = len(fh.readlines())
relative_path = os.path.relpath(actual_path, start=cleandir)
# Overload the input files facility to trigger path normalization.
# `wc` implementations are fairly consistent as far as providing a
# `-l` option and accepting a positional file argument.
cmd = commandline.commandline_operation(
executable="wc", input_files={"-l": relative_path}
)
# We want to find a relative path from the current directory that would
# not resolve correctly from the generated Task directory. We will now
# double-check that the relative path _would have_ caused the test to fail
# if the absolute path conversion (#4827) were not working correctly.
workdir = cmd.output.directory.result()
assert not Path(workdir).joinpath(relative_path).exists()
# Uncomment the following for additional debugging.
# actual_relative_path = os.path.relpath(actual_path, start=workdir)
# returncode = cmd.output.returncode.result()
# error = cmd.output.stderr.result()
# Check that the file whose lines we counted has the expected number of lines.
output = cmd.output.stdout.result()
# For `wc -l filename` on a 2-line file, we expect output
# similar to " 2 filename\n".
# Check the first non-whitespace field.
> assert output.split()[0] == str(num_lines)
^^^^^^^^^^^^^^^^^
E IndexError: list index out of range
/xxx/xxx/xxx/GROMACS/gromacs-2026.1/python_packaging/gmxapi/test/test_commandline.py:172: IndexError
looks llike is failing where it could be of help (running gromacs from python using files as args of commands !!??)
Any help here too ? Or should I create a new question
Thanks a lot
PS
trying to understand more it’s like after
cmd = commandline.commandline_operation(
executable=“wc”, input_files={“-l”: relative_path}
)
there is no cmd.run() line in test_commandline.py , but even adding it the test keeps failing
blabbing about some non existent file
error : /usr/bin/wc: pippo.txt: No such file or directory