Allow gmxapi.commandline.cli to check GMXBIN.
authorM. Eric Irrgang <ericirrgang@gmail.com>
Fri, 27 Nov 2020 17:39:38 +0000 (20:39 +0300)
committerPaul Bauer <paul.bauer.q@gmail.com>
Tue, 29 Jun 2021 07:08:44 +0000 (07:08 +0000)
If `shutil.which` initially fails, try again using
the equivalent of `PATH=$GMXBIN`.

Refs #2961

docs/gmxapi/userguide/usage.rst
python_packaging/scripts/run_full
python_packaging/scripts/run_full_mpi
python_packaging/scripts/run_gmxapi_unittest
python_packaging/scripts/run_sample_test
python_packaging/src/gmxapi/commandline.py
python_packaging/src/setup.py

index 7cd08a764b748875803e90f5c5c99d8ddf41dfb0..df8ede0704663e968084b2e09a667cef14b76996 100644 (file)
@@ -30,20 +30,6 @@ If you would like to access multiple GROMACS installations
 from Python, build and install *gmxapi* in separate
 :ref:`virtual environments <gmxapi venv>`.
 
-In some cases *gmxapi* still needs help finding infrastructure from the
-GROMACS installation.
-For instance, :py:func:`gmxapi.commandline_operation` is not a pure API utility,
-but a wrapper for command line tools.
-Make sure that the command line tools you intend to use are discoverable in
-your :envvar:`PATH`, such as by "source"ing your :file:`GMXRC` before launching
-a *gmxapi* script.
-
-.. todo:: Get relevant GROMACS paths in Python environment.
-
-    :py:class:`gmxapi.commandline_operation` relies on the environment :envvar:`PATH`
-    to locate executables, including the :command:`gmx` wrapper binary.
-    Relates to `#2961 <https://gitlab.com/gromacs/gromacs/-/issues/2961>`__.
-
 .. _parallelism:
 
 Notes on parallelism and MPI
index b9aba79edb17494b88aa3b82c2661eb17ba21b2a..5a90d15fc90f76746e03f27bc9a202306921bb8b 100755 (executable)
@@ -4,10 +4,5 @@
 
 set -ev
 
-# TODO: (#2756) Centrally manage dependencies on the GROMACS installation.
-#  The gmxapi package, virtualenv, or test  infrastructure should have an
-#  internal mechanism for tracking the correct GROMACS installation.
-source /usr/local/gromacs/bin/GMXRC
-
 pytest $HOME/gmxapi/test
 pytest $HOME/sample_restraint/tests
index 9cae12748d35f75b9e03813c91d5828ee5946e8d..96859f25bb44b573ba52f899748635d7b8b38eaa 100755 (executable)
@@ -4,10 +4,5 @@
 
 set -ev
 
-# TODO: (#2756) Centrally manage dependencies on the GROMACS installation.
-#  The gmxapi package, virtualenv, or test  infrastructure should have an
-#  internal mechanism for tracking the correct GROMACS installation.
-source /usr/local/gromacs/bin/GMXRC
-
 mpiexec -n 2 `which python` -m mpi4py -m pytest $HOME/gmxapi/test
 mpiexec -n 2 `which python` -m mpi4py -m pytest $HOME/sample_restraint/tests
index bdf9f17c52e7c4f3cdc7510e9034bb38bf90c0cd..36b67b8ae75eb300181b651033cdf85b16108d7b 100755 (executable)
@@ -3,7 +3,4 @@
 # Additional arguments are passed along to pytest.
 # See README.md and the gmxapi/ci-<option> Docker images.
 
-# TODO: GMXRC should not be necessary with either Py 3.7+ or importlib_resources package.
-source /usr/local/gromacs/bin/GMXRC
-
 pytest $HOME/gmxapi/test $@
index 61a6d564506d01bb2698b8e338bca34eb513f4a9..aabd2196c254a3627c962d80a289e73979a1de2f 100755 (executable)
@@ -3,9 +3,4 @@
 # Additional arguments are passed along to pytest.
 # See README.md and the gmxapi/ci-<option> Docker images.
 
-# TODO: (#2756) Centrally manage dependencies on the GROMACS installation.
-#  The gmxapi package, virtualenv, or test  infrastructure should have an
-#  internal mechanism for tracking the correct GROMACS installation.
-source /usr/local/gromacs/bin/GMXRC
-
 pytest $HOME/sample_restraint/tests $@
index b6351b7486c59ada5d9e36cd7a6bcc03fcb61a9e..c3c896a17a38ef6ea692688558d8c6d2f0456db5 100644 (file)
@@ -186,6 +186,8 @@ def cli(command: NDArray, shell: bool, output: OutputCollectionDescription, stdi
     command = list([arg for arg in command])
 
     executable = shutil.which(command[0])
+    if executable is None:
+        executable = shutil.which(command[0], path=str(cli_bindir()))
     if executable is None:
         raise exceptions.ValueError('"{}" is not found or not executable.'.format(command[0]))
     command[0] = executable
index 5a66469331aa39b671ccb6fecb5ce047312490ff..27f3408f4cb31e52e04e1b2486fd1b639160fe4c 100644 (file)
@@ -161,7 +161,7 @@ setup(
     name='gmxapi',
 
     # TODO: single-source version information (currently repeated in gmxapi/version.py and CMakeLists.txt)
-    version='0.3.0a2',
+    version='0.3.0a3',
     python_requires='>=3.7',
     install_requires=['networkx>=2.0',
                       'numpy>=1'],