yade.libVersions module¶
The yade.libVersions
module tracks versions of all libraries it was compiled with. Example usage is as follows:
from yade.libVersions import *
if(getVersion('cgal') > (4,9,0)):
…
else:
…
To obtain a list of all libraries use the function libVersions.printAllVersions.
All libraries listed in prerequisites are detected by this module.
Note
If we need a version of some library not listed in prerequisites, then it must also be added to that list.
When adding a new version please have a look at these three files:
- py/_libVersions.cpp: detection of versions from
#include
files by C++. - py/libVersions.py.in: python module which is constructed by cmake during compilation. All
*.in
files are processed by cmake. - cMake/FindMissingVersions.cmake: forced detection of library with undetectable version.
-
yade.libVersions.
getAllVersionsCmake
()[source]¶ This function returns library versions as provided by cmake during compilation.
Returns: dictionary in following format: { "libName" : [ (major, minor, patchlevel) , "versionString" ] }
As an example the dict below reflects what libraries this documentation was compiled with (here are only those detected by CMAKE):
Yade [1]: from yade.libVersions import * --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /usr/lib/python3.8/codeop.py in __call__(self, source, filename, symbol) 134 135 def __call__(self, source, filename, symbol): --> 136 codeob = compile(source, filename, symbol, self.flags, 1) 137 for feature in _features: 138 if codeob.co_flags & feature.compiler_flag: TypeError: required field "type_ignores" missing from Module Yade [2]: getAllVersionsCmake() --------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-2-6167f172c933> in <module>() ----> 1 getAllVersionsCmake() NameError: name 'getAllVersionsCmake' is not defined
Note
Please add here detection of other libraries when yade starts using them or if you discover how to extract from cmake a version which I didn’t add here.
-
yade.libVersions.
getLinuxVersion
()[source]¶ Returns: string containing linux release and version, preferably the value of PRETTY_NAME
from file/etc/os-release
.
-
yade.libVersions.
getVersion
(libName)[source]¶ This function returns the tuple
(major, minor, patchlevel)
with library version number. Theyade --test
in file py/tests/libVersions.py tests that this version is the same as detected by cmake and C++. If only one of those could detect the library version, then this number is used.Parameters: libName (string) – the name of the library Returns: tuple in format (major, minor, patchlevel)
iflibName
exists. Otherwise it returnsNone
.Note
library openblas has no properly defined version in header files, this function will return
(0,0,0)
for openblas. Parsing the version string would be unreliable. The mpi version detected by cmake sometimes is different than version detected by C++, this needs further investigation.
-
yade.libVersions.
printAllVersions
(rstFormat=False)[source]¶ This function prints a nicely formatted table with library versions.
Parameters: rstFormat (bool) – whether to print table using the reStructuredText formatting. Defaults to False
and prints using Gitlab markdown rules so that it is easy to paste into gitlab discussions.As an example the table below actually reflects with what libraries this documentation was compiled:
Yade [1]: printAllVersions() --------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-1-553a93cf3584> in <module>() ----> 1 printAllVersions() NameError: name 'printAllVersions' is not defined
Note
For convenience at startup
from yade.libVersions import printAllVersions
is executed, so that this function is readily accessible.
-
yade._libVersions.
getAllVersionsCpp
() → dict¶ This function returns library versions as discovered by C++ during compilation from all the
#include
headers. This can be useful in debugging to detect some library.so
conflicts.Returns: dictionary in folowing format: { "libName" : [ (major, minor, patch) , "versionString" ] }
As an example the dict below reflects what libraries this documentation was compiled with (here are only those detected by C++):
Yade [1]: from yade.libVersions import * --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /usr/lib/python3.8/codeop.py in __call__(self, source, filename, symbol) 134 135 def __call__(self, source, filename, symbol): --> 136 codeob = compile(source, filename, symbol, self.flags, 1) 137 for feature in _features: 138 if codeob.co_flags & feature.compiler_flag: TypeError: required field "type_ignores" missing from Module Yade [2]: getAllVersionsCpp() --------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-2-af2e7cab008f> in <module>() ----> 1 getAllVersionsCpp() NameError: name 'getAllVersionsCpp' is not defined
Note
Please add here C++ detection of other libraries when yade starts using them.