1 # This file is part of the GROMACS molecular simulation package.
3 # Copyright (c) 2019, by the GROMACS development team, led by
4 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
5 # and including many others, as listed in the AUTHORS file in the
6 # top-level source directory and at http://www.gromacs.org.
8 # GROMACS is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public License
10 # as published by the Free Software Foundation; either version 2.1
11 # of the License, or (at your option) any later version.
13 # GROMACS is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Lesser General Public License for more details.
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with GROMACS; if not, see
20 # http://www.gnu.org/licenses, or write to the Free Software Foundation,
21 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 # If you want to redistribute modifications to GROMACS, please
24 # consider that scientific software is very special. Version
25 # control is crucial - bugs must be traceable. We will be happy to
26 # consider code for inclusion in the official distribution, but
27 # derived work must not be called official GROMACS. Details are found
28 # in the README & COPYING files - if they are missing, get the
29 # official version at http://www.gromacs.org.
31 # To help us fund GROMACS development, we humbly ask that you cite
32 # the research papers on the package. Check out http://www.gromacs.org.
34 Provide version and release information.
37 major (int): gmxapi major version number.
38 minor (int): gmxapi minor version number.
39 patch (int): gmxapi patch level number.
40 release (bool): True if imported gmx module is an officially tagged release, else False.
44 # TODO: (pending infrastructure and further discussion) Configure with CMake.
45 # __version__ = "@PROJECT_VERSION@"
46 # major = @PROJECT_VERSION_MAJOR@
47 # minor = @PROJECT_VERSION_MINOR@
48 # patch = @PROJECT_VERSION_PATCH@
50 from gmxapi.exceptions import Error as GmxapiError
52 __version__ = "0.1.0-dev0"
57 # Note: this is not automatically updated. See RELEASE.txt and https://github.com/kassonlab/gmxapi/issues/152
63 class FeatureError(GmxapiError):
64 """Module exception to indicate missing features."""
67 def api_is_at_least(major_version, minor_version=0, patch_version=0):
68 """Allow client to check whether installed module supports the requested API level.
71 major_version (int): gmxapi major version number.
72 minor_version (int): optional gmxapi minor version number (default: 0).
73 patch_version (int): optional gmxapi patch level number (default: 0).
76 True if installed gmx package is greater than or equal to the input level
78 Note that if gmxapi.version.release is False, the package is not guaranteed to correctly or
79 fully support the reported API level.
81 if not isinstance(major_version, int) or not isinstance(minor_version, int) or not isinstance(patch_version, int):
82 raise TypeError('Version levels must be provided as integers.')
83 if major >= major_version:
85 elif major == major_version and minor >= minor_version:
87 elif major == major_version and minor == minor_version and patch >= patch_version:
93 def has_feature(name='', enable_exception=False):
94 """Query whether a named feature is available in the installed package.
96 Between updates to the API specification, new features or experimental aspects
97 may be introduced into the package and need to be detectable. This function
98 is intended to facilitate code testing and resolving differences between
99 development branches. Users should refer to the documentation for the package
100 modules and API level.
102 The function can be used to get a boolean result or can be used to raise an
103 exception in code block by setting `enable_exception=True`
106 True if named feature is recognized by the installed package, else False.
109 gmxapi.version.FeatureError if `enable_exception == True` and feature is not found.
112 if name in _named_features:
116 raise FeatureError('Feature {} not available.'.format(str(name)))