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:

  1. py/_libVersions.cpp: detection of versions from #include files by C++.
  2. py/libVersions.py.in: python module which is constructed by cmake during compilation. All *.in files are processed by cmake.
  3. cMake/FindMissingVersions.cmake: forced detection of library with undetectable version.

Hint

The safest way to compare versions is to use builtin python tuple comparison e.g. if(cgalVer > (4,9,0) and cgalVer < (5,1,1)):.

yade.libVersions.getAllVersions(rstFormat=False)[source]
Returns:str - this function returns the result of printAllVersions(rstFormat) call inside a string variable.
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 *

Yade [2]: getAllVersionsCmake()
Out[2]: 
{'boost': [(1, 65, 1), '106501'],
 'clp': [(1, 16, 11), '1.16.11'],
 'cmake': [(3, 10, 2), '3.10.2'],
 'coinutils': [(2, 10, 14), '2.10.14'],
 'compiler': [(7, 5, 0), '/usr/bin/c++ 7.5.0'],
 'eigen': [(3, 3, 4), '3.3.4'],
 'freeglut': [(2, 8, 1), '2.8.1'],
 'ipython': [(5, 5, 0), '5.5.0'],
 'mpi': [(3, 1, 0), '3.1'],
 'mpi4py': [(2, 0, 0), '2.0.0'],
 'mpmath': [(1, 0, 0), '1.0.0'],
 'python': [(3, 6, 9), '3.6.9'],
 'sphinx': [(1, 6, 7), '1.6.7-final-0'],
 'suitesparse': [(5, 1, 2), '5.1.2'],
 'vtk': [(6, 3, 0), '6.3.0']}

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.getArchitecture()[source]
Returns:string containing processor architecture name, as reported by uname -m call or from CMAKE_HOST_SYSTEM_PROCESSOR cmake variable.
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. The yade --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) if libName exists. Otherwise it returns None.

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()

```
Yade version   :  2022-05-19.git-571b2c3
Yade features  :  LOGGER USEFUL_ERRORS VTK OPENMP GTS QT5 CGAL PFVFLOW PFVFLOW LINSOLV MPI TWOPHASEFLOW LS_DEM FEMLIKE GL2PS LBMFLOW THERMAL PARTIALSAT POTENTIAL_PARTICLES POTENTIAL_BLOCKS
Yade config dir:  ~/.config/yade-ci
Yade precision :  53 bits, 15 decimal places, without mpmath, PrecisionDouble
```

Libraries used :

| library       | cmake                | C++                 |
| ------------- | -------------------- | ------------------- |
| boost         | 106501               | 1.65.1              |
| cgal          |                      | 4.11                |
| clp           | 1.16.11              | 1.16.11             |
| cmake         | 3.10.2               |                     |
| coinutils     | 2.10.14              | 2.10.14             |
| compiler      | /usr/bin/c++ 7.5.0   | gcc 7.5.0           |
| eigen         | 3.3.4                | 3.3.4               |
| freeglut      | 2.8.1                |                     |
| gl            |                      | 20190911            |
| ipython       | 5.5.0                |                     |
| metis         |                      | 5.1.0               |
| mpi           | 3.1                  | ompi:2.1.1          |
| mpi4py        | 2.0.0                |                     |
| mpmath        | 1.0.0                |                     |
| openblas      |                      |  OpenBLAS 0.2.20    |
| python        | 3.6.9                | 3.6.9               |
| qglviewer     |                      | 2.6.3               |
| qt            |                      | 5.9.5               |
| sphinx        | 1.6.7-final-0        |                     |
| sqlite        |                      | 3.22.0              |
| suitesparse   | 5.1.2                | 5.1.2               |
| vtk           | 6.3.0                | 6.3.0               |

```
Linux version  :  Ubuntu 18.04.6 LTS
Architecture   :  amd64
Little endian  :  True
```

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 *

Yade [2]: getAllVersionsCpp()
Out[2]: 
{'boost': [(1, 65, 1), '1.65.1'],
 'cgal': [(4, 11, 0), '4.11'],
 'clp': [(1, 16, 11), '1.16.11'],
 'coinutils': [(2, 10, 14), '2.10.14'],
 'compiler': [(7, 5, 0), 'gcc 7.5.0'],
 'eigen': [(3, 3, 4), '3.3.4'],
 'gl': [(2019, 9, 11), '20190911'],
 'metis': [(5, 1, 0), '5.1.0'],
 'mpc': [],
 'mpfr': [],
 'mpi': [(2, 1, 1), 'ompi:2.1.1'],
 'openblas': [(0, 0, 0), ' OpenBLAS 0.2.20 '],
 'python': [(3, 6, 9), '3.6.9'],
 'qglviewer': [(2, 6, 3), '2.6.3'],
 'qt': [(5, 9, 5), '5.9.5'],
 'sqlite': [(3, 22, 0), '3.22.0'],
 'suitesparse': [(5, 1, 2), '5.1.2'],
 'vtk': [(6, 3, 0), '6.3.0']}

Note

Please add here C++ detection of other libraries when yade starts using them.