Require pybind 2.6 from environment for gmxapi Python package extension module.
[alexxy/gromacs.git] / python_packaging / src / gmxapi / simulation / fileio.py
index 6d6f8ae628e19a3e21783079b7564c3c51dbf45c..57a9ac576fa245ae1adf1de8521f0262cc9e620e 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2019, by the GROMACS development team, led by
+# Copyright (c) 2019,2021, by the GROMACS development team, led by
 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
 # and including many others, as listed in the AUTHORS file in the
 # top-level source directory and at http://www.gromacs.org.
@@ -44,7 +44,6 @@ __all__ = ['TprFile', 'read_tpr', 'write_tpr_file']
 import os
 
 from gmxapi import exceptions
-from gmxapi import _gmxapi
 
 
 class TprFile(object):
@@ -71,11 +70,6 @@ class TprFile(object):
         Note:
             Currently, TPR files are read-only from the Python interface.
 
-        Example:
-
-            >>> import gmxapi as gmx
-            >>> filehandle = gmx.TprFile(filename, 'r')
-
         """
         if filename is None:
             raise exceptions.UsageError("TprFile objects must be associated with a file.")
@@ -90,9 +84,10 @@ class TprFile(object):
         self._tprFileHandle = None
 
     def __repr__(self):
-        return "gmx.fileio.TprFile('{}', '{}')".format(self.filename, self.mode)
+        return "{}('{}', '{}')".format(self.__class__.__name__, self.filename, self.mode)
 
     def __enter__(self):
+        import gmxapi._gmxapi as _gmxapi
         self._tprFileHandle = _gmxapi.read_tprfile(self.filename)
         return self
 
@@ -256,6 +251,7 @@ def write_tpr_file(output, input=None):
     Returns:
         TBD : possibly a completion condition of some sort and/or handle to the new File
     """
+    import gmxapi._gmxapi as _gmxapi
 
     # TODO: (Data model) Decide how to find output data sources.
     if not hasattr(input, 'parameters'):